gfx/skia/trunk/src/gpu/GrPlotMgr.h

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 2010 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 #ifndef GrPlotMgr_DEFINED
michael@0 9 #define GrPlotMgr_DEFINED
michael@0 10
michael@0 11 #include "GrTypes.h"
michael@0 12 #include "GrPoint.h"
michael@0 13 #include "SkTypes.h"
michael@0 14
michael@0 15 class GrPlotMgr : public SkNoncopyable {
michael@0 16 public:
michael@0 17 GrPlotMgr(int width, int height) {
michael@0 18 fDim.set(width, height);
michael@0 19 size_t needed = width * height;
michael@0 20 if (needed <= sizeof(fStorage)) {
michael@0 21 fBusy = fStorage;
michael@0 22 } else {
michael@0 23 fBusy = SkNEW_ARRAY(char, needed);
michael@0 24 }
michael@0 25 this->reset();
michael@0 26 }
michael@0 27
michael@0 28 ~GrPlotMgr() {
michael@0 29 if (fBusy != fStorage) {
michael@0 30 delete[] fBusy;
michael@0 31 }
michael@0 32 }
michael@0 33
michael@0 34 void reset() {
michael@0 35 sk_bzero(fBusy, fDim.fX * fDim.fY);
michael@0 36 }
michael@0 37
michael@0 38 bool newPlot(GrIPoint16* loc) {
michael@0 39 char* busy = fBusy;
michael@0 40 for (int y = 0; y < fDim.fY; y++) {
michael@0 41 for (int x = 0; x < fDim.fX; x++) {
michael@0 42 if (!*busy) {
michael@0 43 *busy = true;
michael@0 44 loc->set(x, y);
michael@0 45 return true;
michael@0 46 }
michael@0 47 busy++;
michael@0 48 }
michael@0 49 }
michael@0 50 return false;
michael@0 51 }
michael@0 52
michael@0 53 bool isBusy(int x, int y) const {
michael@0 54 SkASSERT((unsigned)x < (unsigned)fDim.fX);
michael@0 55 SkASSERT((unsigned)y < (unsigned)fDim.fY);
michael@0 56 return fBusy[y * fDim.fX + x] != 0;
michael@0 57 }
michael@0 58
michael@0 59 void freePlot(int x, int y) {
michael@0 60 SkASSERT((unsigned)x < (unsigned)fDim.fX);
michael@0 61 SkASSERT((unsigned)y < (unsigned)fDim.fY);
michael@0 62 fBusy[y * fDim.fX + x] = false;
michael@0 63 }
michael@0 64
michael@0 65 private:
michael@0 66 enum {
michael@0 67 STORAGE = 64
michael@0 68 };
michael@0 69 char fStorage[STORAGE];
michael@0 70 char* fBusy;
michael@0 71 GrIPoint16 fDim;
michael@0 72 };
michael@0 73
michael@0 74 #endif

mercurial