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 "EGLImage.h"
|
|
32 |
#include "EGLUtils.h"
|
|
33 |
#include "EGLState.h"
|
|
34 |
#include <EGL/eglext.h>
|
|
35 |
#include <VG/openvg.h>
|
|
36 |
|
|
37 |
#include <stdlib.h>
|
|
38 |
|
|
39 |
CEGLImage::CEGLImage( EGLenum target, EGLClientBuffer buffer,
|
|
40 |
SurfaceDescriptor desc, void* data) :
|
|
41 |
m_buffer( buffer ),
|
|
42 |
m_target( target ),
|
|
43 |
m_data(data)
|
|
44 |
{
|
|
45 |
m_siblings = EGLI_NEW EGLImageSibling;
|
|
46 |
m_siblings->buffer = buffer;
|
|
47 |
m_siblings->target = target;
|
|
48 |
m_siblings->next = NULL;
|
|
49 |
m_SurfDesc.m_alphaShift = desc.m_alphaShift;
|
|
50 |
m_SurfDesc.m_blueShift = desc.m_blueShift;
|
|
51 |
m_SurfDesc.m_depthSize = desc.m_depthSize;
|
|
52 |
m_SurfDesc.m_greenShift = desc.m_greenShift;
|
|
53 |
m_SurfDesc.m_height = desc.m_height;
|
|
54 |
m_SurfDesc.m_luminanceShift = desc.m_luminanceShift;
|
|
55 |
m_SurfDesc.m_maskSize = desc.m_maskSize;
|
|
56 |
m_SurfDesc.m_redShift = desc.m_redShift;
|
|
57 |
m_SurfDesc.m_stencilSize = desc.m_stencilSize;
|
|
58 |
m_SurfDesc.m_stride = desc.m_stride;
|
|
59 |
m_SurfDesc.m_width = desc.m_width;
|
|
60 |
|
|
61 |
m_SurfDesc.m_colorDescriptor.m_alphaMaskSize = desc.m_colorDescriptor.m_alphaMaskSize;
|
|
62 |
m_SurfDesc.m_colorDescriptor.m_alphaSize = desc.m_colorDescriptor.m_alphaSize;
|
|
63 |
m_SurfDesc.m_colorDescriptor.m_blueSize = desc.m_colorDescriptor.m_blueSize;
|
|
64 |
m_SurfDesc.m_colorDescriptor.m_bpp = desc.m_colorDescriptor.m_bpp;
|
|
65 |
m_SurfDesc.m_colorDescriptor.m_format = desc.m_colorDescriptor.m_format;
|
|
66 |
m_SurfDesc.m_colorDescriptor.m_greenSize = desc.m_colorDescriptor.m_greenSize;
|
|
67 |
m_SurfDesc.m_colorDescriptor.m_luminanceSize = desc.m_colorDescriptor.m_luminanceSize;
|
|
68 |
m_SurfDesc.m_colorDescriptor.m_redSize = desc.m_colorDescriptor.m_redSize;
|
|
69 |
}
|
|
70 |
|
|
71 |
CEGLImage::~CEGLImage(void)
|
|
72 |
{
|
|
73 |
// tero 2010-08-02, changed to free, since delete is _certainly_ incorrect.
|
|
74 |
if( m_data )
|
|
75 |
free(m_data);
|
|
76 |
m_data = NULL;
|
|
77 |
DestroyAllSiblings();
|
|
78 |
}
|
|
79 |
|
|
80 |
void CEGLImage::AddSibling( EGLenum target, EGLClientBuffer buffer )
|
|
81 |
{
|
|
82 |
EGLImageSibling* newp;
|
|
83 |
EGLImageSibling* curr = m_siblings;
|
|
84 |
newp = EGLI_NEW EGLImageSibling;
|
|
85 |
newp->buffer = buffer;
|
|
86 |
newp->target = target;
|
|
87 |
newp->next = NULL;
|
|
88 |
|
|
89 |
while( curr->next )
|
|
90 |
{
|
|
91 |
curr = curr->next;
|
|
92 |
}
|
|
93 |
curr->next = newp;
|
|
94 |
}
|
|
95 |
|
|
96 |
void CEGLImage::UpdateData( CEGLState *state, void* data )
|
|
97 |
{
|
|
98 |
EGLImageSibling* curr = m_siblings;
|
|
99 |
while( curr )
|
|
100 |
{
|
|
101 |
switch ( curr->target )
|
|
102 |
{
|
|
103 |
case EGL_VG_PARENT_IMAGE_KHR:
|
|
104 |
{
|
|
105 |
// OpenVG
|
|
106 |
|
|
107 |
}
|
|
108 |
break;
|
|
109 |
case EGL_GL_TEXTURE_2D_KHR:
|
|
110 |
case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR:
|
|
111 |
case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR:
|
|
112 |
case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR:
|
|
113 |
case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR:
|
|
114 |
case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR:
|
|
115 |
case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR:
|
|
116 |
{
|
|
117 |
// GLES
|
|
118 |
IEGLtoGLES2Interface* iFace = (IEGLtoGLES2Interface*)state->GLESInterface(2);
|
|
119 |
//iFace->UpdateBuffers(
|
|
120 |
}
|
|
121 |
break;
|
|
122 |
default:
|
|
123 |
break;
|
|
124 |
}
|
|
125 |
curr = curr->next;
|
|
126 |
}
|
|
127 |
}
|
|
128 |
|
|
129 |
void CEGLImage::DestroyAllSiblings()
|
|
130 |
{
|
|
131 |
EGLImageSibling* curr = m_siblings;
|
|
132 |
EGLImageSibling* next = curr->next;
|
|
133 |
|
|
134 |
while( curr )
|
|
135 |
{
|
|
136 |
next = curr->next;
|
|
137 |
free( curr );
|
|
138 |
curr = next;
|
|
139 |
}
|
|
140 |
}
|