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.

     1 /*
     2  * Copyright 2010 Google Inc.
     3  *
     4  * Use of this source code is governed by a BSD-style license that can be
     5  * found in the LICENSE file.
     6  */
     8 #ifndef GrPlotMgr_DEFINED
     9 #define GrPlotMgr_DEFINED
    11 #include "GrTypes.h"
    12 #include "GrPoint.h"
    13 #include "SkTypes.h"
    15 class GrPlotMgr : public SkNoncopyable {
    16 public:
    17     GrPlotMgr(int width, int height) {
    18         fDim.set(width, height);
    19         size_t needed = width * height;
    20         if (needed <= sizeof(fStorage)) {
    21             fBusy = fStorage;
    22         } else {
    23             fBusy = SkNEW_ARRAY(char, needed);
    24         }
    25         this->reset();
    26     }
    28     ~GrPlotMgr() {
    29         if (fBusy != fStorage) {
    30             delete[] fBusy;
    31         }
    32     }
    34     void reset() {
    35         sk_bzero(fBusy, fDim.fX * fDim.fY);
    36     }
    38     bool newPlot(GrIPoint16* loc) {
    39         char* busy = fBusy;
    40         for (int y = 0; y < fDim.fY; y++) {
    41             for (int x = 0; x < fDim.fX; x++) {
    42                 if (!*busy) {
    43                     *busy = true;
    44                     loc->set(x, y);
    45                     return true;
    46                 }
    47                 busy++;
    48             }
    49         }
    50         return false;
    51     }
    53     bool isBusy(int x, int y) const {
    54         SkASSERT((unsigned)x < (unsigned)fDim.fX);
    55         SkASSERT((unsigned)y < (unsigned)fDim.fY);
    56         return fBusy[y * fDim.fX + x] != 0;
    57     }
    59     void freePlot(int x, int y) {
    60         SkASSERT((unsigned)x < (unsigned)fDim.fX);
    61         SkASSERT((unsigned)y < (unsigned)fDim.fY);
    62         fBusy[y * fDim.fX + x] = false;
    63     }
    65 private:
    66     enum {
    67         STORAGE = 64
    68     };
    69     char fStorage[STORAGE];
    70     char* fBusy;
    71     GrIPoint16  fDim;
    72 };
    74 #endif

mercurial