1 
2 /*
3  * Copyright 2011 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 
10 
11 #ifndef GrGLConfig_DEFINED
12 #define GrGLConfig_DEFINED
13 
14 #include "GrTypes.h"
15 
16 /**
17  * Optional GL config file.
18  */
19 #ifdef GR_GL_CUSTOM_SETUP_HEADER
20     #include GR_GL_CUSTOM_SETUP_HEADER
21 #endif
22 
23 #if !defined(GR_GL_FUNCTION_TYPE)
24     #if defined(SK_BUILD_FOR_WIN32)
25         #define GR_GL_FUNCTION_TYPE __stdcall
26     #else
27         #define GR_GL_FUNCTION_TYPE
28     #endif
29 #endif
30 
31 /**
32  * The following are optional defines that can be enabled at the compiler
33  * command line, in a IDE project, in a GrUserConfig.h file, or in a GL custom
34  * file (if one is in use). If a GR_GL_CUSTOM_SETUP_HEADER is used they can
35  * also be placed there.
36  *
37  * GR_GL_LOG_CALLS: if 1 Gr can print every GL call using SkDebugf. Defaults to
38  * 0. Logging can be enabled and disabled at runtime using a debugger via to
39  * global gLogCallsGL. The initial value of gLogCallsGL is controlled by
40  * GR_GL_LOG_CALLS_START.
41  *
42  * GR_GL_LOG_CALLS_START: controls the initial value of gLogCallsGL when
43  * GR_GL_LOG_CALLS is 1. Defaults to 0.
44  *
45  * GR_GL_CHECK_ERROR: if enabled Gr can do a glGetError() after every GL call.
46  * Defaults to 1 if SK_DEBUG is set, otherwise 0. When GR_GL_CHECK_ERROR is 1
47  * this can be toggled in a debugger using the gCheckErrorGL global. The initial
48  * value of gCheckErrorGL is controlled by by GR_GL_CHECK_ERROR_START.
49  *
50  * GR_GL_CHECK_ERROR_START: controls the initial value of gCheckErrorGL
51  * when GR_GL_CHECK_ERROR is 1.  Defaults to 1.
52  *
53  * GR_GL_USE_BUFFER_DATA_NULL_HINT: When specifing new data for a vertex/index
54  * buffer that replaces old data Ganesh can give a hint to the driver that the
55  * previous data will not be used in future draws like this:
56  *  glBufferData(GL_..._BUFFER, size, NULL, usage);       //<--hint, NULL means
57  *  glBufferSubData(GL_..._BUFFER, 0, lessThanSize, data) //   old data can't be
58  *                                                        //   used again.
59  * However, this can be an unoptimization on some platforms, esp. Chrome.
60  * Chrome's cmd buffer will create a new allocation and memset the whole thing
61  * to zero (for security reasons). Defaults to 1 (enabled).
62  *
63  * GR_GL_CHECK_ALLOC_WITH_GET_ERROR: If set to 1 this will then glTexImage,
64  * glBufferData, glRenderbufferStorage, etc will be checked for errors. This
65  * amounts to ensuring the error is GL_NO_ERROR, calling the allocating
66  * function, and then checking that the error is still GL_NO_ERROR. When the
67  * value is 0 we will assume no error was generated without checking.
68  *
69  * GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT: We will normally check the FBO status
70  * every time we bind a texture or renderbuffer to an FBO. However, in some
71  * environments CheckFrameBufferStatus is very expensive. If this is set we will
72  * check the first time we use a color format or a combination of color /
73  * stencil formats as attachments. If the FBO is complete we will assume
74  * subsequent attachments with the same formats are complete as well.
75  *
76  * GR_GL_MUST_USE_VBO: Indicates that all vertices and indices must be rendered
77  * from VBOs. Chromium's command buffer doesn't allow glVertexAttribArray with
78  * ARARY_BUFFER 0 bound or glDrawElements with ELEMENT_ARRAY_BUFFER 0 bound.
79  *
80  * GR_GL_USE_NEW_SHADER_SOURCE_SIGNATURE is for compatibility with the new version
81  * of the OpenGLES2.0 headers from Khronos.  glShaderSource now takes a const char * const *,
82  * instead of a const char
83  */
84 
85 #if !defined(GR_GL_LOG_CALLS)
86     #ifdef SK_DEBUG
87         #define GR_GL_LOG_CALLS 1
88     #else
89         #define GR_GL_LOG_CALLS 0
90     #endif
91 #endif
92 
93 #if !defined(GR_GL_LOG_CALLS_START)
94     #define GR_GL_LOG_CALLS_START                       0
95 #endif
96 
97 #if !defined(GR_GL_CHECK_ERROR)
98     #ifdef SK_DEBUG
99         #define GR_GL_CHECK_ERROR 1
100     #else
101         #define GR_GL_CHECK_ERROR 0
102     #endif
103 #endif
104 
105 #if !defined(GR_GL_CHECK_ERROR_START)
106     #define GR_GL_CHECK_ERROR_START                     1
107 #endif
108 
109 #if !defined(GR_GL_USE_BUFFER_DATA_NULL_HINT)
110     #define GR_GL_USE_BUFFER_DATA_NULL_HINT             1
111 #endif
112 
113 #if !defined(GR_GL_CHECK_ALLOC_WITH_GET_ERROR)
114     #define GR_GL_CHECK_ALLOC_WITH_GET_ERROR            1
115 #endif
116 
117 #if !defined(GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT)
118     #define GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT      0
119 #endif
120 
121 #if !defined(GR_GL_MUST_USE_VBO)
122     #define GR_GL_MUST_USE_VBO                          0
123 #endif
124 
125 #if !defined(GR_GL_USE_NEW_SHADER_SOURCE_SIGNATURE)
126     #define GR_GL_USE_NEW_SHADER_SOURCE_SIGNATURE       0
127 #endif
128 
129 #endif
130