Home | History | Annotate | Download | only in GLcommon
      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 TRANSLATOR_IFACES_H
     17 #define TRANSLATOR_IFACES_H
     18 #include <GLES/gl.h>
     19 #include <string.h>
     20 #include "objectNameManager.h"
     21 
     22 extern "C" {
     23 
     24 /* This is a generic function pointer type, whose name indicates it must
     25  * be cast to the proper type *and calling convention* before use.
     26  */
     27 typedef void (*__translatorMustCastToProperFunctionPointerType)(void);
     28 
     29 typedef struct {
     30   const char*                                     name;
     31   __translatorMustCastToProperFunctionPointerType address;
     32 }ExtentionDescriptor;
     33 
     34 class TextureData : public ObjectData
     35 {
     36 public:
     37     ~TextureData() {
     38         if (sourceEGLImage && eglImageDetach) (*eglImageDetach)(sourceEGLImage);
     39     }
     40     TextureData():  ObjectData(TEXTURE_DATA),
     41                     width(0),
     42                     height(0),
     43                     border(0),
     44                     internalFormat(GL_RGBA),
     45                     sourceEGLImage(0),
     46                     wasBound(false),
     47                     requiresAutoMipmap(false),
     48                     target(0),
     49                     oldGlobal(0) {
     50         memset(crop_rect,0,4*sizeof(int));
     51     };
     52 
     53     unsigned int width;
     54     unsigned int height;
     55     unsigned int border;
     56     unsigned int internalFormat;
     57     unsigned int sourceEGLImage;
     58     bool wasBound;
     59     bool requiresAutoMipmap;
     60     int          crop_rect[4];
     61     void (*eglImageDetach)(unsigned int imageId);
     62     GLenum target;
     63     GLuint oldGlobal;
     64 };
     65 
     66 struct EglImage
     67 {
     68     ~EglImage(){};
     69     unsigned int imageId;
     70     unsigned int globalTexName;
     71     unsigned int width;
     72     unsigned int height;
     73     unsigned int internalFormat;
     74     unsigned int border;
     75 };
     76 
     77 typedef SmartPtr<EglImage> ImagePtr;
     78 typedef  std::map< unsigned int, ImagePtr>       ImagesHndlMap;
     79 
     80 class GLEScontext;
     81 
     82 typedef struct {
     83     GLEScontext*                                    (*createGLESContext)();
     84     void                                            (*initContext)(GLEScontext*,ShareGroupPtr);
     85     void                                            (*deleteGLESContext)(GLEScontext*);
     86     void                                            (*flush)();
     87     void                                            (*finish)();
     88     void                                            (*setShareGroup)(GLEScontext*,ShareGroupPtr);
     89     __translatorMustCastToProperFunctionPointerType (*getProcAddress)(const char*);
     90 }GLESiface;
     91 
     92 
     93 typedef struct {
     94     GLEScontext* (*getGLESContext)();
     95     EglImage* (*eglAttachEGLImage)(unsigned int imageId);
     96     void        (*eglDetachEGLImage)(unsigned int imageId);
     97 }EGLiface;
     98 
     99 typedef GLESiface* (*__translator_getGLESIfaceFunc)(EGLiface*);
    100 
    101 }
    102 #endif
    103