egl/egltest/endpointtestsuite/automated/src/eglendpointwrap.cpp
branchRCL_3
changeset 163 bbf46f59e123
equal deleted inserted replaced
150:57c618273d5c 163:bbf46f59e123
       
     1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @test
       
    19  @internalComponent - Internal Symbian test code
       
    20 */
       
    21 
       
    22 #include <e32debug.h>
       
    23 #include "eglendpointwrap.h"
       
    24 #include "egltest_commscommon.h"
       
    25 
       
    26 
       
    27 /*
       
    28  * TEglEndpointWrap is a simple class that presents all of the EGL endpoint
       
    29  * extension functions without the user needing to perform an eglGetProcAddress()
       
    30  * to obtain the function pointer. Each endpoint member function takes the same
       
    31  * arguments as the EGL functions and returns the same types. After construction
       
    32  * you should check the Error() function to ensure that all function pointers
       
    33  * were resolved. Trying to use one of the endpoint functions in the event of a
       
    34  * construction error will result in a panic.
       
    35  */
       
    36 
       
    37 
       
    38 TEglEndpointWrap::TEglEndpointWrap()
       
    39     {
       
    40     //Save all the endpoint function pointers. If an error occurs, log it to iError.
       
    41     TRAP(iError,
       
    42         ipfnEglCreateEndpointNOK = reinterpret_cast<PFNEGLCREATEENDPOINTNOKPROC>(ProcAddressL("eglCreateEndpointNOK"));
       
    43         ipfnEglDestroyEndpointNOK = reinterpret_cast<PFNEGLDESTROYENDPOINTNOKPROC>(ProcAddressL("eglDestroyEndpointNOK"));
       
    44         ipfnEglGetEndpointAttribNOK = reinterpret_cast<PFNEGLGETENDPOINTATTRIBNOKPROC>(ProcAddressL("eglGetEndpointAttribNOK"));
       
    45         ipfnEglSetEndpointAttribNOK = reinterpret_cast<PFNEGLSETENDPOINTATTRIBNOKPROC>(ProcAddressL("eglSetEndpointAttribNOK"));
       
    46         ipfnEglEndpointBeginStreamingNOK = reinterpret_cast<PFNEGLENDPOINTBEGINSTREAMINGNOKPROC>(ProcAddressL("eglEndpointBeginStreamingNOK"));
       
    47         ipfnEglEndpointEndStreamingNOK = reinterpret_cast<PFNEGLENDPOINTENDSTREAMINGNOKPROC>(ProcAddressL("eglEndpointEndStreamingNOK"));
       
    48         ipfnEglAcquireImageNOK = reinterpret_cast<PFNEGLACQUIREIMAGENOKPROC>(ProcAddressL("eglAcquireImageNOK"));
       
    49         ipfnEglReleaseImageNOK = reinterpret_cast<PFNEGLRELEASEIMAGENOKPROC>(ProcAddressL("eglReleaseImageNOK"));
       
    50         ipfnEglGetEndpointDirtyAreaNOK = reinterpret_cast<PFNEGLGETENDPOINTDIRTYAREANOKPROC>(ProcAddressL("eglGetEndpointDirtyAreaNOK"));
       
    51         ipfnEglEndpointRequestNotificationNOK = reinterpret_cast<PFNEGLENDPOINTREQUESTNOTIFICATIONNOKPROC>(ProcAddressL("eglEndpointRequestNotificationNOK"));
       
    52         ipfnEglEndpointCancelNotificationNOK = reinterpret_cast<PFNEGLENDPOINTCANCELNOTIFICATIONNOKPROC>(ProcAddressL("eglEndpointCancelNotificationNOK"));
       
    53         ipfnEglDestroyImageKHR = reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>(ProcAddressL("eglDestroyImageKHR"));
       
    54         );
       
    55     }
       
    56 
       
    57 
       
    58 TInt TEglEndpointWrap::Error() const
       
    59     {
       
    60     return iError;
       
    61     }
       
    62 
       
    63 
       
    64 TAnyFuncPtr TEglEndpointWrap::ProcAddressL(const char* aProcName) const
       
    65     {
       
    66     //get the function pointer and check for errors
       
    67     TAnyFuncPtr func = reinterpret_cast<TAnyFuncPtr>(eglGetProcAddress(aProcName));
       
    68     if(!func)
       
    69         {
       
    70         User::Leave(KErrNotFound);
       
    71         }
       
    72     return func;
       
    73     }
       
    74 
       
    75 
       
    76 EGLEndpointNOK TEglEndpointWrap::CreateEndpoint(EGLDisplay dpy, EGLenum type, EGLenum source_type, 
       
    77                                                 EGLEndpointSourceNOK source, const EGLint *attrib_list) const
       
    78     {
       
    79     ENDPOINT_ASSERT_DEBUG(iError == KErrNone, User::Invariant());
       
    80     return ipfnEglCreateEndpointNOK(dpy, type, source_type, source, attrib_list);
       
    81     }
       
    82 
       
    83 
       
    84 EGLBoolean TEglEndpointWrap::DestroyEndpoint(EGLDisplay dpy, EGLEndpointNOK endpoint) const
       
    85     {
       
    86     ENDPOINT_ASSERT_DEBUG(iError == KErrNone, User::Invariant());
       
    87     return ipfnEglDestroyEndpointNOK(dpy, endpoint);
       
    88     }
       
    89 
       
    90 
       
    91 EGLint TEglEndpointWrap::GetEndpointAttrib(EGLDisplay dpy, EGLEndpointNOK endpoint, EGLint attrib) const
       
    92     {
       
    93     ENDPOINT_ASSERT_DEBUG(iError == KErrNone, User::Invariant());
       
    94     return ipfnEglGetEndpointAttribNOK(dpy, endpoint, attrib);
       
    95     }
       
    96 
       
    97 
       
    98 EGLBoolean TEglEndpointWrap::SetEndpointAttrib(EGLDisplay dpy, EGLEndpointNOK endpoint, EGLint attrib, EGLint value) const
       
    99     {
       
   100     ENDPOINT_ASSERT_DEBUG(iError == KErrNone, User::Invariant());
       
   101     return ipfnEglSetEndpointAttribNOK(dpy, endpoint, attrib, value);
       
   102     }
       
   103 
       
   104 
       
   105 EGLBoolean TEglEndpointWrap::EndpointBeginStreaming(EGLDisplay dpy, EGLEndpointNOK endpoint) const
       
   106     {
       
   107     ENDPOINT_ASSERT_DEBUG(iError == KErrNone, User::Invariant());
       
   108     return ipfnEglEndpointBeginStreamingNOK(dpy, endpoint);
       
   109     }
       
   110 
       
   111 
       
   112 EGLBoolean TEglEndpointWrap::EndpointEndStreaming(EGLDisplay dpy, EGLEndpointNOK endpoint) const
       
   113     {
       
   114     ENDPOINT_ASSERT_DEBUG(iError == KErrNone, User::Invariant());
       
   115     return ipfnEglEndpointEndStreamingNOK(dpy, endpoint);
       
   116     }
       
   117 
       
   118 
       
   119 EGLImageKHR TEglEndpointWrap::AcquireImage(EGLDisplay dpy, EGLEndpointNOK endpoint) const
       
   120     {
       
   121     ENDPOINT_ASSERT_DEBUG(iError == KErrNone, User::Invariant());
       
   122     return ipfnEglAcquireImageNOK(dpy, endpoint);
       
   123     }
       
   124 
       
   125 
       
   126 EGLBoolean TEglEndpointWrap::ReleaseImage(EGLDisplay dpy, EGLEndpointNOK endpoint, EGLImageKHR image, EGLenum api) const
       
   127     {
       
   128     ENDPOINT_ASSERT_DEBUG(iError == KErrNone, User::Invariant());
       
   129     return ipfnEglReleaseImageNOK(dpy, endpoint, image, api);
       
   130     }
       
   131 
       
   132 
       
   133 EGLint TEglEndpointWrap::GetEndpointDirtyArea(EGLDisplay dpy, EGLEndpointNOK endpoint, EGLint* rects, 
       
   134                                               EGLint start_rect, EGLint max_rects, EGLBoolean collapse) const
       
   135     {
       
   136     ENDPOINT_ASSERT_DEBUG(iError == KErrNone, User::Invariant());
       
   137     return ipfnEglGetEndpointDirtyAreaNOK(dpy, endpoint, rects, start_rect, max_rects, collapse);
       
   138     }
       
   139 
       
   140 
       
   141 EGLBoolean TEglEndpointWrap::EndpointRequestNotification(EGLDisplay dpy, EGLEndpointNOK endpoint, EGLTRequestStatusNOK sync) const
       
   142     {
       
   143     ENDPOINT_ASSERT_DEBUG(iError == KErrNone, User::Invariant());
       
   144     return ipfnEglEndpointRequestNotificationNOK(dpy, endpoint, sync);
       
   145     }
       
   146 
       
   147 
       
   148 EGLBoolean TEglEndpointWrap::EndpointCancelNotification(EGLDisplay dpy, EGLEndpointNOK endpoint) const
       
   149     {
       
   150     ENDPOINT_ASSERT_DEBUG(iError == KErrNone, User::Invariant());
       
   151     return ipfnEglEndpointCancelNotificationNOK(dpy, endpoint);
       
   152     }
       
   153 
       
   154 
       
   155 EGLBoolean TEglEndpointWrap::DestroyImage(EGLDisplay dpy, EGLImageKHR image) const
       
   156     {
       
   157     ENDPOINT_ASSERT_DEBUG(iError == KErrNone, User::Invariant());
       
   158     return ipfnEglDestroyImageKHR(dpy, image);
       
   159     }