Sat, 03 Jan 2015 20:18:00 +0100
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 | /* |
michael@0 | 3 | * Copyright 2006 The Android Open Source Project |
michael@0 | 4 | * |
michael@0 | 5 | * Use of this source code is governed by a BSD-style license that can be |
michael@0 | 6 | * found in the LICENSE file. |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | |
michael@0 | 10 | #ifndef SkBlitter_DEFINED |
michael@0 | 11 | #define SkBlitter_DEFINED |
michael@0 | 12 | |
michael@0 | 13 | #include "SkBitmap.h" |
michael@0 | 14 | #include "SkBitmapProcShader.h" |
michael@0 | 15 | #include "SkMask.h" |
michael@0 | 16 | #include "SkMatrix.h" |
michael@0 | 17 | #include "SkPaint.h" |
michael@0 | 18 | #include "SkRefCnt.h" |
michael@0 | 19 | #include "SkRegion.h" |
michael@0 | 20 | #include "SkShader.h" |
michael@0 | 21 | #include "SkSmallAllocator.h" |
michael@0 | 22 | |
michael@0 | 23 | /** SkBlitter and its subclasses are responsible for actually writing pixels |
michael@0 | 24 | into memory. Besides efficiency, they handle clipping and antialiasing. |
michael@0 | 25 | */ |
michael@0 | 26 | class SkBlitter { |
michael@0 | 27 | public: |
michael@0 | 28 | virtual ~SkBlitter(); |
michael@0 | 29 | |
michael@0 | 30 | /// Blit a horizontal run of one or more pixels. |
michael@0 | 31 | virtual void blitH(int x, int y, int width); |
michael@0 | 32 | /// Blit a horizontal run of antialiased pixels; runs[] is a *sparse* |
michael@0 | 33 | /// zero-terminated run-length encoding of spans of constant alpha values. |
michael@0 | 34 | virtual void blitAntiH(int x, int y, const SkAlpha antialias[], |
michael@0 | 35 | const int16_t runs[]); |
michael@0 | 36 | /// Blit a vertical run of pixels with a constant alpha value. |
michael@0 | 37 | virtual void blitV(int x, int y, int height, SkAlpha alpha); |
michael@0 | 38 | /// Blit a solid rectangle one or more pixels wide. |
michael@0 | 39 | virtual void blitRect(int x, int y, int width, int height); |
michael@0 | 40 | /** Blit a rectangle with one alpha-blended column on the left, |
michael@0 | 41 | width (zero or more) opaque pixels, and one alpha-blended column |
michael@0 | 42 | on the right. |
michael@0 | 43 | The result will always be at least two pixels wide. |
michael@0 | 44 | */ |
michael@0 | 45 | virtual void blitAntiRect(int x, int y, int width, int height, |
michael@0 | 46 | SkAlpha leftAlpha, SkAlpha rightAlpha); |
michael@0 | 47 | /// Blit a pattern of pixels defined by a rectangle-clipped mask; |
michael@0 | 48 | /// typically used for text. |
michael@0 | 49 | virtual void blitMask(const SkMask&, const SkIRect& clip); |
michael@0 | 50 | |
michael@0 | 51 | /** If the blitter just sets a single value for each pixel, return the |
michael@0 | 52 | bitmap it draws into, and assign value. If not, return NULL and ignore |
michael@0 | 53 | the value parameter. |
michael@0 | 54 | */ |
michael@0 | 55 | virtual const SkBitmap* justAnOpaqueColor(uint32_t* value); |
michael@0 | 56 | |
michael@0 | 57 | /** |
michael@0 | 58 | * Special method just to identify the null blitter, which is returned |
michael@0 | 59 | * from Choose() if the request cannot be fulfilled. Default impl |
michael@0 | 60 | * returns false. |
michael@0 | 61 | */ |
michael@0 | 62 | virtual bool isNullBlitter() const; |
michael@0 | 63 | |
michael@0 | 64 | ///@name non-virtual helpers |
michael@0 | 65 | void blitMaskRegion(const SkMask& mask, const SkRegion& clip); |
michael@0 | 66 | void blitRectRegion(const SkIRect& rect, const SkRegion& clip); |
michael@0 | 67 | void blitRegion(const SkRegion& clip); |
michael@0 | 68 | ///@} |
michael@0 | 69 | |
michael@0 | 70 | /** @name Factories |
michael@0 | 71 | Return the correct blitter to use given the specified context. |
michael@0 | 72 | */ |
michael@0 | 73 | static SkBlitter* Choose(const SkBitmap& device, |
michael@0 | 74 | const SkMatrix& matrix, |
michael@0 | 75 | const SkPaint& paint, |
michael@0 | 76 | SkTBlitterAllocator*, |
michael@0 | 77 | bool drawCoverage = false); |
michael@0 | 78 | |
michael@0 | 79 | static SkBlitter* ChooseSprite(const SkBitmap& device, |
michael@0 | 80 | const SkPaint&, |
michael@0 | 81 | const SkBitmap& src, |
michael@0 | 82 | int left, int top, |
michael@0 | 83 | SkTBlitterAllocator*); |
michael@0 | 84 | ///@} |
michael@0 | 85 | |
michael@0 | 86 | private: |
michael@0 | 87 | }; |
michael@0 | 88 | |
michael@0 | 89 | /** This blitter silently never draws anything. |
michael@0 | 90 | */ |
michael@0 | 91 | class SkNullBlitter : public SkBlitter { |
michael@0 | 92 | public: |
michael@0 | 93 | virtual void blitH(int x, int y, int width) SK_OVERRIDE; |
michael@0 | 94 | virtual void blitAntiH(int x, int y, const SkAlpha[], |
michael@0 | 95 | const int16_t runs[]) SK_OVERRIDE; |
michael@0 | 96 | virtual void blitV(int x, int y, int height, SkAlpha alpha) SK_OVERRIDE; |
michael@0 | 97 | virtual void blitRect(int x, int y, int width, int height) SK_OVERRIDE; |
michael@0 | 98 | virtual void blitMask(const SkMask&, const SkIRect& clip) SK_OVERRIDE; |
michael@0 | 99 | virtual const SkBitmap* justAnOpaqueColor(uint32_t* value) SK_OVERRIDE; |
michael@0 | 100 | virtual bool isNullBlitter() const SK_OVERRIDE; |
michael@0 | 101 | }; |
michael@0 | 102 | |
michael@0 | 103 | /** Wraps another (real) blitter, and ensures that the real blitter is only |
michael@0 | 104 | called with coordinates that have been clipped by the specified clipRect. |
michael@0 | 105 | This means the caller need not perform the clipping ahead of time. |
michael@0 | 106 | */ |
michael@0 | 107 | class SkRectClipBlitter : public SkBlitter { |
michael@0 | 108 | public: |
michael@0 | 109 | void init(SkBlitter* blitter, const SkIRect& clipRect) { |
michael@0 | 110 | SkASSERT(!clipRect.isEmpty()); |
michael@0 | 111 | fBlitter = blitter; |
michael@0 | 112 | fClipRect = clipRect; |
michael@0 | 113 | } |
michael@0 | 114 | |
michael@0 | 115 | virtual void blitH(int x, int y, int width) SK_OVERRIDE; |
michael@0 | 116 | virtual void blitAntiH(int x, int y, const SkAlpha[], |
michael@0 | 117 | const int16_t runs[]) SK_OVERRIDE; |
michael@0 | 118 | virtual void blitV(int x, int y, int height, SkAlpha alpha) SK_OVERRIDE; |
michael@0 | 119 | virtual void blitRect(int x, int y, int width, int height) SK_OVERRIDE; |
michael@0 | 120 | virtual void blitAntiRect(int x, int y, int width, int height, |
michael@0 | 121 | SkAlpha leftAlpha, SkAlpha rightAlpha) SK_OVERRIDE; |
michael@0 | 122 | virtual void blitMask(const SkMask&, const SkIRect& clip) SK_OVERRIDE; |
michael@0 | 123 | virtual const SkBitmap* justAnOpaqueColor(uint32_t* value) SK_OVERRIDE; |
michael@0 | 124 | |
michael@0 | 125 | private: |
michael@0 | 126 | SkBlitter* fBlitter; |
michael@0 | 127 | SkIRect fClipRect; |
michael@0 | 128 | }; |
michael@0 | 129 | |
michael@0 | 130 | /** Wraps another (real) blitter, and ensures that the real blitter is only |
michael@0 | 131 | called with coordinates that have been clipped by the specified clipRgn. |
michael@0 | 132 | This means the caller need not perform the clipping ahead of time. |
michael@0 | 133 | */ |
michael@0 | 134 | class SkRgnClipBlitter : public SkBlitter { |
michael@0 | 135 | public: |
michael@0 | 136 | void init(SkBlitter* blitter, const SkRegion* clipRgn) { |
michael@0 | 137 | SkASSERT(clipRgn && !clipRgn->isEmpty()); |
michael@0 | 138 | fBlitter = blitter; |
michael@0 | 139 | fRgn = clipRgn; |
michael@0 | 140 | } |
michael@0 | 141 | |
michael@0 | 142 | virtual void blitH(int x, int y, int width) SK_OVERRIDE; |
michael@0 | 143 | virtual void blitAntiH(int x, int y, const SkAlpha[], |
michael@0 | 144 | const int16_t runs[]) SK_OVERRIDE; |
michael@0 | 145 | virtual void blitV(int x, int y, int height, SkAlpha alpha) SK_OVERRIDE; |
michael@0 | 146 | virtual void blitRect(int x, int y, int width, int height) SK_OVERRIDE; |
michael@0 | 147 | virtual void blitAntiRect(int x, int y, int width, int height, |
michael@0 | 148 | SkAlpha leftAlpha, SkAlpha rightAlpha) SK_OVERRIDE; |
michael@0 | 149 | virtual void blitMask(const SkMask&, const SkIRect& clip) SK_OVERRIDE; |
michael@0 | 150 | virtual const SkBitmap* justAnOpaqueColor(uint32_t* value) SK_OVERRIDE; |
michael@0 | 151 | |
michael@0 | 152 | private: |
michael@0 | 153 | SkBlitter* fBlitter; |
michael@0 | 154 | const SkRegion* fRgn; |
michael@0 | 155 | }; |
michael@0 | 156 | |
michael@0 | 157 | /** Factory to set up the appropriate most-efficient wrapper blitter |
michael@0 | 158 | to apply a clip. Returns a pointer to a member, so lifetime must |
michael@0 | 159 | be managed carefully. |
michael@0 | 160 | */ |
michael@0 | 161 | class SkBlitterClipper { |
michael@0 | 162 | public: |
michael@0 | 163 | SkBlitter* apply(SkBlitter* blitter, const SkRegion* clip, |
michael@0 | 164 | const SkIRect* bounds = NULL); |
michael@0 | 165 | |
michael@0 | 166 | private: |
michael@0 | 167 | SkNullBlitter fNullBlitter; |
michael@0 | 168 | SkRectClipBlitter fRectBlitter; |
michael@0 | 169 | SkRgnClipBlitter fRgnBlitter; |
michael@0 | 170 | }; |
michael@0 | 171 | |
michael@0 | 172 | #endif |