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