1 /* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
2 * |
|
3 * Permission is hereby granted, free of charge, to any person obtaining a |
|
4 * copy of this software and /or associated documentation files |
|
5 * (the "Materials "), to deal in the Materials without restriction, |
|
6 * including without limitation the rights to use, copy, modify, merge, |
|
7 * publish, distribute, sublicense, and/or sell copies of the Materials, |
|
8 * and to permit persons to whom the Materials are furnished to do so, |
|
9 * subject to the following conditions: |
|
10 * |
|
11 * The above copyright notice and this permission notice shall be included |
|
12 * in all copies or substantial portions of the Materials. |
|
13 * |
|
14 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|
15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|
16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
|
17 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
|
18 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
|
19 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR |
|
20 * THE USE OR OTHER DEALINGS IN THE MATERIALS. |
|
21 */ |
|
22 |
|
23 #ifndef _SFEGLINTERFACE_H_ |
|
24 #define _SFEGLINTERFACE_H_ |
|
25 |
|
26 #include "riImage.h" |
|
27 #include "VGInterface.h" |
|
28 |
|
29 |
|
30 // Get pointer to global interface object. |
|
31 extern "C" { RI_API_CALL IEGLtoVGInterface* getVGInterface(void); } |
|
32 extern "C" { RI_API_CALL VGErrorCode vgPlatsimGetError(void); } |
|
33 |
|
34 namespace OpenVGRI |
|
35 { |
|
36 void* eglvgGetCurrentVGContext(void); |
|
37 bool eglvgIsInUse(void* image); |
|
38 bool eglvgLockSurface(bool read, bool write); |
|
39 bool eglvgUnlockSurface(); |
|
40 void OSAcquireMutex(void); |
|
41 void OSReleaseMutex(void); |
|
42 void eglvgGetImageDescriptor( void* image, Color::Descriptor &desc, int &width, int &height, int &stride ); |
|
43 void* eglvgGetImageData( void* image ); |
|
44 } |
|
45 |
|
46 // Services from OpenVG to EGL |
|
47 class EGLtoVGInterface : public IEGLtoVGInterface |
|
48 { |
|
49 public: |
|
50 EGLtoVGInterface(); |
|
51 ~EGLtoVGInterface(); |
|
52 |
|
53 void SetEGLInterface( IVGtoEGLInterface* egl ); |
|
54 void* CreateContext( void* shareContext ); |
|
55 bool ReleaseContext( void* context ); |
|
56 bool CreateSurface( const SurfaceDescriptor* desc, BufferContainer* buffers, void* image ); |
|
57 bool ReleaseSurface(void* surface); |
|
58 bool SetCurrentSurface( void* context, void* surface ); |
|
59 bool ResizeSurface( void* context, void* surface, int width, int height, BufferContainer* buffers ); |
|
60 bool IsValidImage( void* image, CColorDescriptor* colorDesc, int* width, int* height ); |
|
61 bool IsImageInUse( void* image ); |
|
62 void* CreateImage(); |
|
63 bool ReleaseImage(); |
|
64 void Flush(); |
|
65 void Finish(); |
|
66 fpVGProc GetVGProcAddress( const char *procname ); |
|
67 void CopyBuffers( void* buffer, int stride, void* surface ); |
|
68 void UpdateBuffers( void* buffer, int stride, const SurfaceDescriptor* desc ); |
|
69 bool IsRootImage( void* buffer ); |
|
70 void GetImageData( void* image, SurfaceDescriptor& desc, void* data ); |
|
71 void AddRef( void* image ); |
|
72 void RemoveRef( void* image ); |
|
73 |
|
74 // Methods for local OpenVG-implementation. To be called only from OpenVG internals. |
|
75 static IVGtoEGLInterface* GetEGLInterface(); |
|
76 static OpenVGRI::Color::Descriptor vgDescriptorFromSurfaceDescriptor(const SurfaceDescriptor* sdesc); // \todo static |
|
77 |
|
78 private: |
|
79 int findContext(OpenVGRI::VGContext* contextPtr); |
|
80 bool isValidImage(void* image); |
|
81 |
|
82 private: |
|
83 OpenVGRI::Array<OpenVGRI::VGContext*> m_contexts; |
|
84 IVGtoEGLInterface* m_egl; |
|
85 |
|
86 }; |
|
87 |
|
88 #endif |
|
89 |
|