gfx/skia/trunk/src/gpu/GrTextureAccess.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 2012 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 "GrTextureAccess.h"
michael@0 9 #include "GrColor.h"
michael@0 10 #include "GrTexture.h"
michael@0 11
michael@0 12 GrTextureAccess::GrTextureAccess() {
michael@0 13 #ifdef SK_DEBUG
michael@0 14 memcpy(fSwizzle, "void", 5);
michael@0 15 fSwizzleMask = 0xbeeffeed;
michael@0 16 #endif
michael@0 17 }
michael@0 18
michael@0 19 GrTextureAccess::GrTextureAccess(GrTexture* texture, const GrTextureParams& params) {
michael@0 20 this->reset(texture, params);
michael@0 21 }
michael@0 22
michael@0 23 GrTextureAccess::GrTextureAccess(GrTexture* texture,
michael@0 24 GrTextureParams::FilterMode filterMode,
michael@0 25 SkShader::TileMode tileXAndY) {
michael@0 26 this->reset(texture, filterMode, tileXAndY);
michael@0 27 }
michael@0 28
michael@0 29 GrTextureAccess::GrTextureAccess(GrTexture* texture,
michael@0 30 const char* swizzle,
michael@0 31 const GrTextureParams& params) {
michael@0 32 this->reset(texture, swizzle, params);
michael@0 33 }
michael@0 34
michael@0 35 GrTextureAccess::GrTextureAccess(GrTexture* texture,
michael@0 36 const char* swizzle,
michael@0 37 GrTextureParams::FilterMode filterMode,
michael@0 38 SkShader::TileMode tileXAndY) {
michael@0 39 this->reset(texture, swizzle, filterMode, tileXAndY);
michael@0 40 }
michael@0 41
michael@0 42 void GrTextureAccess::reset(GrTexture* texture,
michael@0 43 const char* swizzle,
michael@0 44 const GrTextureParams& params) {
michael@0 45 SkASSERT(NULL != texture);
michael@0 46 SkASSERT(strlen(swizzle) >= 1 && strlen(swizzle) <= 4);
michael@0 47
michael@0 48 fParams = params;
michael@0 49 fTexture.reset(SkRef(texture));
michael@0 50 this->setSwizzle(swizzle);
michael@0 51 }
michael@0 52
michael@0 53 void GrTextureAccess::reset(GrTexture* texture,
michael@0 54 const char* swizzle,
michael@0 55 GrTextureParams::FilterMode filterMode,
michael@0 56 SkShader::TileMode tileXAndY) {
michael@0 57 SkASSERT(NULL != texture);
michael@0 58 SkASSERT(strlen(swizzle) >= 1 && strlen(swizzle) <= 4);
michael@0 59
michael@0 60 fParams.reset(tileXAndY, filterMode);
michael@0 61 fTexture.reset(SkRef(texture));
michael@0 62 this->setSwizzle(swizzle);
michael@0 63 }
michael@0 64
michael@0 65 void GrTextureAccess::reset(GrTexture* texture,
michael@0 66 const GrTextureParams& params) {
michael@0 67 SkASSERT(NULL != texture);
michael@0 68 fTexture.reset(SkRef(texture));
michael@0 69 fParams = params;
michael@0 70 memcpy(fSwizzle, "rgba", 5);
michael@0 71 fSwizzleMask = kRGBA_GrColorComponentFlags;
michael@0 72 }
michael@0 73
michael@0 74 void GrTextureAccess::reset(GrTexture* texture,
michael@0 75 GrTextureParams::FilterMode filterMode,
michael@0 76 SkShader::TileMode tileXAndY) {
michael@0 77 SkASSERT(NULL != texture);
michael@0 78 fTexture.reset(SkRef(texture));
michael@0 79 fParams.reset(tileXAndY, filterMode);
michael@0 80 memcpy(fSwizzle, "rgba", 5);
michael@0 81 fSwizzleMask = kRGBA_GrColorComponentFlags;
michael@0 82 }
michael@0 83
michael@0 84 void GrTextureAccess::setSwizzle(const char* swizzle) {
michael@0 85 fSwizzleMask = 0;
michael@0 86 memset(fSwizzle, '\0', 5);
michael@0 87 for (int i = 0; i < 4 && '\0' != swizzle[i]; ++i) {
michael@0 88 fSwizzle[i] = swizzle[i];
michael@0 89 switch (swizzle[i]) {
michael@0 90 case 'r':
michael@0 91 fSwizzleMask |= kR_GrColorComponentFlag;
michael@0 92 break;
michael@0 93 case 'g':
michael@0 94 fSwizzleMask |= kG_GrColorComponentFlag;
michael@0 95 break;
michael@0 96 case 'b':
michael@0 97 fSwizzleMask |= kB_GrColorComponentFlag;
michael@0 98 break;
michael@0 99 case 'a':
michael@0 100 fSwizzleMask |= kA_GrColorComponentFlag;
michael@0 101 break;
michael@0 102 default:
michael@0 103 GrCrash("Unexpected swizzle string character.");
michael@0 104 break;
michael@0 105 }
michael@0 106 }
michael@0 107 }

mercurial