os/graphics/egl/egltest/endpointtestsuite/automated/src/eglendpointwrap.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/egl/egltest/endpointtestsuite/automated/src/eglendpointwrap.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,159 @@
     1.4 +// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +/**
    1.20 + @file
    1.21 + @test
    1.22 + @internalComponent - Internal Symbian test code
    1.23 +*/
    1.24 +
    1.25 +#include <e32debug.h>
    1.26 +#include "eglendpointwrap.h"
    1.27 +#include "egltest_commscommon.h"
    1.28 +
    1.29 +
    1.30 +/*
    1.31 + * TEglEndpointWrap is a simple class that presents all of the EGL endpoint
    1.32 + * extension functions without the user needing to perform an eglGetProcAddress()
    1.33 + * to obtain the function pointer. Each endpoint member function takes the same
    1.34 + * arguments as the EGL functions and returns the same types. After construction
    1.35 + * you should check the Error() function to ensure that all function pointers
    1.36 + * were resolved. Trying to use one of the endpoint functions in the event of a
    1.37 + * construction error will result in a panic.
    1.38 + */
    1.39 +
    1.40 +
    1.41 +TEglEndpointWrap::TEglEndpointWrap()
    1.42 +    {
    1.43 +    //Save all the endpoint function pointers. If an error occurs, log it to iError.
    1.44 +    TRAP(iError,
    1.45 +        ipfnEglCreateEndpointNOK = reinterpret_cast<PFNEGLCREATEENDPOINTNOKPROC>(ProcAddressL("eglCreateEndpointNOK"));
    1.46 +        ipfnEglDestroyEndpointNOK = reinterpret_cast<PFNEGLDESTROYENDPOINTNOKPROC>(ProcAddressL("eglDestroyEndpointNOK"));
    1.47 +        ipfnEglGetEndpointAttribNOK = reinterpret_cast<PFNEGLGETENDPOINTATTRIBNOKPROC>(ProcAddressL("eglGetEndpointAttribNOK"));
    1.48 +        ipfnEglSetEndpointAttribNOK = reinterpret_cast<PFNEGLSETENDPOINTATTRIBNOKPROC>(ProcAddressL("eglSetEndpointAttribNOK"));
    1.49 +        ipfnEglEndpointBeginStreamingNOK = reinterpret_cast<PFNEGLENDPOINTBEGINSTREAMINGNOKPROC>(ProcAddressL("eglEndpointBeginStreamingNOK"));
    1.50 +        ipfnEglEndpointEndStreamingNOK = reinterpret_cast<PFNEGLENDPOINTENDSTREAMINGNOKPROC>(ProcAddressL("eglEndpointEndStreamingNOK"));
    1.51 +        ipfnEglAcquireImageNOK = reinterpret_cast<PFNEGLACQUIREIMAGENOKPROC>(ProcAddressL("eglAcquireImageNOK"));
    1.52 +        ipfnEglReleaseImageNOK = reinterpret_cast<PFNEGLRELEASEIMAGENOKPROC>(ProcAddressL("eglReleaseImageNOK"));
    1.53 +        ipfnEglGetEndpointDirtyAreaNOK = reinterpret_cast<PFNEGLGETENDPOINTDIRTYAREANOKPROC>(ProcAddressL("eglGetEndpointDirtyAreaNOK"));
    1.54 +        ipfnEglEndpointRequestNotificationNOK = reinterpret_cast<PFNEGLENDPOINTREQUESTNOTIFICATIONNOKPROC>(ProcAddressL("eglEndpointRequestNotificationNOK"));
    1.55 +        ipfnEglEndpointCancelNotificationNOK = reinterpret_cast<PFNEGLENDPOINTCANCELNOTIFICATIONNOKPROC>(ProcAddressL("eglEndpointCancelNotificationNOK"));
    1.56 +        ipfnEglDestroyImageKHR = reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>(ProcAddressL("eglDestroyImageKHR"));
    1.57 +        );
    1.58 +    }
    1.59 +
    1.60 +
    1.61 +TInt TEglEndpointWrap::Error() const
    1.62 +    {
    1.63 +    return iError;
    1.64 +    }
    1.65 +
    1.66 +
    1.67 +TAnyFuncPtr TEglEndpointWrap::ProcAddressL(const char* aProcName) const
    1.68 +    {
    1.69 +    //get the function pointer and check for errors
    1.70 +    TAnyFuncPtr func = reinterpret_cast<TAnyFuncPtr>(eglGetProcAddress(aProcName));
    1.71 +    if(!func)
    1.72 +        {
    1.73 +        User::Leave(KErrNotFound);
    1.74 +        }
    1.75 +    return func;
    1.76 +    }
    1.77 +
    1.78 +
    1.79 +EGLEndpointNOK TEglEndpointWrap::CreateEndpoint(EGLDisplay dpy, EGLenum type, EGLenum source_type, 
    1.80 +                                                EGLEndpointSourceNOK source, const EGLint *attrib_list) const
    1.81 +    {
    1.82 +    ENDPOINT_ASSERT_DEBUG(iError == KErrNone, User::Invariant());
    1.83 +    return ipfnEglCreateEndpointNOK(dpy, type, source_type, source, attrib_list);
    1.84 +    }
    1.85 +
    1.86 +
    1.87 +EGLBoolean TEglEndpointWrap::DestroyEndpoint(EGLDisplay dpy, EGLEndpointNOK endpoint) const
    1.88 +    {
    1.89 +    ENDPOINT_ASSERT_DEBUG(iError == KErrNone, User::Invariant());
    1.90 +    return ipfnEglDestroyEndpointNOK(dpy, endpoint);
    1.91 +    }
    1.92 +
    1.93 +
    1.94 +EGLint TEglEndpointWrap::GetEndpointAttrib(EGLDisplay dpy, EGLEndpointNOK endpoint, EGLint attrib) const
    1.95 +    {
    1.96 +    ENDPOINT_ASSERT_DEBUG(iError == KErrNone, User::Invariant());
    1.97 +    return ipfnEglGetEndpointAttribNOK(dpy, endpoint, attrib);
    1.98 +    }
    1.99 +
   1.100 +
   1.101 +EGLBoolean TEglEndpointWrap::SetEndpointAttrib(EGLDisplay dpy, EGLEndpointNOK endpoint, EGLint attrib, EGLint value) const
   1.102 +    {
   1.103 +    ENDPOINT_ASSERT_DEBUG(iError == KErrNone, User::Invariant());
   1.104 +    return ipfnEglSetEndpointAttribNOK(dpy, endpoint, attrib, value);
   1.105 +    }
   1.106 +
   1.107 +
   1.108 +EGLBoolean TEglEndpointWrap::EndpointBeginStreaming(EGLDisplay dpy, EGLEndpointNOK endpoint) const
   1.109 +    {
   1.110 +    ENDPOINT_ASSERT_DEBUG(iError == KErrNone, User::Invariant());
   1.111 +    return ipfnEglEndpointBeginStreamingNOK(dpy, endpoint);
   1.112 +    }
   1.113 +
   1.114 +
   1.115 +EGLBoolean TEglEndpointWrap::EndpointEndStreaming(EGLDisplay dpy, EGLEndpointNOK endpoint) const
   1.116 +    {
   1.117 +    ENDPOINT_ASSERT_DEBUG(iError == KErrNone, User::Invariant());
   1.118 +    return ipfnEglEndpointEndStreamingNOK(dpy, endpoint);
   1.119 +    }
   1.120 +
   1.121 +
   1.122 +EGLImageKHR TEglEndpointWrap::AcquireImage(EGLDisplay dpy, EGLEndpointNOK endpoint) const
   1.123 +    {
   1.124 +    ENDPOINT_ASSERT_DEBUG(iError == KErrNone, User::Invariant());
   1.125 +    return ipfnEglAcquireImageNOK(dpy, endpoint);
   1.126 +    }
   1.127 +
   1.128 +
   1.129 +EGLBoolean TEglEndpointWrap::ReleaseImage(EGLDisplay dpy, EGLEndpointNOK endpoint, EGLImageKHR image, EGLenum api) const
   1.130 +    {
   1.131 +    ENDPOINT_ASSERT_DEBUG(iError == KErrNone, User::Invariant());
   1.132 +    return ipfnEglReleaseImageNOK(dpy, endpoint, image, api);
   1.133 +    }
   1.134 +
   1.135 +
   1.136 +EGLint TEglEndpointWrap::GetEndpointDirtyArea(EGLDisplay dpy, EGLEndpointNOK endpoint, EGLint* rects, 
   1.137 +                                              EGLint start_rect, EGLint max_rects, EGLBoolean collapse) const
   1.138 +    {
   1.139 +    ENDPOINT_ASSERT_DEBUG(iError == KErrNone, User::Invariant());
   1.140 +    return ipfnEglGetEndpointDirtyAreaNOK(dpy, endpoint, rects, start_rect, max_rects, collapse);
   1.141 +    }
   1.142 +
   1.143 +
   1.144 +EGLBoolean TEglEndpointWrap::EndpointRequestNotification(EGLDisplay dpy, EGLEndpointNOK endpoint, EGLTRequestStatusNOK sync) const
   1.145 +    {
   1.146 +    ENDPOINT_ASSERT_DEBUG(iError == KErrNone, User::Invariant());
   1.147 +    return ipfnEglEndpointRequestNotificationNOK(dpy, endpoint, sync);
   1.148 +    }
   1.149 +
   1.150 +
   1.151 +EGLBoolean TEglEndpointWrap::EndpointCancelNotification(EGLDisplay dpy, EGLEndpointNOK endpoint) const
   1.152 +    {
   1.153 +    ENDPOINT_ASSERT_DEBUG(iError == KErrNone, User::Invariant());
   1.154 +    return ipfnEglEndpointCancelNotificationNOK(dpy, endpoint);
   1.155 +    }
   1.156 +
   1.157 +
   1.158 +EGLBoolean TEglEndpointWrap::DestroyImage(EGLDisplay dpy, EGLImageKHR image) const
   1.159 +    {
   1.160 +    ENDPOINT_ASSERT_DEBUG(iError == KErrNone, User::Invariant());
   1.161 +    return ipfnEglDestroyImageKHR(dpy, image);
   1.162 +    }