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 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 */
9 #include <GL/osmesa.h>
11 #include "gl/SkMesaGLContext.h"
12 #include "gl/GrGLDefines.h"
14 SkMesaGLContext::AutoContextRestore::AutoContextRestore() {
15 fOldContext = (Context)OSMesaGetCurrentContext();
16 if (NULL != (OSMesaContext)fOldContext) {
17 OSMesaGetColorBuffer((OSMesaContext)fOldContext,
18 &fOldWidth, &fOldHeight,
19 &fOldFormat, &fOldImage);
20 }
21 }
23 SkMesaGLContext::AutoContextRestore::~AutoContextRestore() {
24 if (NULL != (OSMesaContext)fOldContext) {
25 OSMesaMakeCurrent((OSMesaContext)fOldContext, fOldImage,
26 fOldFormat, fOldWidth, fOldHeight);
27 }
28 }
30 ///////////////////////////////////////////////////////////////////////////////
32 SkMesaGLContext::SkMesaGLContext()
33 : fContext(static_cast<Context>(NULL))
34 , fImage(NULL) {
35 GR_STATIC_ASSERT(sizeof(Context) == sizeof(OSMesaContext));
36 }
38 SkMesaGLContext::~SkMesaGLContext() {
39 this->destroyGLContext();
40 }
42 void SkMesaGLContext::destroyGLContext() {
43 if (fImage) {
44 sk_free(fImage);
45 fImage = NULL;
46 }
48 if (fContext) {
49 OSMesaDestroyContext((OSMesaContext)fContext);
50 fContext = static_cast<Context>(NULL);
51 }
52 }
54 static const GrGLint gBOGUS_SIZE = 16;
56 const GrGLInterface* SkMesaGLContext::createGLContext() {
57 /* Create an RGBA-mode context */
58 #if OSMESA_MAJOR_VERSION * 100 + OSMESA_MINOR_VERSION >= 305
59 /* specify Z, stencil, accum sizes */
60 fContext = (Context)OSMesaCreateContextExt(OSMESA_BGRA, 0, 0, 0, NULL);
61 #else
62 fContext = (Context)OSMesaCreateContext(OSMESA_BGRA, NULL);
63 #endif
64 if (!fContext) {
65 SkDebugf("OSMesaCreateContext failed!\n");
66 this->destroyGLContext();
67 return NULL;
68 }
69 // Allocate the image buffer
70 fImage = (GrGLubyte *) sk_malloc_throw(gBOGUS_SIZE * gBOGUS_SIZE *
71 4 * sizeof(GrGLubyte));
72 if (!fImage) {
73 SkDebugf("Alloc image buffer failed!\n");
74 this->destroyGLContext();
75 return NULL;
76 }
78 // Bind the buffer to the context and make it current
79 if (!OSMesaMakeCurrent((OSMesaContext)fContext,
80 fImage,
81 GR_GL_UNSIGNED_BYTE,
82 gBOGUS_SIZE,
83 gBOGUS_SIZE)) {
84 SkDebugf("OSMesaMakeCurrent failed!\n");
85 this->destroyGLContext();
86 return NULL;
87 }
89 const GrGLInterface* interface = GrGLCreateMesaInterface();
90 if (!interface) {
91 SkDebugf("Could not create GL interface!\n");
92 this->destroyGLContext();
93 return NULL;
94 }
95 return interface;
97 }
99 void SkMesaGLContext::makeCurrent() const {
100 if (fContext) {
101 if (!OSMesaMakeCurrent((OSMesaContext)fContext, fImage,
102 GR_GL_UNSIGNED_BYTE, gBOGUS_SIZE, gBOGUS_SIZE)) {
103 SkDebugf("Could not make MESA context current.");
104 }
105 }
106 }
108 void SkMesaGLContext::swapBuffers() const { }