• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 #include "EglValidate.h"
17 #include <GLcommon/GLutils.h>
18 
19 #ifndef EGL_PRESERVED_RESOURCES
20 #define EGL_PRESERVED_RESOURCES 0x3030
21 #endif
22 
23 // static
confAttrib(EGLint attrib)24 bool EglValidate::confAttrib(EGLint attrib) {
25     switch(attrib) {
26     case EGL_BUFFER_SIZE:
27     case EGL_RED_SIZE:
28     case EGL_GREEN_SIZE:
29     case EGL_BLUE_SIZE:
30     case EGL_ALPHA_SIZE:
31     case EGL_ALPHA_MASK_SIZE:
32     case EGL_BIND_TO_TEXTURE_RGB:
33     case EGL_BIND_TO_TEXTURE_RGBA:
34     case EGL_CONFIG_CAVEAT:
35     case EGL_CONFIG_ID:
36     case EGL_DEPTH_SIZE:
37     case EGL_LEVEL:
38     case EGL_LUMINANCE_SIZE:
39     case EGL_MAX_PBUFFER_WIDTH:
40     case EGL_MAX_PBUFFER_HEIGHT:
41     case EGL_MAX_PBUFFER_PIXELS:
42     case EGL_MAX_SWAP_INTERVAL:
43     case EGL_MIN_SWAP_INTERVAL:
44     case EGL_PRESERVED_RESOURCES:
45     case EGL_RENDERABLE_TYPE:
46     case EGL_NATIVE_RENDERABLE:
47     case EGL_NATIVE_VISUAL_ID:
48     case EGL_NATIVE_VISUAL_TYPE:
49     case EGL_SAMPLE_BUFFERS:
50     case EGL_SAMPLES:
51     case EGL_STENCIL_SIZE:
52     case EGL_SURFACE_TYPE:
53     case EGL_COLOR_BUFFER_TYPE:
54     case EGL_TRANSPARENT_TYPE:
55     case EGL_TRANSPARENT_RED_VALUE:
56     case EGL_TRANSPARENT_GREEN_VALUE:
57     case EGL_TRANSPARENT_BLUE_VALUE:
58     case EGL_RECORDABLE_ANDROID:
59     case EGL_CONFORMANT:
60         return true;
61     }
62     return false;
63 }
64 
65 // static
noAttribs(const EGLint * attrib)66 bool EglValidate::noAttribs(const EGLint* attrib) {
67     return !attrib || attrib[0] == EGL_NONE ;
68 }
69 
70 // static
pbufferAttribs(EGLint width,EGLint height,bool isTexFormatNoTex,bool isTexTargetNoTex)71 bool EglValidate::pbufferAttribs(EGLint width,
72                                  EGLint height,
73                                  bool isTexFormatNoTex,
74                                  bool isTexTargetNoTex) {
75     if(!isTexFormatNoTex) {
76         if (!(isPowerOf2(width) && isPowerOf2(height))) {
77             return false;
78         }
79     }
80     return isTexFormatNoTex == isTexTargetNoTex ;
81 }
82 
83 // static
releaseContext(EGLContext ctx,EGLSurface s1,EGLSurface s2)84 bool EglValidate::releaseContext(EGLContext ctx,
85                                  EGLSurface s1,
86                                  EGLSurface s2) {
87     return (ctx == EGL_NO_CONTEXT) &&
88            (s1 == EGL_NO_SURFACE)  &&
89            (s2 == EGL_NO_SURFACE);
90 }
91 
92 // static
badContextMatch(EGLContext ctx,EGLSurface s1,EGLSurface s2)93 bool EglValidate::badContextMatch(EGLContext ctx,
94                                   EGLSurface s1,
95                                   EGLSurface s2) {
96     return (ctx != EGL_NO_CONTEXT)
97             ? (s1 == EGL_NO_SURFACE || s2 == EGL_NO_SURFACE)
98             : (s1 != EGL_NO_SURFACE || s2 != EGL_NO_SURFACE);
99 }
100 
101 // static
surfaceTarget(EGLint target)102 bool EglValidate::surfaceTarget(EGLint target) {
103     return target == EGL_READ || target == EGL_DRAW;
104 }
105 
106 // static
engine(EGLint engine)107 bool EglValidate::engine(EGLint engine) {
108     return engine == EGL_CORE_NATIVE_ENGINE;
109 }
110 
111 // static
stringName(EGLint name)112 bool EglValidate::stringName(EGLint name) {
113     return name == EGL_VENDOR  ||
114            name == EGL_VERSION ||
115            name == EGL_EXTENSIONS;
116 }
117 
118 // static
supportedApi(EGLenum api)119 bool EglValidate::supportedApi(EGLenum api) {
120     return api == EGL_OPENGL_ES_API;
121 }
122