gfx/skia/trunk/src/gpu/gl/GrGLUtil.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /*
michael@0 2 * Copyright 2012 Google Inc.
michael@0 3 *
michael@0 4 * Use of this source code is governed by a BSD-style license that can be
michael@0 5 * found in the LICENSE file.
michael@0 6 */
michael@0 7
michael@0 8 #ifndef GrGLUtil_DEFINED
michael@0 9 #define GrGLUtil_DEFINED
michael@0 10
michael@0 11 #include "gl/GrGLInterface.h"
michael@0 12 #include "GrGLDefines.h"
michael@0 13
michael@0 14 class SkMatrix;
michael@0 15
michael@0 16 ////////////////////////////////////////////////////////////////////////////////
michael@0 17
michael@0 18 typedef uint32_t GrGLVersion;
michael@0 19 typedef uint32_t GrGLSLVersion;
michael@0 20
michael@0 21 /**
michael@0 22 * The Vendor and Renderer enum values are lazily updated as required.
michael@0 23 */
michael@0 24 enum GrGLVendor {
michael@0 25 kARM_GrGLVendor,
michael@0 26 kImagination_GrGLVendor,
michael@0 27 kIntel_GrGLVendor,
michael@0 28 kQualcomm_GrGLVendor,
michael@0 29
michael@0 30 kOther_GrGLVendor
michael@0 31 };
michael@0 32
michael@0 33 enum GrGLRenderer {
michael@0 34 kTegra2_GrGLRenderer,
michael@0 35 kTegra3_GrGLRenderer,
michael@0 36
michael@0 37 kOther_GrGLRenderer
michael@0 38 };
michael@0 39
michael@0 40 #define GR_GL_VER(major, minor) ((static_cast<int>(major) << 16) | \
michael@0 41 static_cast<int>(minor))
michael@0 42 #define GR_GLSL_VER(major, minor) ((static_cast<int>(major) << 16) | \
michael@0 43 static_cast<int>(minor))
michael@0 44
michael@0 45 ////////////////////////////////////////////////////////////////////////////////
michael@0 46
michael@0 47 /**
michael@0 48 * Some drivers want the var-int arg to be zero-initialized on input.
michael@0 49 */
michael@0 50 #define GR_GL_INIT_ZERO 0
michael@0 51 #define GR_GL_GetIntegerv(gl, e, p) \
michael@0 52 do { \
michael@0 53 *(p) = GR_GL_INIT_ZERO; \
michael@0 54 GR_GL_CALL(gl, GetIntegerv(e, p)); \
michael@0 55 } while (0)
michael@0 56
michael@0 57 #define GR_GL_GetFramebufferAttachmentParameteriv(gl, t, a, pname, p) \
michael@0 58 do { \
michael@0 59 *(p) = GR_GL_INIT_ZERO; \
michael@0 60 GR_GL_CALL(gl, GetFramebufferAttachmentParameteriv(t, a, pname, p)); \
michael@0 61 } while (0)
michael@0 62
michael@0 63 #define GR_GL_GetRenderbufferParameteriv(gl, t, pname, p) \
michael@0 64 do { \
michael@0 65 *(p) = GR_GL_INIT_ZERO; \
michael@0 66 GR_GL_CALL(gl, GetRenderbufferParameteriv(t, pname, p)); \
michael@0 67 } while (0)
michael@0 68 #define GR_GL_GetTexLevelParameteriv(gl, t, l, pname, p) \
michael@0 69 do { \
michael@0 70 *(p) = GR_GL_INIT_ZERO; \
michael@0 71 GR_GL_CALL(gl, GetTexLevelParameteriv(t, l, pname, p)); \
michael@0 72 } while (0)
michael@0 73
michael@0 74 ////////////////////////////////////////////////////////////////////////////////
michael@0 75
michael@0 76 /**
michael@0 77 * Helpers for glGetString()
michael@0 78 */
michael@0 79
michael@0 80 // these variants assume caller already has a string from glGetString()
michael@0 81 GrGLVersion GrGLGetVersionFromString(const char* versionString);
michael@0 82 GrGLStandard GrGLGetStandardInUseFromString(const char* versionString);
michael@0 83 GrGLSLVersion GrGLGetGLSLVersionFromString(const char* versionString);
michael@0 84 bool GrGLIsMesaFromVersionString(const char* versionString);
michael@0 85 GrGLVendor GrGLGetVendorFromString(const char* vendorString);
michael@0 86 GrGLRenderer GrGLGetRendererFromString(const char* rendererString);
michael@0 87 bool GrGLIsChromiumFromRendererString(const char* rendererString);
michael@0 88
michael@0 89 // these variants call glGetString()
michael@0 90 GrGLVersion GrGLGetVersion(const GrGLInterface*);
michael@0 91 GrGLSLVersion GrGLGetGLSLVersion(const GrGLInterface*);
michael@0 92 GrGLVendor GrGLGetVendor(const GrGLInterface*);
michael@0 93 GrGLRenderer GrGLGetRenderer(const GrGLInterface*);
michael@0 94
michael@0 95
michael@0 96 /**
michael@0 97 * Helpers for glGetError()
michael@0 98 */
michael@0 99
michael@0 100 void GrGLCheckErr(const GrGLInterface* gl,
michael@0 101 const char* location,
michael@0 102 const char* call);
michael@0 103
michael@0 104 void GrGLClearErr(const GrGLInterface* gl);
michael@0 105
michael@0 106 /**
michael@0 107 * Helper for converting SkMatrix to a column-major GL float array
michael@0 108 */
michael@0 109 template<int MatrixSize> void GrGLGetMatrix(GrGLfloat* dest, const SkMatrix& src);
michael@0 110
michael@0 111 ////////////////////////////////////////////////////////////////////////////////
michael@0 112
michael@0 113 /**
michael@0 114 * Macros for using GrGLInterface to make GL calls
michael@0 115 */
michael@0 116
michael@0 117 // internal macro to conditionally call glGetError based on compile-time and
michael@0 118 // run-time flags.
michael@0 119 #if GR_GL_CHECK_ERROR
michael@0 120 extern bool gCheckErrorGL;
michael@0 121 #define GR_GL_CHECK_ERROR_IMPL(IFACE, X) \
michael@0 122 if (gCheckErrorGL) \
michael@0 123 GrGLCheckErr(IFACE, GR_FILE_AND_LINE_STR, #X)
michael@0 124 #else
michael@0 125 #define GR_GL_CHECK_ERROR_IMPL(IFACE, X)
michael@0 126 #endif
michael@0 127
michael@0 128 // internal macro to conditionally log the gl call using GrPrintf based on
michael@0 129 // compile-time and run-time flags.
michael@0 130 #if GR_GL_LOG_CALLS
michael@0 131 extern bool gLogCallsGL;
michael@0 132 #define GR_GL_LOG_CALLS_IMPL(X) \
michael@0 133 if (gLogCallsGL) \
michael@0 134 GrPrintf(GR_FILE_AND_LINE_STR "GL: " #X "\n")
michael@0 135 #else
michael@0 136 #define GR_GL_LOG_CALLS_IMPL(X)
michael@0 137 #endif
michael@0 138
michael@0 139 // internal macro that does the per-GL-call callback (if necessary)
michael@0 140 #if GR_GL_PER_GL_FUNC_CALLBACK
michael@0 141 #define GR_GL_CALLBACK_IMPL(IFACE) (IFACE)->fCallback(IFACE)
michael@0 142 #else
michael@0 143 #define GR_GL_CALLBACK_IMPL(IFACE)
michael@0 144 #endif
michael@0 145
michael@0 146 // makes a GL call on the interface and does any error checking and logging
michael@0 147 #define GR_GL_CALL(IFACE, X) \
michael@0 148 do { \
michael@0 149 GR_GL_CALL_NOERRCHECK(IFACE, X); \
michael@0 150 GR_GL_CHECK_ERROR_IMPL(IFACE, X); \
michael@0 151 } while (false)
michael@0 152
michael@0 153 // Variant of above that always skips the error check. This is useful when
michael@0 154 // the caller wants to do its own glGetError() call and examine the error value.
michael@0 155 #define GR_GL_CALL_NOERRCHECK(IFACE, X) \
michael@0 156 do { \
michael@0 157 GR_GL_CALLBACK_IMPL(IFACE); \
michael@0 158 (IFACE)->fFunctions.f##X; \
michael@0 159 GR_GL_LOG_CALLS_IMPL(X); \
michael@0 160 } while (false)
michael@0 161
michael@0 162 // same as GR_GL_CALL but stores the return value of the gl call in RET
michael@0 163 #define GR_GL_CALL_RET(IFACE, RET, X) \
michael@0 164 do { \
michael@0 165 GR_GL_CALL_RET_NOERRCHECK(IFACE, RET, X); \
michael@0 166 GR_GL_CHECK_ERROR_IMPL(IFACE, X); \
michael@0 167 } while (false)
michael@0 168
michael@0 169 // same as GR_GL_CALL_RET but always skips the error check.
michael@0 170 #define GR_GL_CALL_RET_NOERRCHECK(IFACE, RET, X) \
michael@0 171 do { \
michael@0 172 GR_GL_CALLBACK_IMPL(IFACE); \
michael@0 173 (RET) = (IFACE)->fFunctions.f##X; \
michael@0 174 GR_GL_LOG_CALLS_IMPL(X); \
michael@0 175 } while (false)
michael@0 176
michael@0 177 // call glGetError without doing a redundant error check or logging.
michael@0 178 #define GR_GL_GET_ERROR(IFACE) (IFACE)->fFunctions.fGetError()
michael@0 179
michael@0 180 #endif

mercurial