1876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com
2876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com/*
3876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * Copyright 2011 Google Inc.
4876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com *
5876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * Use of this source code is governed by a BSD-style license that can be
6876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * found in the LICENSE file.
7876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com */
8876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com
9876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com
10876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com
11876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com#ifndef GrGLConfig_DEFINED
12876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com#define GrGLConfig_DEFINED
13876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com
14876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com#include "GrTypes.h"
15876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com
16876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com/**
17876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * Optional GL config file.
18876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com */
19876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com#ifdef GR_GL_CUSTOM_SETUP_HEADER
20876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com    #include GR_GL_CUSTOM_SETUP_HEADER
21876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com#endif
22876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com
23876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com#if !defined(GR_GL_FUNCTION_TYPE)
24876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com    #define GR_GL_FUNCTION_TYPE
25876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com#endif
26876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com
27876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com/**
28876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * The following are optional defines that can be enabled at the compiler
29876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * command line, in a IDE project, in a GrUserConfig.h file, or in a GL custom
30876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * file (if one is in use). If a GR_GL_CUSTOM_SETUP_HEADER is used they can
31876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * also be placed there.
32876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com *
33876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * GR_GL_LOG_CALLS: if 1 Gr can print every GL call using GrPrintf. Defaults to
34876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * 0. Logging can be enabled and disabled at runtime using a debugger via to
35876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * global gLogCallsGL. The initial value of gLogCallsGL is controlled by
36876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * GR_GL_LOG_CALLS_START.
37876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com *
38876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * GR_GL_LOG_CALLS_START: controls the initial value of gLogCallsGL when
39876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * GR_GL_LOG_CALLS is 1. Defaults to 0.
40876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com *
41876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * GR_GL_CHECK_ERROR: if enabled Gr can do a glGetError() after every GL call.
42f9e5f501b4e6c9e17b19730ef1f32caa407fb80bcommit-bot@chromium.org * Defaults to 1 if SK_DEBUG is set, otherwise 0. When GR_GL_CHECK_ERROR is 1
43876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * this can be toggled in a debugger using the gCheckErrorGL global. The initial
44876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * value of gCheckErrorGL is controlled by by GR_GL_CHECK_ERROR_START.
45876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com *
46876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * GR_GL_CHECK_ERROR_START: controls the initial value of gCheckErrorGL
47876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * when GR_GL_CHECK_ERROR is 1.  Defaults to 1.
48876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com *
49876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * GR_GL_NO_CONSTANT_ATTRIBUTES: if this evaluates to true then the GL backend
50876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * will use uniforms instead of attributes in all cases when there is not
51876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * per-vertex data. This is important when the underlying GL implementation
521fde19f3b72345b473a1a9bd64729237a388813frmistry@google.com * doesn't actually support immediate style attribute values (e.g. when
53876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * the GL stream is converted to DX as in ANGLE on Chrome). Defaults to 0.
54876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com *
55876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * GR_GL_USE_BUFFER_DATA_NULL_HINT: When specifing new data for a vertex/index
56876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * buffer that replaces old data Ganesh can give a hint to the driver that the
57876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * previous data will not be used in future draws like this:
58876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com *  glBufferData(GL_..._BUFFER, size, NULL, usage);       //<--hint, NULL means
59876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com *  glBufferSubData(GL_..._BUFFER, 0, lessThanSize, data) //   old data can't be
60876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com *                                                        //   used again.
61876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * However, this can be an unoptimization on some platforms, esp. Chrome.
62876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * Chrome's cmd buffer will create a new allocation and memset the whole thing
63876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * to zero (for security reasons). Defaults to 1 (enabled).
64876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com *
65876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * GR_GL_PER_GL_FUNC_CALLBACK: When set to 1 the GrGLInterface object provides
66876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * a function pointer that is called just before every gl function. The ptr must
67876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * be valid (i.e. there is no NULL check). However, by default the callback will
68876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * be set to a function that does nothing. The signature of the function is:
69876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com *    void function(const GrGLInterface*)
70876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * It is not extern "C".
71876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * The GrGLInterface field fCallback specifies the function ptr and there is an
72876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com * additional field fCallbackData of type intptr_t for client data.
739faf9291146b9d8c02862271bc84e4b1172998cfbsalomon@google.com *
74fa2e5700995a246efa4ef53bfadd3d2d03d9225ebsalomon@google.com * GR_GL_RGBA_8888_PIXEL_OPS_SLOW: Set this to 1 if it is known that performing
75fa2e5700995a246efa4ef53bfadd3d2d03d9225ebsalomon@google.com * glReadPixels / glTex(Sub)Image with format=GL_RGBA, type=GL_UNISIGNED_BYTE is
76fa2e5700995a246efa4ef53bfadd3d2d03d9225ebsalomon@google.com * significantly slower than format=GL_BGRA, type=GL_UNISIGNED_BYTE.
776b758a0dae0c3ba3cf72a32246a4ca2737ef98d6bsalomon@google.com *
786b758a0dae0c3ba3cf72a32246a4ca2737ef98d6bsalomon@google.com * GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL: Set this to 1 if calling
796b758a0dae0c3ba3cf72a32246a4ca2737ef98d6bsalomon@google.com * glReadPixels to read the entire framebuffer is faster than calling it with
806b758a0dae0c3ba3cf72a32246a4ca2737ef98d6bsalomon@google.com * the same sized rectangle but with a framebuffer bound that is larger than
816b758a0dae0c3ba3cf72a32246a4ca2737ef98d6bsalomon@google.com * the rectangle read.
826ecfb4f4491a466124e6b5297c6564eb1ddc8f1cbsalomon@google.com *
836ecfb4f4491a466124e6b5297c6564eb1ddc8f1cbsalomon@google.com * GR_GL_CHECK_ALLOC_WITH_GET_ERROR: If set to 1 this will then glTexImage,
846ecfb4f4491a466124e6b5297c6564eb1ddc8f1cbsalomon@google.com * glBufferData, glRenderbufferStorage, etc will be checked for errors. This
856ecfb4f4491a466124e6b5297c6564eb1ddc8f1cbsalomon@google.com * amounts to ensuring the error is GL_NO_ERROR, calling the allocating
866ecfb4f4491a466124e6b5297c6564eb1ddc8f1cbsalomon@google.com * function, and then checking that the error is still GL_NO_ERROR. When the
876ecfb4f4491a466124e6b5297c6564eb1ddc8f1cbsalomon@google.com * value is 0 we will assume no error was generated without checking.
881dbed9c602ce269716783d894f03655d1e8d7647bsalomon@google.com *
891dbed9c602ce269716783d894f03655d1e8d7647bsalomon@google.com * GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT: We will normally check the FBO status
901dbed9c602ce269716783d894f03655d1e8d7647bsalomon@google.com * every time we bind a texture or renderbuffer to an FBO. However, in some
911dbed9c602ce269716783d894f03655d1e8d7647bsalomon@google.com * environments CheckFrameBufferStatus is very expensive. If this is set we will
921dbed9c602ce269716783d894f03655d1e8d7647bsalomon@google.com * check the first time we use a color format or a combination of color /
931dbed9c602ce269716783d894f03655d1e8d7647bsalomon@google.com * stencil formats as attachments. If the FBO is complete we will assume
941dbed9c602ce269716783d894f03655d1e8d7647bsalomon@google.com * subsequent attachments with the same formats are complete as well.
957376cf36fed86de3af0bb713dc49ef3c99d1c199bsalomon@google.com *
967376cf36fed86de3af0bb713dc49ef3c99d1c199bsalomon@google.com * GR_GL_USE_NV_PATH_RENDERING: Enable experimental support for
977376cf36fed86de3af0bb713dc49ef3c99d1c199bsalomon@google.com * GL_NV_path_rendering. There are known issues with clipping, non-AA paths, and
987376cf36fed86de3af0bb713dc49ef3c99d1c199bsalomon@google.com * perspective.
99f58e7193bec03ab37df78ca910336f6f4c1fec95bsalomon@google.com *
100f58e7193bec03ab37df78ca910336f6f4c1fec95bsalomon@google.com * GR_GL_MUST_USE_VBO: Indicates that all vertices and indices must be rendered
101f58e7193bec03ab37df78ca910336f6f4c1fec95bsalomon@google.com * from VBOs. Chromium's command buffer doesn't allow glVertexAttribArray with
102f58e7193bec03ab37df78ca910336f6f4c1fec95bsalomon@google.com * ARARY_BUFFER 0 bound or glDrawElements with ELEMENT_ARRAY_BUFFER 0 bound.
1035a02d14de590f6477f86291ce3ee822e7e8c4824bsalomon@google.com *
1045a02d14de590f6477f86291ce3ee822e7e8c4824bsalomon@google.com * GR_GL_USE_NEW_SHADER_SOURCE_SIGNATURE is for compatibility with the new version
1055a02d14de590f6477f86291ce3ee822e7e8c4824bsalomon@google.com * of the OpenGLES2.0 headers from Khronos.  glShaderSource now takes a const char * const *,
1065a02d14de590f6477f86291ce3ee822e7e8c4824bsalomon@google.com * instead of a const char
107876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com */
108876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com
109876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com#if !defined(GR_GL_LOG_CALLS)
110f9e5f501b4e6c9e17b19730ef1f32caa407fb80bcommit-bot@chromium.org    #ifdef SK_DEBUG
111f9e5f501b4e6c9e17b19730ef1f32caa407fb80bcommit-bot@chromium.org        #define GR_GL_LOG_CALLS 1
112f9e5f501b4e6c9e17b19730ef1f32caa407fb80bcommit-bot@chromium.org    #else
113f9e5f501b4e6c9e17b19730ef1f32caa407fb80bcommit-bot@chromium.org        #define GR_GL_LOG_CALLS 0
114f9e5f501b4e6c9e17b19730ef1f32caa407fb80bcommit-bot@chromium.org    #endif
115876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com#endif
116876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com
117876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com#if !defined(GR_GL_LOG_CALLS_START)
1181dbed9c602ce269716783d894f03655d1e8d7647bsalomon@google.com    #define GR_GL_LOG_CALLS_START                       0
119876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com#endif
120876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com
121876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com#if !defined(GR_GL_CHECK_ERROR)
122f9e5f501b4e6c9e17b19730ef1f32caa407fb80bcommit-bot@chromium.org    #ifdef SK_DEBUG
123f9e5f501b4e6c9e17b19730ef1f32caa407fb80bcommit-bot@chromium.org        #define GR_GL_CHECK_ERROR 1
124f9e5f501b4e6c9e17b19730ef1f32caa407fb80bcommit-bot@chromium.org    #else
125f9e5f501b4e6c9e17b19730ef1f32caa407fb80bcommit-bot@chromium.org        #define GR_GL_CHECK_ERROR 0
126f9e5f501b4e6c9e17b19730ef1f32caa407fb80bcommit-bot@chromium.org    #endif
127876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com#endif
128876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com
129876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com#if !defined(GR_GL_CHECK_ERROR_START)
1301dbed9c602ce269716783d894f03655d1e8d7647bsalomon@google.com    #define GR_GL_CHECK_ERROR_START                     1
131876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com#endif
132876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com
133876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com#if !defined(GR_GL_NO_CONSTANT_ATTRIBUTES)
1341dbed9c602ce269716783d894f03655d1e8d7647bsalomon@google.com    #define GR_GL_NO_CONSTANT_ATTRIBUTES                0
135876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com#endif
136876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com
137876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com#if !defined(GR_GL_USE_BUFFER_DATA_NULL_HINT)
1381dbed9c602ce269716783d894f03655d1e8d7647bsalomon@google.com    #define GR_GL_USE_BUFFER_DATA_NULL_HINT             1
139876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com#endif
140876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com
141876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com#if !defined(GR_GL_PER_GL_FUNC_CALLBACK)
1421dbed9c602ce269716783d894f03655d1e8d7647bsalomon@google.com    #define GR_GL_PER_GL_FUNC_CALLBACK                  0
143876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com#endif
144876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com
145fa2e5700995a246efa4ef53bfadd3d2d03d9225ebsalomon@google.com#if !defined(GR_GL_RGBA_8888_PIXEL_OPS_SLOW)
1461dbed9c602ce269716783d894f03655d1e8d7647bsalomon@google.com    #define GR_GL_RGBA_8888_PIXEL_OPS_SLOW              0
1479faf9291146b9d8c02862271bc84e4b1172998cfbsalomon@google.com#endif
1489faf9291146b9d8c02862271bc84e4b1172998cfbsalomon@google.com
1496b758a0dae0c3ba3cf72a32246a4ca2737ef98d6bsalomon@google.com#if !defined(GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL)
1501dbed9c602ce269716783d894f03655d1e8d7647bsalomon@google.com    #define GR_GL_FULL_READPIXELS_FASTER_THAN_PARTIAL   0
1516b758a0dae0c3ba3cf72a32246a4ca2737ef98d6bsalomon@google.com#endif
1526b758a0dae0c3ba3cf72a32246a4ca2737ef98d6bsalomon@google.com
1536ecfb4f4491a466124e6b5297c6564eb1ddc8f1cbsalomon@google.com#if !defined(GR_GL_CHECK_ALLOC_WITH_GET_ERROR)
1541dbed9c602ce269716783d894f03655d1e8d7647bsalomon@google.com    #define GR_GL_CHECK_ALLOC_WITH_GET_ERROR            1
1551dbed9c602ce269716783d894f03655d1e8d7647bsalomon@google.com#endif
1561dbed9c602ce269716783d894f03655d1e8d7647bsalomon@google.com
1571dbed9c602ce269716783d894f03655d1e8d7647bsalomon@google.com#if !defined(GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT)
1581dbed9c602ce269716783d894f03655d1e8d7647bsalomon@google.com    #define GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT      0
1596ecfb4f4491a466124e6b5297c6564eb1ddc8f1cbsalomon@google.com#endif
1606ecfb4f4491a466124e6b5297c6564eb1ddc8f1cbsalomon@google.com
1617376cf36fed86de3af0bb713dc49ef3c99d1c199bsalomon@google.com#if !defined(GR_GL_USE_NV_PATH_RENDERING)
1627376cf36fed86de3af0bb713dc49ef3c99d1c199bsalomon@google.com    #define GR_GL_USE_NV_PATH_RENDERING                 0
1637376cf36fed86de3af0bb713dc49ef3c99d1c199bsalomon@google.com#endif
1647376cf36fed86de3af0bb713dc49ef3c99d1c199bsalomon@google.com
165f58e7193bec03ab37df78ca910336f6f4c1fec95bsalomon@google.com#if !defined(GR_GL_MUST_USE_VBO)
166f58e7193bec03ab37df78ca910336f6f4c1fec95bsalomon@google.com    #define GR_GL_MUST_USE_VBO                          0
167f58e7193bec03ab37df78ca910336f6f4c1fec95bsalomon@google.com#endif
168f58e7193bec03ab37df78ca910336f6f4c1fec95bsalomon@google.com
1695a02d14de590f6477f86291ce3ee822e7e8c4824bsalomon@google.com#if !defined(GR_GL_USE_NEW_SHADER_SOURCE_SIGNATURE)
1705a02d14de590f6477f86291ce3ee822e7e8c4824bsalomon@google.com    #define GR_GL_USE_NEW_SHADER_SOURCE_SIGNATURE       0
1715a02d14de590f6477f86291ce3ee822e7e8c4824bsalomon@google.com#endif
1725a02d14de590f6477f86291ce3ee822e7e8c4824bsalomon@google.com
1734463fac7395b5a85284ff5330204820e5f81fdb7commit-bot@chromium.org// We now have a separate GrGLInterface function pointer entry for the IMG/EXT version of
1744463fac7395b5a85284ff5330204820e5f81fdb7commit-bot@chromium.org// glRenderbufferStorageMultisampled. However, Chrome is setting the one we now use for
1754463fac7395b5a85284ff5330204820e5f81fdb7commit-bot@chromium.org// ES3 MSAA to point to the IMG/EXT function. This macro exists to make Skia ignore the
1764463fac7395b5a85284ff5330204820e5f81fdb7commit-bot@chromium.org// ES3 MSAA and instead use the IMG/EXT version with the old function pointer entry. It will
1774463fac7395b5a85284ff5330204820e5f81fdb7commit-bot@chromium.org// be removed as soon as Chrome is updated to set the new function pointer.
1784463fac7395b5a85284ff5330204820e5f81fdb7commit-bot@chromium.org#if !defined(GR_GL_IGNORE_ES3_MSAA)
1794463fac7395b5a85284ff5330204820e5f81fdb7commit-bot@chromium.org    #define GR_GL_IGNORE_ES3_MSAA 0
1804463fac7395b5a85284ff5330204820e5f81fdb7commit-bot@chromium.org#endif
1814463fac7395b5a85284ff5330204820e5f81fdb7commit-bot@chromium.org
182ab9a47bee0453aa5ab165131cbe03a9e8425a51bbsalomon@google.com/**
183ab9a47bee0453aa5ab165131cbe03a9e8425a51bbsalomon@google.com * There is a strange bug that occurs on Macs with NVIDIA GPUs. We don't
184ab9a47bee0453aa5ab165131cbe03a9e8425a51bbsalomon@google.com * fully understand it. When (element) array buffers are continually
18570869254b0d9d807dd7167651bee0b09b8847965bsalomon@google.com * respecified using glBufferData performance can fall off of a cliff. The
18670869254b0d9d807dd7167651bee0b09b8847965bsalomon@google.com * driver winds up performing many DMA mapping / unmappings and chews up ~50% of
18770869254b0d9d807dd7167651bee0b09b8847965bsalomon@google.com * the core. However, it has been observed that occaisonally respecifiying the
18870869254b0d9d807dd7167651bee0b09b8847965bsalomon@google.com * buffer using glBufferData and then writing data using glBufferSubData
18970869254b0d9d807dd7167651bee0b09b8847965bsalomon@google.com * prevents the bad behavior.
190ab9a47bee0453aa5ab165131cbe03a9e8425a51bbsalomon@google.com *
191ab9a47bee0453aa5ab165131cbe03a9e8425a51bbsalomon@google.com * There is a lot of uncertainty around this issue. In Chrome backgrounding
192ab9a47bee0453aa5ab165131cbe03a9e8425a51bbsalomon@google.com * the tab somehow initiates this behavior and we don't know what the connection
193ab9a47bee0453aa5ab165131cbe03a9e8425a51bbsalomon@google.com * is. Another observation is that Chrome's cmd buffer server will actually
194ab9a47bee0453aa5ab165131cbe03a9e8425a51bbsalomon@google.com * create a buffer full of zeros when it sees a NULL data param (for security
195ab9a47bee0453aa5ab165131cbe03a9e8425a51bbsalomon@google.com * reasons). If this is disabled and NULL is actually passed all the way to the
196ab9a47bee0453aa5ab165131cbe03a9e8425a51bbsalomon@google.com * driver then the workaround doesn't help.
197ab9a47bee0453aa5ab165131cbe03a9e8425a51bbsalomon@google.com *
198ab9a47bee0453aa5ab165131cbe03a9e8425a51bbsalomon@google.com * The issue is tracked at:
199ab9a47bee0453aa5ab165131cbe03a9e8425a51bbsalomon@google.com * http://code.google.com/p/chromium/issues/detail?id=114865
200ab9a47bee0453aa5ab165131cbe03a9e8425a51bbsalomon@google.com *
20170869254b0d9d807dd7167651bee0b09b8847965bsalomon@google.com * When the workaround is enabled we will use the glBufferData / glBufferSubData
20270869254b0d9d807dd7167651bee0b09b8847965bsalomon@google.com * trick every 128 array buffer uploads.
203ab9a47bee0453aa5ab165131cbe03a9e8425a51bbsalomon@google.com *
204ab9a47bee0453aa5ab165131cbe03a9e8425a51bbsalomon@google.com * Hopefully we will understand this better and have a cleaner fix or get a
205ab9a47bee0453aa5ab165131cbe03a9e8425a51bbsalomon@google.com * OS/driver level fix.
206ab9a47bee0453aa5ab165131cbe03a9e8425a51bbsalomon@google.com */
207ab9a47bee0453aa5ab165131cbe03a9e8425a51bbsalomon@google.com#define GR_GL_MAC_BUFFER_OBJECT_PERFOMANCE_WORKAROUND   \
20808455f1364095aca96041856b5fdb6410d40bb5fcommit-bot@chromium.org    (defined(SK_BUILD_FOR_MAC) &&                       \
209ab9a47bee0453aa5ab165131cbe03a9e8425a51bbsalomon@google.com     !GR_GL_USE_BUFFER_DATA_NULL_HINT)
210ab9a47bee0453aa5ab165131cbe03a9e8425a51bbsalomon@google.com
211876688bbdef378c43ef01f50e52fa8539f28ec33bsalomon@google.com#endif
212