Initial commit
[profile/ivi/simulator-opengl.git] / egl_1_4 / 36SurfaceAttrib.c
1 /* 
2  * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
3  * 
4  * Contact:
5  * DongKyun Yun <dk77.yun@samsung.com>
6  * SangJin Kim <sangjin3.kim@samsung.com>
7  * HyunGoo Kang <hyungoo1.kang@samsung.com>
8  *
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:
15  * 
16  * The above copyright notice and this permission notice shall be included in all
17  * copies or substantial portions of the Software.
18  * 
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
25  * SOFTWARE.
26  * 
27  * Contributors:
28  * - S-Core Co., Ltd
29  *
30  */
31
32 #include "implement.h"
33
34
35 EGLBoolean EGLAPIENTRY eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface,
36         EGLint attribute, EGLint value) {
37         struct DisplayExtra* pDisplay = EGLINTER(LookUpDisplay)(dpy);
38         if (pDisplay == NULL) {
39                 EGLINTER(SetError)(EGL_BAD_DISPLAY);
40                 return EGL_FALSE;
41         }
42         if (pDisplay->bInitialized == EGL_FALSE) {
43                 EGLINTER(SetError)(EGL_NOT_INITIALIZED);
44                 return EGL_FALSE;
45         }
46         struct SurfaceExtra* pSurface = EGLINTER(LookUpSurface)(surface);
47         if (pSurface == NULL) {
48                 EGLINTER(SetError)(EGL_BAD_SURFACE);
49                 return EGL_FALSE;
50         }
51         if (pSurface->display != pDisplay->unique) {
52                 EGLINTER(SetError)(EGL_BAD_SURFACE);
53                 return EGL_FALSE;
54         }
55         switch (attribute) {
56         case EGL_MIPMAP_LEVEL:
57                 pSurface->mipmapLevel = value;
58                 break;
59         case EGL_SWAP_BEHAVIOR:
60                 if (value == EGL_BUFFER_PRESERVED || value == EGL_BUFFER_DESTROYED) {
61                         pSurface->swapBehavior = value;
62                 } else {
63                         EGLINTER(SetError)(EGL_BAD_PARAMETER);
64                         return EGL_FALSE;
65                 }
66                 break;
67         case EGL_MULTISAMPLE_RESOLVE:
68                 if (value == EGL_MULTISAMPLE_RESOLVE_DEFAULT || value == EGL_MULTISAMPLE_RESOLVE_BOX) {
69                         pSurface->multisampleResolve = value;
70                 } else {
71                         EGLINTER(SetError)(EGL_BAD_PARAMETER);
72                         return EGL_FALSE;
73                 }
74                 break;
75         default:
76                 EGLINTER(SetError)(EGL_BAD_ATTRIBUTE);
77                 return EGL_FALSE;
78                 break;
79         }
80         return EGL_TRUE;
81 }