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 #ifndef EGL_VALIDATE_H 17 #define EGL_VALIDATE_H 18 19 #include <EGL/egl.h> 20 #include <EGL/eglext.h> 21 22 class EglValidate { 23 public: 24 // Return true iff |attrib| is a valid EGLConfig attribute name. 25 static bool confAttrib(EGLint attrib); 26 27 // Return true iff |attrib| is NULL, or |attrib[0]| is EGL_NONE, which 28 // correspond to empty config attribute lists. 29 static bool noAttribs(const EGLint* attrib); 30 31 // Used to check that the config attributes used to create a new pbuffer 32 // are correct. |width| and |height| are the PBuffer's dimensions in 33 // pixels. |texFormatIsNoText| is true iff the PBuffer's texture format 34 // if EGL_NO_TEXTURE. |texTargetIsNoTex| is true iff the PBuffer's target 35 // is EGL_NO_TEXTURE. 36 static bool pbufferAttribs(EGLint width, 37 EGLint height, 38 bool texFormatIsNoTex, 39 bool texTargetIsNoTex); 40 41 // Return true if |ctx| is EGL_NO_CONTEXT, and both |draw| and |read| 42 // are EGL_NO_SURFACE. This corresponds to an eglMakeCurrent operation 43 // used to release the current context and draw/read surfaces at the 44 // same time. 45 static bool releaseContext(EGLContext ctx, 46 EGLSurface draw, 47 EGLSurface read); 48 49 // Return true if the values of |ctx|, |draw| and |read| do _not_ match 50 // the following rules: 51 // 52 // - If |ctx| is EGL_NO_CONTEXT, then |draw| and |read| must be 53 // EGL_NO_SURFACE. 54 // 55 // - If |ctx| is not EGL_NO_CONTEXT, then |draw| and |read| must not 56 // be EGL_NO_SURFACE. 57 // 58 static bool badContextMatch(EGLContext ctx, 59 EGLSurface draw, 60 EGLSurface read); 61 62 // Returns true iff |target| is either EGL_DRAW or EGL_READ. 63 static bool surfaceTarget(EGLint target); 64 65 // Returns true iff |engine| is EGL_CORE_NATIVE_RENDERER 66 static bool engine(EGLint engine); 67 68 // Returns true iff |name| is the attribute name of a string, e.g. 69 // EGL_VENDOR, EGL_VERSION or EGL_EXTENSIONS. 70 static bool stringName(EGLint name); 71 72 // Returns true iff |api| is the value of a supported API, e.g. 73 // EGL_OPENGL_ES_API. 74 static bool supportedApi(EGLenum api); 75 }; 76 #endif 77