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.
2 /*
3 * Copyright 2013 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 #ifndef SkGLContextHelper_DEFINED
9 #define SkGLContextHelper_DEFINED
11 #include "GrGLInterface.h"
13 /**
14 * Create an offscreen opengl context with an RGBA8 / 8bit stencil FBO.
15 * Provides a GrGLInterface struct of function pointers for the context.
16 */
18 class SK_API SkGLContextHelper : public SkRefCnt {
19 public:
20 SK_DECLARE_INST_COUNT(SkGLContextHelper)
22 SkGLContextHelper();
23 virtual ~SkGLContextHelper();
25 /**
26 * Initializes the context and makes it current.
27 */
28 bool init(const int width, const int height);
30 int getFBOID() const { return fFBO; }
32 const GrGLInterface* gl() const { return fGL; }
34 virtual void makeCurrent() const = 0;
36 /**
37 * The primary purpose of this function it to provide a means of scheduling
38 * work on the GPU (since all of the subclasses create primary buffers for
39 * testing that are small and not meant to be rendered to the screen).
40 *
41 * If the drawing surface provided by the platform is double buffered this
42 * call will cause the platform to swap which buffer is currently being
43 * targeted. If the current surface does not include a back buffer, this
44 * call has no effect.
45 */
46 virtual void swapBuffers() const = 0;
48 bool hasExtension(const char* extensionName) const {
49 SkASSERT(NULL != fGL);
50 return fGL->hasExtension(extensionName);
51 }
53 protected:
54 /**
55 * Subclass implements this to make a GL context. The returned GrGLInterface
56 * should be populated with functions compatible with the context. The
57 * format and size of backbuffers does not matter since an FBO will be
58 * created.
59 */
60 virtual const GrGLInterface* createGLContext() = 0;
62 /**
63 * Subclass should destroy the underlying GL context.
64 */
65 virtual void destroyGLContext() = 0;
67 private:
68 GrGLuint fFBO;
69 GrGLuint fColorBufferID;
70 GrGLuint fDepthStencilBufferID;
71 const GrGLInterface* fGL;
73 typedef SkRefCnt INHERITED;
74 };
76 /**
77 * Helper macros for using the GL context through the GrGLInterface. Example:
78 * SK_GL(glCtx, GenTextures(1, &texID));
79 */
80 #define SK_GL(ctx, X) (ctx).gl()->fFunctions.f ## X; \
81 SkASSERT(GR_GL_NO_ERROR == (ctx).gl()->fFunctions.fGetError())
82 #define SK_GL_RET(ctx, RET, X) (RET) = (ctx).gl()->fFunctions.f ## X; \
83 SkASSERT(GR_GL_NO_ERROR == (ctx).gl()->fFunctions.fGetError())
84 #define SK_GL_NOERRCHECK(ctx, X) (ctx).gl()->fFunctions.f ## X
85 #define SK_GL_RET_NOERRCHECK(ctx, RET, X) (RET) = (ctx).gl()->fFunctions.f ## X
87 #endif