• 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 
confAttrib(EGLint attrib)19 bool EglValidate::confAttrib(EGLint attrib) {
20     switch(attrib) {
21     case EGL_BUFFER_SIZE:
22     case EGL_RED_SIZE:
23     case EGL_GREEN_SIZE:
24     case EGL_BLUE_SIZE:
25     case EGL_ALPHA_SIZE:
26     case EGL_BIND_TO_TEXTURE_RGB:
27     case EGL_BIND_TO_TEXTURE_RGBA:
28     case EGL_CONFIG_CAVEAT:
29     case EGL_CONFIG_ID:
30     case EGL_DEPTH_SIZE:
31     case EGL_LEVEL:
32     case EGL_MAX_PBUFFER_WIDTH:
33     case EGL_MAX_PBUFFER_HEIGHT:
34     case EGL_MAX_PBUFFER_PIXELS:
35     case EGL_MAX_SWAP_INTERVAL:
36     case EGL_MIN_SWAP_INTERVAL:
37     case EGL_RENDERABLE_TYPE:
38     case EGL_NATIVE_RENDERABLE:
39     case EGL_NATIVE_VISUAL_ID:
40     case EGL_NATIVE_VISUAL_TYPE:
41     case EGL_SAMPLE_BUFFERS:
42     case EGL_SAMPLES:
43     case EGL_STENCIL_SIZE:
44     case EGL_SURFACE_TYPE:
45     case EGL_TRANSPARENT_TYPE:
46     case EGL_TRANSPARENT_RED_VALUE:
47     case EGL_TRANSPARENT_GREEN_VALUE:
48     case EGL_TRANSPARENT_BLUE_VALUE:
49     case EGL_CONFORMANT:
50         return true;
51     }
52     return false;
53 }
54 
noAttribs(const EGLint * attrib)55 bool EglValidate::noAttribs(const EGLint* attrib) {
56     return !attrib || attrib[0] == EGL_NONE ;
57 }
58 
pbufferAttribs(EGLint width,EGLint height,bool isTexFormatNoTex,bool isTexTargetNoTex)59 bool EglValidate::pbufferAttribs(EGLint width,EGLint height,bool isTexFormatNoTex,bool isTexTargetNoTex) {
60     if(!isTexFormatNoTex) {
61       if (!(isPowerOf2(width) && isPowerOf2(height))) return false;
62     }
63     return isTexFormatNoTex == isTexTargetNoTex ;
64 }
65 
releaseContext(EGLContext ctx,EGLSurface s1,EGLSurface s2)66 bool EglValidate::releaseContext(EGLContext ctx,EGLSurface s1,EGLSurface s2) {
67     return (ctx == EGL_NO_CONTEXT) &&
68            (s1 == EGL_NO_SURFACE)  &&
69            (s2 == EGL_NO_SURFACE);
70 }
71 
badContextMatch(EGLContext ctx,EGLSurface s1,EGLSurface s2)72 bool EglValidate::badContextMatch(EGLContext ctx,EGLSurface s1,EGLSurface s2) {
73     return ctx != EGL_NO_CONTEXT ? (s1 == EGL_NO_SURFACE || s2 == EGL_NO_SURFACE):
74                                    (s1 != EGL_NO_SURFACE || s2 != EGL_NO_SURFACE);
75 }
76 
surfaceTarget(EGLint target)77 bool EglValidate::surfaceTarget(EGLint target) {
78     return target == EGL_READ || target == EGL_DRAW;
79 }
80 
engine(EGLint engine)81 bool EglValidate::engine(EGLint engine) {
82     return engine == EGL_CORE_NATIVE_ENGINE;
83 }
84 
stringName(EGLint name)85 bool EglValidate::stringName(EGLint name) {
86     return name == EGL_VENDOR  ||
87            name == EGL_VERSION ||
88            name == EGL_EXTENSIONS;
89 }
90 
supportedApi(EGLenum api)91 bool EglValidate::supportedApi(EGLenum api) {
92     return api == EGL_OPENGL_ES_API;
93 }
94