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 */
8 #include "gl/SkNativeGLContext.h"
9 #include "AvailabilityMacros.h"
11 SkNativeGLContext::AutoContextRestore::AutoContextRestore() {
12 fOldCGLContext = CGLGetCurrentContext();
13 }
15 SkNativeGLContext::AutoContextRestore::~AutoContextRestore() {
16 CGLSetCurrentContext(fOldCGLContext);
17 }
19 ///////////////////////////////////////////////////////////////////////////////
21 SkNativeGLContext::SkNativeGLContext()
22 : fContext(NULL) {
23 }
25 SkNativeGLContext::~SkNativeGLContext() {
26 this->destroyGLContext();
27 }
29 void SkNativeGLContext::destroyGLContext() {
30 if (NULL != fContext) {
31 CGLReleaseContext(fContext);
32 }
33 }
35 const GrGLInterface* SkNativeGLContext::createGLContext() {
36 SkASSERT(NULL == fContext);
38 CGLPixelFormatAttribute attributes[] = {
39 #if MAC_OS_X_VERSION_10_7
40 kCGLPFAOpenGLProfile, (CGLPixelFormatAttribute) kCGLOGLPVersion_3_2_Core,
41 #endif
42 kCGLPFADoubleBuffer,
43 (CGLPixelFormatAttribute)0
44 };
45 CGLPixelFormatObj pixFormat;
46 GLint npix;
48 CGLChoosePixelFormat(attributes, &pixFormat, &npix);
50 if (NULL == pixFormat) {
51 SkDebugf("CGLChoosePixelFormat failed.");
52 return NULL;
53 }
55 CGLCreateContext(pixFormat, NULL, &fContext);
56 CGLReleasePixelFormat(pixFormat);
58 if (NULL == fContext) {
59 SkDebugf("CGLCreateContext failed.");
60 return NULL;
61 }
63 CGLSetCurrentContext(fContext);
65 const GrGLInterface* interface = GrGLCreateNativeInterface();
66 if (NULL == interface) {
67 SkDebugf("Context could not create GL interface.\n");
68 this->destroyGLContext();
69 return NULL;
70 }
72 return interface;
73 }
75 void SkNativeGLContext::makeCurrent() const {
76 CGLSetCurrentContext(fContext);
77 }
79 void SkNativeGLContext::swapBuffers() const {
80 CGLFlushDrawable(fContext);
81 }