gfx/skia/trunk/src/gpu/gl/GrGLRenderTarget.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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 * Copyright 2011 Google Inc.
michael@0 3 *
michael@0 4 * Use of this source code is governed by a BSD-style license that can be
michael@0 5 * found in the LICENSE file.
michael@0 6 */
michael@0 7
michael@0 8 #include "GrGLRenderTarget.h"
michael@0 9
michael@0 10 #include "GrGpuGL.h"
michael@0 11
michael@0 12 #define GPUGL static_cast<GrGpuGL*>(getGpu())
michael@0 13
michael@0 14 #define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X)
michael@0 15
michael@0 16 void GrGLRenderTarget::init(const Desc& desc,
michael@0 17 const GrGLIRect& viewport,
michael@0 18 GrGLTexID* texID) {
michael@0 19 fRTFBOID = desc.fRTFBOID;
michael@0 20 fTexFBOID = desc.fTexFBOID;
michael@0 21 fMSColorRenderbufferID = desc.fMSColorRenderbufferID;
michael@0 22 fViewport = viewport;
michael@0 23 fTexIDObj.reset(SkSafeRef(texID));
michael@0 24 }
michael@0 25
michael@0 26 namespace {
michael@0 27 GrTextureDesc MakeDesc(GrTextureFlags flags,
michael@0 28 int width, int height,
michael@0 29 GrPixelConfig config, int sampleCnt,
michael@0 30 GrSurfaceOrigin origin) {
michael@0 31 GrTextureDesc temp;
michael@0 32 temp.fFlags = flags;
michael@0 33 temp.fWidth = width;
michael@0 34 temp.fHeight = height;
michael@0 35 temp.fConfig = config;
michael@0 36 temp.fSampleCnt = sampleCnt;
michael@0 37 temp.fOrigin = origin;
michael@0 38 return temp;
michael@0 39 }
michael@0 40
michael@0 41 };
michael@0 42
michael@0 43 GrGLRenderTarget::GrGLRenderTarget(GrGpuGL* gpu,
michael@0 44 const Desc& desc,
michael@0 45 const GrGLIRect& viewport,
michael@0 46 GrGLTexID* texID,
michael@0 47 GrGLTexture* texture)
michael@0 48 : INHERITED(gpu,
michael@0 49 desc.fIsWrapped,
michael@0 50 texture,
michael@0 51 MakeDesc(kNone_GrTextureFlags,
michael@0 52 viewport.fWidth, viewport.fHeight,
michael@0 53 desc.fConfig, desc.fSampleCnt,
michael@0 54 desc.fOrigin)) {
michael@0 55 SkASSERT(NULL != texID);
michael@0 56 SkASSERT(NULL != texture);
michael@0 57 // FBO 0 can't also be a texture, right?
michael@0 58 SkASSERT(0 != desc.fRTFBOID);
michael@0 59 SkASSERT(0 != desc.fTexFBOID);
michael@0 60
michael@0 61 // we assume this is true, TODO: get rid of viewport as a param.
michael@0 62 SkASSERT(viewport.fWidth == texture->width());
michael@0 63 SkASSERT(viewport.fHeight == texture->height());
michael@0 64
michael@0 65 this->init(desc, viewport, texID);
michael@0 66 }
michael@0 67
michael@0 68 GrGLRenderTarget::GrGLRenderTarget(GrGpuGL* gpu,
michael@0 69 const Desc& desc,
michael@0 70 const GrGLIRect& viewport)
michael@0 71 : INHERITED(gpu,
michael@0 72 desc.fIsWrapped,
michael@0 73 NULL,
michael@0 74 MakeDesc(kNone_GrTextureFlags,
michael@0 75 viewport.fWidth, viewport.fHeight,
michael@0 76 desc.fConfig, desc.fSampleCnt,
michael@0 77 desc.fOrigin)) {
michael@0 78 this->init(desc, viewport, NULL);
michael@0 79 }
michael@0 80
michael@0 81 void GrGLRenderTarget::onRelease() {
michael@0 82 GPUGL->notifyRenderTargetDelete(this);
michael@0 83 if (!this->isWrapped()) {
michael@0 84 if (fTexFBOID) {
michael@0 85 GL_CALL(DeleteFramebuffers(1, &fTexFBOID));
michael@0 86 }
michael@0 87 if (fRTFBOID && fRTFBOID != fTexFBOID) {
michael@0 88 GL_CALL(DeleteFramebuffers(1, &fRTFBOID));
michael@0 89 }
michael@0 90 if (fMSColorRenderbufferID) {
michael@0 91 GL_CALL(DeleteRenderbuffers(1, &fMSColorRenderbufferID));
michael@0 92 }
michael@0 93 }
michael@0 94 fRTFBOID = 0;
michael@0 95 fTexFBOID = 0;
michael@0 96 fMSColorRenderbufferID = 0;
michael@0 97 fTexIDObj.reset(NULL);
michael@0 98 INHERITED::onRelease();
michael@0 99 }
michael@0 100
michael@0 101 void GrGLRenderTarget::onAbandon() {
michael@0 102 fRTFBOID = 0;
michael@0 103 fTexFBOID = 0;
michael@0 104 fMSColorRenderbufferID = 0;
michael@0 105 if (NULL != fTexIDObj.get()) {
michael@0 106 fTexIDObj->abandon();
michael@0 107 fTexIDObj.reset(NULL);
michael@0 108 }
michael@0 109 INHERITED::onAbandon();
michael@0 110 }

mercurial