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_WIN)
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_CHECK_ALLOC_WITH_GET_ERROR: If set to 1 this will then glTexImage,
54  * glBufferData, glRenderbufferStorage, etc will be checked for errors. This
55  * amounts to ensuring the error is GL_NO_ERROR, calling the allocating
56  * function, and then checking that the error is still GL_NO_ERROR. When the
57  * value is 0 we will assume no error was generated without checking.
58  *
59  * GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT: We will normally check the FBO status
60  * every time we bind a texture or renderbuffer to an FBO. However, in some
61  * environments CheckFrameBufferStatus is very expensive. If this is set we will
62  * check the first time we use a color format or a combination of color /
63  * stencil formats as attachments. If the FBO is complete we will assume
64  * subsequent attachments with the same formats are complete as well.
65  *
66  * GR_GL_MUST_USE_VBO: Indicates that all vertices and indices must be rendered
67  * from VBOs. Chromium's command buffer doesn't allow glVertexAttribArray with
68  * ARARY_BUFFER 0 bound or glDrawElements with ELEMENT_ARRAY_BUFFER 0 bound.
69  */
70 
71 #if !defined(GR_GL_LOG_CALLS)
72     #ifdef SK_DEBUG
73         #define GR_GL_LOG_CALLS 1
74     #else
75         #define GR_GL_LOG_CALLS 0
76     #endif
77 #endif
78 
79 #if !defined(GR_GL_LOG_CALLS_START)
80     #define GR_GL_LOG_CALLS_START                       0
81 #endif
82 
83 #if !defined(GR_GL_CHECK_ERROR)
84     #ifdef SK_DEBUG
85         #define GR_GL_CHECK_ERROR 1
86     #else
87         #define GR_GL_CHECK_ERROR 0
88     #endif
89 #endif
90 
91 #if !defined(GR_GL_CHECK_ERROR_START)
92     #define GR_GL_CHECK_ERROR_START                     1
93 #endif
94 
95 #if !defined(GR_GL_CHECK_ALLOC_WITH_GET_ERROR)
96     #define GR_GL_CHECK_ALLOC_WITH_GET_ERROR            1
97 #endif
98 
99 #endif
100