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.
michael@0 | 1 | |
michael@0 | 2 | /* |
michael@0 | 3 | * Copyright 2013 Google Inc. |
michael@0 | 4 | * |
michael@0 | 5 | * Use of this source code is governed by a BSD-style license that can be |
michael@0 | 6 | * found in the LICENSE file. |
michael@0 | 7 | */ |
michael@0 | 8 | #include "gl/SkGLContextHelper.h" |
michael@0 | 9 | #include "GrGLUtil.h" |
michael@0 | 10 | |
michael@0 | 11 | SkGLContextHelper::SkGLContextHelper() |
michael@0 | 12 | : fFBO(0) |
michael@0 | 13 | , fColorBufferID(0) |
michael@0 | 14 | , fDepthStencilBufferID(0) |
michael@0 | 15 | , fGL(NULL) { |
michael@0 | 16 | } |
michael@0 | 17 | |
michael@0 | 18 | SkGLContextHelper::~SkGLContextHelper() { |
michael@0 | 19 | |
michael@0 | 20 | if (fGL) { |
michael@0 | 21 | // TODO: determine why DeleteFramebuffers is generating a GL error in tests |
michael@0 | 22 | SK_GL_NOERRCHECK(*this, DeleteFramebuffers(1, &fFBO)); |
michael@0 | 23 | SK_GL_NOERRCHECK(*this, DeleteRenderbuffers(1, &fColorBufferID)); |
michael@0 | 24 | SK_GL_NOERRCHECK(*this, DeleteRenderbuffers(1, &fDepthStencilBufferID)); |
michael@0 | 25 | } |
michael@0 | 26 | |
michael@0 | 27 | SkSafeUnref(fGL); |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | bool SkGLContextHelper::init(int width, int height) { |
michael@0 | 31 | if (fGL) { |
michael@0 | 32 | fGL->unref(); |
michael@0 | 33 | this->destroyGLContext(); |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | fGL = this->createGLContext(); |
michael@0 | 37 | if (fGL) { |
michael@0 | 38 | const GrGLubyte* temp; |
michael@0 | 39 | |
michael@0 | 40 | if (!fGL->validate()) { |
michael@0 | 41 | fGL = NULL; |
michael@0 | 42 | this->destroyGLContext(); |
michael@0 | 43 | return false; |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | SK_GL_RET(*this, temp, GetString(GR_GL_VERSION)); |
michael@0 | 47 | const char* versionStr = reinterpret_cast<const char*>(temp); |
michael@0 | 48 | GrGLVersion version = GrGLGetVersionFromString(versionStr); |
michael@0 | 49 | |
michael@0 | 50 | // clear any existing GL erorrs |
michael@0 | 51 | GrGLenum error; |
michael@0 | 52 | do { |
michael@0 | 53 | SK_GL_RET(*this, error, GetError()); |
michael@0 | 54 | } while (GR_GL_NO_ERROR != error); |
michael@0 | 55 | |
michael@0 | 56 | SK_GL(*this, GenFramebuffers(1, &fFBO)); |
michael@0 | 57 | SK_GL(*this, BindFramebuffer(GR_GL_FRAMEBUFFER, fFBO)); |
michael@0 | 58 | SK_GL(*this, GenRenderbuffers(1, &fColorBufferID)); |
michael@0 | 59 | SK_GL(*this, BindRenderbuffer(GR_GL_RENDERBUFFER, fColorBufferID)); |
michael@0 | 60 | if (kGLES_GrGLStandard == this->gl()->fStandard) { |
michael@0 | 61 | SK_GL(*this, RenderbufferStorage(GR_GL_RENDERBUFFER, |
michael@0 | 62 | GR_GL_RGBA8, |
michael@0 | 63 | width, height)); |
michael@0 | 64 | } else { |
michael@0 | 65 | SK_GL(*this, RenderbufferStorage(GR_GL_RENDERBUFFER, |
michael@0 | 66 | GR_GL_RGBA, |
michael@0 | 67 | width, height)); |
michael@0 | 68 | } |
michael@0 | 69 | SK_GL(*this, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, |
michael@0 | 70 | GR_GL_COLOR_ATTACHMENT0, |
michael@0 | 71 | GR_GL_RENDERBUFFER, |
michael@0 | 72 | fColorBufferID)); |
michael@0 | 73 | SK_GL(*this, GenRenderbuffers(1, &fDepthStencilBufferID)); |
michael@0 | 74 | SK_GL(*this, BindRenderbuffer(GR_GL_RENDERBUFFER, fDepthStencilBufferID)); |
michael@0 | 75 | |
michael@0 | 76 | // Some drivers that support packed depth stencil will only succeed |
michael@0 | 77 | // in binding a packed format an FBO. However, we can't rely on packed |
michael@0 | 78 | // depth stencil being available. |
michael@0 | 79 | bool supportsPackedDepthStencil; |
michael@0 | 80 | if (kGLES_GrGLStandard == this->gl()->fStandard) { |
michael@0 | 81 | supportsPackedDepthStencil = version >= GR_GL_VER(3,0) || |
michael@0 | 82 | this->hasExtension("GL_OES_packed_depth_stencil"); |
michael@0 | 83 | } else { |
michael@0 | 84 | supportsPackedDepthStencil = version >= GR_GL_VER(3,0) || |
michael@0 | 85 | this->hasExtension("GL_EXT_packed_depth_stencil") || |
michael@0 | 86 | this->hasExtension("GL_ARB_framebuffer_object"); |
michael@0 | 87 | } |
michael@0 | 88 | |
michael@0 | 89 | if (supportsPackedDepthStencil) { |
michael@0 | 90 | // ES2 requires sized internal formats for RenderbufferStorage |
michael@0 | 91 | // On Desktop we let the driver decide. |
michael@0 | 92 | GrGLenum format = kGLES_GrGLStandard == this->gl()->fStandard ? |
michael@0 | 93 | GR_GL_DEPTH24_STENCIL8 : |
michael@0 | 94 | GR_GL_DEPTH_STENCIL; |
michael@0 | 95 | SK_GL(*this, RenderbufferStorage(GR_GL_RENDERBUFFER, |
michael@0 | 96 | format, |
michael@0 | 97 | width, height)); |
michael@0 | 98 | SK_GL(*this, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, |
michael@0 | 99 | GR_GL_DEPTH_ATTACHMENT, |
michael@0 | 100 | GR_GL_RENDERBUFFER, |
michael@0 | 101 | fDepthStencilBufferID)); |
michael@0 | 102 | } else { |
michael@0 | 103 | GrGLenum format = kGLES_GrGLStandard == this->gl()->fStandard ? GR_GL_STENCIL_INDEX8 : |
michael@0 | 104 | GR_GL_STENCIL_INDEX; |
michael@0 | 105 | SK_GL(*this, RenderbufferStorage(GR_GL_RENDERBUFFER, |
michael@0 | 106 | format, |
michael@0 | 107 | width, height)); |
michael@0 | 108 | } |
michael@0 | 109 | SK_GL(*this, FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, |
michael@0 | 110 | GR_GL_STENCIL_ATTACHMENT, |
michael@0 | 111 | GR_GL_RENDERBUFFER, |
michael@0 | 112 | fDepthStencilBufferID)); |
michael@0 | 113 | SK_GL(*this, Viewport(0, 0, width, height)); |
michael@0 | 114 | SK_GL(*this, ClearStencil(0)); |
michael@0 | 115 | SK_GL(*this, Clear(GR_GL_STENCIL_BUFFER_BIT)); |
michael@0 | 116 | |
michael@0 | 117 | SK_GL_RET(*this, error, GetError()); |
michael@0 | 118 | GrGLenum status; |
michael@0 | 119 | SK_GL_RET(*this, status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); |
michael@0 | 120 | |
michael@0 | 121 | if (GR_GL_FRAMEBUFFER_COMPLETE != status || |
michael@0 | 122 | GR_GL_NO_ERROR != error) { |
michael@0 | 123 | fFBO = 0; |
michael@0 | 124 | fColorBufferID = 0; |
michael@0 | 125 | fDepthStencilBufferID = 0; |
michael@0 | 126 | fGL->unref(); |
michael@0 | 127 | fGL = NULL; |
michael@0 | 128 | this->destroyGLContext(); |
michael@0 | 129 | return false; |
michael@0 | 130 | } else { |
michael@0 | 131 | return true; |
michael@0 | 132 | } |
michael@0 | 133 | } |
michael@0 | 134 | return false; |
michael@0 | 135 | } |