24
|
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 "EGLPbufferSurface.h"
|
|
32 |
#include "EGLOs.h"
|
|
33 |
|
|
34 |
CEGLPbufferSurface::CEGLPbufferSurface(void) :
|
|
35 |
CEGLSurface( CEGLSurface::PBUFFER_SURFACE,
|
|
36 |
0,
|
|
37 |
0,
|
|
38 |
0,
|
|
39 |
NULL ),
|
|
40 |
m_clientBuffer( NULL ),
|
|
41 |
m_container( NULL )
|
|
42 |
{
|
|
43 |
}
|
|
44 |
|
|
45 |
CEGLPbufferSurface::CEGLPbufferSurface( EGLint colorSpace, EGLint alphaFormat, EGLint renderBuffer, CEGLConfig* config, EGLint largestPbuffer, EGLint textureFormat, EGLint textureTarget, EGLint mipmapTexture, EGLClientBuffer clientBuf ) :
|
|
46 |
CEGLSurface( CEGLSurface::PBUFFER_SURFACE,
|
|
47 |
colorSpace,
|
|
48 |
alphaFormat,
|
|
49 |
renderBuffer,
|
|
50 |
config ),
|
|
51 |
m_largestPbuffer( largestPbuffer ),
|
|
52 |
m_textureFormat( textureFormat ),
|
|
53 |
m_textureTarget( textureTarget ),
|
|
54 |
m_mipmapTexture( mipmapTexture ),
|
|
55 |
m_clientBuffer( clientBuf ),
|
|
56 |
m_container( NULL )
|
|
57 |
{
|
|
58 |
|
|
59 |
}
|
|
60 |
|
|
61 |
CEGLPbufferSurface::~CEGLPbufferSurface(void)
|
|
62 |
{
|
|
63 |
if( m_container )
|
|
64 |
{
|
|
65 |
// \todo errors
|
|
66 |
CEGLOs::DestroyNativePbuffer( m_container );
|
|
67 |
delete m_container;
|
|
68 |
m_container = NULL;
|
|
69 |
}
|
|
70 |
}
|
|
71 |
|
|
72 |
void CEGLPbufferSurface::SetNativePbufferContainer( EGLINativePbufferContainer* container )
|
|
73 |
{
|
|
74 |
if( m_container )
|
|
75 |
{
|
|
76 |
// \todo errors
|
|
77 |
CEGLOs::DestroyNativePbuffer( m_container );
|
|
78 |
delete m_container;
|
|
79 |
m_container = NULL;
|
|
80 |
}
|
|
81 |
m_container = container;
|
|
82 |
}
|
|
83 |
|
|
84 |
bool CEGLPbufferSurface::BindCopyContext()
|
|
85 |
{
|
|
86 |
m_tmpContext = CEGLOs::CurrentNativeContext();
|
|
87 |
// \todo read/draw?
|
|
88 |
m_tmpDisplay = CEGLOs::CurrentNativeSurface();
|
|
89 |
|
|
90 |
if( !m_container )
|
|
91 |
{
|
|
92 |
return false;
|
|
93 |
}
|
|
94 |
|
|
95 |
return CEGLOs::MakeNativeContextCurrent( NativeGLFunctions(), NativeDisplay(), NativeDisplay(), CopyContext() );
|
|
96 |
}
|
|
97 |
|
|
98 |
bool CEGLPbufferSurface::ReleaseCopyContext()
|
|
99 |
{
|
|
100 |
// \todo read/draw?
|
|
101 |
return CEGLOs::MakeNativeContextCurrent( NativeGLFunctions(), m_tmpDisplay, m_tmpDisplay, m_tmpContext );
|
|
102 |
}
|