gfx/skia/trunk/src/core/SkAAClip.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.

     2 /*
     3  * Copyright 2011 Google Inc.
     4  *
     5  * Use of this source code is governed by a BSD-style license that can be
     6  * found in the LICENSE file.
     7  */
     9 #ifndef SkAAClip_DEFINED
    10 #define SkAAClip_DEFINED
    12 #include "SkBlitter.h"
    13 #include "SkRegion.h"
    15 class SkAAClip {
    16 public:
    17     SkAAClip();
    18     SkAAClip(const SkAAClip&);
    19     ~SkAAClip();
    21     SkAAClip& operator=(const SkAAClip&);
    22     friend bool operator==(const SkAAClip&, const SkAAClip&);
    23     friend bool operator!=(const SkAAClip& a, const SkAAClip& b) {
    24         return !(a == b);
    25     }
    27     void swap(SkAAClip&);
    29     bool isEmpty() const { return NULL == fRunHead; }
    30     const SkIRect& getBounds() const { return fBounds; }
    32     bool setEmpty();
    33     bool setRect(const SkIRect&);
    34     bool setRect(const SkRect&, bool doAA = true);
    35     bool setPath(const SkPath&, const SkRegion* clip = NULL, bool doAA = true);
    36     bool setRegion(const SkRegion&);
    37     bool set(const SkAAClip&);
    39     bool op(const SkAAClip&, const SkAAClip&, SkRegion::Op);
    41     // Helpers for op()
    42     bool op(const SkIRect&, SkRegion::Op);
    43     bool op(const SkRect&, SkRegion::Op, bool doAA);
    44     bool op(const SkAAClip&, SkRegion::Op);
    46     bool translate(int dx, int dy, SkAAClip* dst) const;
    47     bool translate(int dx, int dy) {
    48         return this->translate(dx, dy, this);
    49     }
    51     /**
    52      *  Allocates a mask the size of the aaclip, and expands its data into
    53      *  the mask, using kA8_Format
    54      */
    55     void copyToMask(SkMask*) const;
    57     // called internally
    59     bool quickContains(int left, int top, int right, int bottom) const;
    60     bool quickContains(const SkIRect& r) const {
    61         return this->quickContains(r.fLeft, r.fTop, r.fRight, r.fBottom);
    62     }
    64     const uint8_t* findRow(int y, int* lastYForRow = NULL) const;
    65     const uint8_t* findX(const uint8_t data[], int x, int* initialCount = NULL) const;
    67     class Iter;
    68     struct RunHead;
    69     struct YOffset;
    70     class Builder;
    72 #ifdef SK_DEBUG
    73     void validate() const;
    74 #else
    75     void validate() const {}
    76 #endif
    78 private:
    79     SkIRect  fBounds;
    80     RunHead* fRunHead;
    82     void freeRuns();
    83     bool trimBounds();
    84     bool trimTopBottom();
    85     bool trimLeftRight();
    87     friend class Builder;
    88     class BuilderBlitter;
    89     friend class BuilderBlitter;
    90 };
    92 ///////////////////////////////////////////////////////////////////////////////
    94 class SkAAClipBlitter : public SkBlitter {
    95 public:
    96     SkAAClipBlitter() : fScanlineScratch(NULL) {}
    97     virtual ~SkAAClipBlitter();
    99     void init(SkBlitter* blitter, const SkAAClip* aaclip) {
   100         SkASSERT(aaclip && !aaclip->isEmpty());
   101         fBlitter = blitter;
   102         fAAClip = aaclip;
   103         fAAClipBounds = aaclip->getBounds();
   104     }
   106     virtual void blitH(int x, int y, int width) SK_OVERRIDE;
   107     virtual void blitAntiH(int x, int y, const SkAlpha[],
   108                            const int16_t runs[]) SK_OVERRIDE;
   109     virtual void blitV(int x, int y, int height, SkAlpha alpha) SK_OVERRIDE;
   110     virtual void blitRect(int x, int y, int width, int height) SK_OVERRIDE;
   111     virtual void blitMask(const SkMask&, const SkIRect& clip) SK_OVERRIDE;
   112     virtual const SkBitmap* justAnOpaqueColor(uint32_t* value) SK_OVERRIDE;
   114 private:
   115     SkBlitter*      fBlitter;
   116     const SkAAClip* fAAClip;
   117     SkIRect         fAAClipBounds;
   119     // point into fScanlineScratch
   120     int16_t*        fRuns;
   121     SkAlpha*        fAA;
   123     enum {
   124         kSize = 32 * 32
   125     };
   126     SkAutoSMalloc<kSize> fGrayMaskScratch;  // used for blitMask
   127     void* fScanlineScratch;  // enough for a mask at 32bit, or runs+aa
   129     void ensureRunsAndAA();
   130 };
   132 #endif

mercurial