Home | History | Annotate | Download | only in gl
      1 
      2 /*
      3  * Copyright 2015 Google Inc.
      4  *
      5  * Use of this source code is governed by a BSD-style license that can be
      6  * found in the LICENSE file.
      7  */
      8 
      9 #ifndef GrGLTypes_DEFINED
     10 #define GrGLTypes_DEFINED
     11 
     12 #include "GrExternalTextureData.h"
     13 #include "GrGLConfig.h"
     14 #include "SkRefCnt.h"
     15 
     16 /**
     17  * Classifies GL contexts by which standard they implement (currently as OpenGL vs. OpenGL ES).
     18  */
     19 enum GrGLStandard {
     20     kNone_GrGLStandard,
     21     kGL_GrGLStandard,
     22     kGLES_GrGLStandard,
     23 };
     24 static const int kGrGLStandardCnt = 3;
     25 
     26 ///////////////////////////////////////////////////////////////////////////////
     27 
     28 /**
     29  * Declares typedefs for all the GL functions used in GrGLInterface
     30  */
     31 
     32 typedef unsigned int GrGLenum;
     33 typedef unsigned char GrGLboolean;
     34 typedef unsigned int GrGLbitfield;
     35 typedef signed char GrGLbyte;
     36 typedef char GrGLchar;
     37 typedef short GrGLshort;
     38 typedef int GrGLint;
     39 typedef int GrGLsizei;
     40 typedef int64_t GrGLint64;
     41 typedef unsigned char GrGLubyte;
     42 typedef unsigned short GrGLushort;
     43 typedef unsigned int GrGLuint;
     44 typedef uint64_t GrGLuint64;
     45 typedef float GrGLfloat;
     46 typedef float GrGLclampf;
     47 typedef double GrGLdouble;
     48 typedef double GrGLclampd;
     49 typedef void GrGLvoid;
     50 #ifndef SK_IGNORE_64BIT_OPENGL_CHANGES
     51 #ifdef _WIN64
     52 typedef signed long long int GrGLintptr;
     53 typedef signed long long int GrGLsizeiptr;
     54 #else
     55 typedef signed long int GrGLintptr;
     56 typedef signed long int GrGLsizeiptr;
     57 #endif
     58 #else
     59 typedef signed long int GrGLintptr;
     60 typedef signed long int GrGLsizeiptr;
     61 #endif
     62 typedef void* GrGLeglImage;
     63 typedef void* GrGLsync;
     64 
     65 struct GrGLDrawArraysIndirectCommand {
     66     GrGLuint fCount;
     67     GrGLuint fInstanceCount;
     68     GrGLuint fFirst;
     69     GrGLuint fBaseInstance;  // Requires EXT_base_instance on ES.
     70 };
     71 
     72 GR_STATIC_ASSERT(16 == sizeof(GrGLDrawArraysIndirectCommand));
     73 
     74 struct GrGLDrawElementsIndirectCommand {
     75     GrGLuint fCount;
     76     GrGLuint fInstanceCount;
     77     GrGLuint fFirstIndex;
     78     GrGLuint fBaseVertex;
     79     GrGLuint fBaseInstance;  // Requires EXT_base_instance on ES.
     80 };
     81 
     82 GR_STATIC_ASSERT(20 == sizeof(GrGLDrawElementsIndirectCommand));
     83 
     84 /**
     85  * KHR_debug
     86  */
     87 typedef void (GR_GL_FUNCTION_TYPE* GRGLDEBUGPROC)(GrGLenum source,
     88                                                   GrGLenum type,
     89                                                   GrGLuint id,
     90                                                   GrGLenum severity,
     91                                                   GrGLsizei length,
     92                                                   const GrGLchar* message,
     93                                                   const void* userParam);
     94 
     95 /**
     96  * EGL types.
     97  */
     98 typedef void* GrEGLImage;
     99 typedef void* GrEGLDisplay;
    100 typedef void* GrEGLContext;
    101 typedef void* GrEGLClientBuffer;
    102 typedef unsigned int GrEGLenum;
    103 typedef int32_t GrEGLint;
    104 typedef unsigned int GrEGLBoolean;
    105 
    106 ///////////////////////////////////////////////////////////////////////////////
    107 /**
    108  * Types for interacting with GL resources created externally to Skia. GrBackendObjects for GL
    109  * textures are really const GrGLTexture*
    110  */
    111 
    112 struct GrGLTextureInfo {
    113     GrGLenum fTarget;
    114     GrGLuint fID;
    115 };
    116 
    117 class GrSemaphore;
    118 
    119 class GrGLExternalTextureData : public GrExternalTextureData {
    120 public:
    121     GrGLExternalTextureData(const GrGLTextureInfo& info, sk_sp<GrSemaphore> semaphore, GrContext*);
    122     GrBackend getBackend() const override { return kOpenGL_GrBackend; }
    123 
    124 protected:
    125     GrBackendObject getBackendObject() const override {
    126         return reinterpret_cast<GrBackendObject>(&fInfo);
    127     }
    128     void attachToContext(GrContext*) override;
    129 
    130     GrGLTextureInfo fInfo;
    131     sk_sp<GrSemaphore> fSemaphore;
    132 
    133     typedef GrExternalTextureData INHERITED;
    134 };
    135 
    136 GR_STATIC_ASSERT(sizeof(GrBackendObject) >= sizeof(const GrGLTextureInfo*));
    137 
    138 #endif
    139