|
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 * Initial Contributors: |
|
23 * Nokia Corporation - initial contribution. |
|
24 * |
|
25 * Contributors: |
|
26 * |
|
27 * Description: |
|
28 * |
|
29 */ |
|
30 |
|
31 #include "EGLThread.h" |
|
32 #include "EGLContext.h" |
|
33 #include "EGLSurface.h" |
|
34 |
|
35 CEGLThread::CEGLThread( EGLI_THREAD_ID threadId, EGLint supportedApis ) : |
|
36 m_id( threadId ), |
|
37 m_currentVGContext( NULL ), |
|
38 m_currentVGSurface( NULL ), |
|
39 m_currentGLESContext( NULL ), |
|
40 m_currentGLESReadSurface( NULL ), |
|
41 m_currentGLESDrawSurface( NULL ), |
|
42 m_currentApi( EGL_OPENGL_ES_API ), |
|
43 m_lastError( EGL_SUCCESS ), |
|
44 m_supportedApis( supportedApis ) |
|
45 { |
|
46 } |
|
47 |
|
48 CEGLThread::~CEGLThread(void) |
|
49 { |
|
50 } |
|
51 |
|
52 bool CEGLThread::IsSupportedApi( EGLenum api ) const |
|
53 { |
|
54 bool ret = false; |
|
55 switch( api ) |
|
56 { |
|
57 case EGL_OPENVG_API: |
|
58 { |
|
59 if( m_supportedApis & EGL_OPENVG_BIT ) |
|
60 ret = true; |
|
61 break; |
|
62 } |
|
63 case EGL_OPENGL_ES_API: |
|
64 { |
|
65 if( m_supportedApis & EGL_OPENGL_ES_BIT || |
|
66 m_supportedApis & EGL_OPENGL_ES2_BIT ) |
|
67 ret = true; |
|
68 break; |
|
69 } |
|
70 } |
|
71 return ret; |
|
72 } |
|
73 |
|
74 CEGLContext* CEGLThread::SwitchVGContext( CEGLContext* vgContext ) |
|
75 { |
|
76 CEGLContext* ret = m_currentVGContext; |
|
77 if( vgContext != m_currentVGContext ) |
|
78 { |
|
79 m_currentVGContext = vgContext; |
|
80 if( vgContext ) vgContext->SetThread( this ); |
|
81 if( ret ) ret->SetThread( NULL ); |
|
82 } |
|
83 return ret; |
|
84 } |
|
85 |
|
86 CEGLSurface* CEGLThread::SwitchVGSurface( CEGLSurface* vgSurface ) |
|
87 { |
|
88 CEGLSurface* ret = m_currentVGSurface; |
|
89 if( vgSurface != m_currentVGSurface ) |
|
90 { |
|
91 m_currentVGSurface = vgSurface; |
|
92 if( vgSurface ) vgSurface->SetThread( this ); |
|
93 if( ret ) ret->SetThread( NULL ); |
|
94 } |
|
95 return ret; |
|
96 } |
|
97 |
|
98 CEGLContext* CEGLThread::SwitchGLESContext( CEGLContext* glesContext ) |
|
99 { |
|
100 CEGLContext* ret = m_currentGLESContext; |
|
101 if( glesContext != m_currentGLESContext ) |
|
102 { |
|
103 m_currentGLESContext = glesContext; |
|
104 if( glesContext ) glesContext->SetThread( this ); |
|
105 if( ret ) ret->SetThread( NULL ); |
|
106 } |
|
107 return ret; |
|
108 } |
|
109 |
|
110 void CEGLThread::SwitchGLESSurfaces( CEGLSurface* read, CEGLSurface* draw, CEGLSurface*& previousRead, CEGLSurface*& previousDraw ) |
|
111 { |
|
112 previousRead = m_currentGLESReadSurface; |
|
113 previousDraw = m_currentGLESDrawSurface; |
|
114 m_currentGLESReadSurface = read; |
|
115 if( read ) read->SetThread( this ); |
|
116 if( previousRead && previousRead != read ) previousRead->SetThread( NULL ); |
|
117 m_currentGLESDrawSurface = draw; |
|
118 if( draw ) draw->SetThread( this ); |
|
119 if( previousDraw && previousDraw != draw ) previousDraw->SetThread( NULL ); |
|
120 } |
|
121 |
|
122 void CEGLThread::CurrentGLESSurfaces( CEGLSurface** read, CEGLSurface** draw ) const |
|
123 { |
|
124 if( read ) *read = m_currentGLESReadSurface; |
|
125 if( draw ) *draw = m_currentGLESDrawSurface; |
|
126 } |