2 * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5 * DongKyun Yun <dk77.yun@samsung.com>
6 * SangJin Kim <sangjin3.kim@samsung.com>
7 * HyunGoo Kang <hyungoo1.kang@samsung.com>
9 * Permission is hereby granted, free of charge, to any person obtaining a copy of
10 * this software and associated documentation files (the "Software"), to deal in
11 * the Software without restriction, including without limitation the rights to
12 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
13 * of the Software, and to permit persons to whom the Software is furnished to do
14 * so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included in all
17 * copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 #include "implement.h"
35 EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer(EGLDisplay dpy,
36 EGLenum buftype, EGLClientBuffer buffer,
37 EGLConfig config, const EGLint *attrib_list) {
38 struct DisplayExtra* pDisplay = EGLINTER(LookUpDisplay)(dpy);
39 if (pDisplay == NULL) {
40 EGLINTER(SetError)(EGL_BAD_DISPLAY);
41 return EGL_NO_SURFACE;
43 if (pDisplay->bInitialized == EGL_FALSE) {
44 EGLINTER(SetError)(EGL_NOT_INITIALIZED);
45 return EGL_NO_SURFACE;
47 struct ConfigExtra* pConfig = EGLINTER(LookUpConfig)(pDisplay, config);
48 if (pConfig == NULL) {
49 EGLINTER(SetError)(EGL_BAD_CONFIG);
50 return EGL_NO_SURFACE;
52 if (pConfig->surfaceType & EGL_PBUFFER_BIT == 0) {
53 EGLINTER(SetError)(EGL_BAD_MATCH);
54 return EGL_NO_SURFACE;
56 if (buftype != EGL_OPENVG_IMAGE) {
57 EGLINTER(SetError)(EGL_BAD_PARAMETER);
58 return EGL_NO_SURFACE;
60 struct SurfaceExtra surfaceValue;
61 memcpy(&surfaceValue, &surfaceExtraDefault, sizeof(struct SurfaceExtra));
62 surfaceValue.renderBuffer = EGL_BACK_BUFFER;
65 while (attrib_list && *attrib_list != EGL_NONE) {
66 switch (*attrib_list++) {
69 *ptr++ = *attrib_list++;
73 *ptr++ = *attrib_list++;
75 case EGL_TEXTURE_FORMAT:
76 if (*attrib_list == EGL_NO_TEXTURE || *attrib_list == EGL_TEXTURE_RGB
77 || *attrib_list == EGL_TEXTURE_RGBA) {
78 surfaceValue.textureFormat = *attrib_list++;
80 EGLINTER(SetError)(EGL_BAD_PARAMETER);
81 return EGL_NO_SURFACE;
84 case EGL_TEXTURE_TARGET:
85 if (*attrib_list == EGL_NO_TEXTURE || *attrib_list == EGL_TEXTURE_2D) {
86 surfaceValue.textureFormat = *attrib_list++;
88 EGLINTER(SetError)(EGL_BAD_PARAMETER);
89 return EGL_NO_SURFACE;
92 case EGL_MIPMAP_TEXTURE:
93 surfaceValue.mipmapTexture = (*attrib_list++ == EGL_FALSE) ? EGL_FALSE : EGL_TRUE;
95 case EGL_VG_ALPHA_FORMAT:
96 if (*attrib_list == EGL_VG_ALPHA_FORMAT_NONPRE
97 || *attrib_list == EGL_VG_ALPHA_FORMAT_PRE) {
98 surfaceValue.vgAlphaFormat = *attrib_list++;
100 EGLINTER(SetError)(EGL_BAD_PARAMETER);
101 return EGL_NO_SURFACE;
104 case EGL_VG_COLORSPACE:
105 if (*attrib_list == EGL_VG_COLORSPACE_sRGB
106 || *attrib_list == EGL_VG_COLORSPACE_LINEAR) {
107 surfaceValue.vgColorSpace = *attrib_list++;
109 EGLINTER(SetError)(EGL_BAD_PARAMETER);
110 return EGL_NO_SURFACE;
114 EGLINTER(SetError)(EGL_BAD_ATTRIBUTE);
115 return EGL_NO_SURFACE;
120 EGLINTER(SetError)(EGL_BAD_SURFACE);
121 return EGL_NO_SURFACE;