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 SkDraw_DEFINED |
michael@0 | 11 | #define SkDraw_DEFINED |
michael@0 | 12 | |
michael@0 | 13 | #include "SkCanvas.h" |
michael@0 | 14 | #include "SkMask.h" |
michael@0 | 15 | #include "SkPaint.h" |
michael@0 | 16 | |
michael@0 | 17 | class SkBitmap; |
michael@0 | 18 | class SkBounder; |
michael@0 | 19 | class SkClipStack; |
michael@0 | 20 | class SkBaseDevice; |
michael@0 | 21 | class SkMatrix; |
michael@0 | 22 | class SkPath; |
michael@0 | 23 | class SkRegion; |
michael@0 | 24 | class SkRasterClip; |
michael@0 | 25 | struct SkDrawProcs; |
michael@0 | 26 | struct SkRect; |
michael@0 | 27 | class SkRRect; |
michael@0 | 28 | |
michael@0 | 29 | class SkDraw { |
michael@0 | 30 | public: |
michael@0 | 31 | SkDraw(); |
michael@0 | 32 | SkDraw(const SkDraw& src); |
michael@0 | 33 | |
michael@0 | 34 | void drawPaint(const SkPaint&) const; |
michael@0 | 35 | void drawPoints(SkCanvas::PointMode, size_t count, const SkPoint[], |
michael@0 | 36 | const SkPaint&, bool forceUseDevice = false) const; |
michael@0 | 37 | void drawRect(const SkRect&, const SkPaint&) const; |
michael@0 | 38 | void drawRRect(const SkRRect&, const SkPaint&) const; |
michael@0 | 39 | /** |
michael@0 | 40 | * To save on mallocs, we allow a flag that tells us that srcPath is |
michael@0 | 41 | * mutable, so that we don't have to make copies of it as we transform it. |
michael@0 | 42 | * |
michael@0 | 43 | * If prePathMatrix is not null, it should logically be applied before any |
michael@0 | 44 | * stroking or other effects. If there are no effects on the paint that |
michael@0 | 45 | * affect the geometry/rasterization, then the pre matrix can just be |
michael@0 | 46 | * pre-concated with the current matrix. |
michael@0 | 47 | */ |
michael@0 | 48 | void drawPath(const SkPath& path, const SkPaint& paint, |
michael@0 | 49 | const SkMatrix* prePathMatrix, bool pathIsMutable) const { |
michael@0 | 50 | this->drawPath(path, paint, prePathMatrix, pathIsMutable, false); |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | void drawPath(const SkPath& path, const SkPaint& paint) const { |
michael@0 | 54 | this->drawPath(path, paint, NULL, false, false); |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | void drawBitmap(const SkBitmap&, const SkMatrix&, const SkPaint&) const; |
michael@0 | 58 | void drawSprite(const SkBitmap&, int x, int y, const SkPaint&) const; |
michael@0 | 59 | void drawText(const char text[], size_t byteLength, SkScalar x, |
michael@0 | 60 | SkScalar y, const SkPaint& paint) const; |
michael@0 | 61 | void drawPosText(const char text[], size_t byteLength, |
michael@0 | 62 | const SkScalar pos[], SkScalar constY, |
michael@0 | 63 | int scalarsPerPosition, const SkPaint& paint) const; |
michael@0 | 64 | void drawTextOnPath(const char text[], size_t byteLength, |
michael@0 | 65 | const SkPath&, const SkMatrix*, const SkPaint&) const; |
michael@0 | 66 | void drawVertices(SkCanvas::VertexMode mode, int count, |
michael@0 | 67 | const SkPoint vertices[], const SkPoint textures[], |
michael@0 | 68 | const SkColor colors[], SkXfermode* xmode, |
michael@0 | 69 | const uint16_t indices[], int ptCount, |
michael@0 | 70 | const SkPaint& paint) const; |
michael@0 | 71 | |
michael@0 | 72 | /** |
michael@0 | 73 | * Overwrite the target with the path's coverage (i.e. its mask). |
michael@0 | 74 | * Will overwrite the entire device, so it need not be zero'd first. |
michael@0 | 75 | * |
michael@0 | 76 | * Only device A8 is supported right now. |
michael@0 | 77 | */ |
michael@0 | 78 | void drawPathCoverage(const SkPath& src, const SkPaint& paint) const { |
michael@0 | 79 | this->drawPath(src, paint, NULL, false, true); |
michael@0 | 80 | } |
michael@0 | 81 | |
michael@0 | 82 | /** Helper function that creates a mask from a path and an optional maskfilter. |
michael@0 | 83 | Note however, that the resulting mask will not have been actually filtered, |
michael@0 | 84 | that must be done afterwards (by calling filterMask). The maskfilter is provided |
michael@0 | 85 | solely to assist in computing the mask's bounds (if the mode requests that). |
michael@0 | 86 | */ |
michael@0 | 87 | static bool DrawToMask(const SkPath& devPath, const SkIRect* clipBounds, |
michael@0 | 88 | const SkMaskFilter*, const SkMatrix* filterMatrix, |
michael@0 | 89 | SkMask* mask, SkMask::CreateMode mode, |
michael@0 | 90 | SkPaint::Style style); |
michael@0 | 91 | |
michael@0 | 92 | enum RectType { |
michael@0 | 93 | kHair_RectType, |
michael@0 | 94 | kFill_RectType, |
michael@0 | 95 | kStroke_RectType, |
michael@0 | 96 | kPath_RectType |
michael@0 | 97 | }; |
michael@0 | 98 | |
michael@0 | 99 | /** |
michael@0 | 100 | * Based on the paint's style, strokeWidth, and the matrix, classify how |
michael@0 | 101 | * to draw the rect. If no special-case is available, returns |
michael@0 | 102 | * kPath_RectType. |
michael@0 | 103 | * |
michael@0 | 104 | * Iff RectType == kStroke_RectType, then strokeSize is set to the device |
michael@0 | 105 | * width and height of the stroke. |
michael@0 | 106 | */ |
michael@0 | 107 | static RectType ComputeRectType(const SkPaint&, const SkMatrix&, |
michael@0 | 108 | SkPoint* strokeSize); |
michael@0 | 109 | |
michael@0 | 110 | static bool ShouldDrawTextAsPaths(const SkPaint&, const SkMatrix&); |
michael@0 | 111 | void drawText_asPaths(const char text[], size_t byteLength, |
michael@0 | 112 | SkScalar x, SkScalar y, const SkPaint&) const; |
michael@0 | 113 | void drawPosText_asPaths(const char text[], size_t byteLength, |
michael@0 | 114 | const SkScalar pos[], SkScalar constY, |
michael@0 | 115 | int scalarsPerPosition, const SkPaint&) const; |
michael@0 | 116 | |
michael@0 | 117 | private: |
michael@0 | 118 | void drawDevMask(const SkMask& mask, const SkPaint&) const; |
michael@0 | 119 | void drawBitmapAsMask(const SkBitmap&, const SkPaint&) const; |
michael@0 | 120 | |
michael@0 | 121 | void drawPath(const SkPath&, const SkPaint&, const SkMatrix* preMatrix, |
michael@0 | 122 | bool pathIsMutable, bool drawCoverage) const; |
michael@0 | 123 | |
michael@0 | 124 | /** |
michael@0 | 125 | * Return the current clip bounds, in local coordinates, with slop to account |
michael@0 | 126 | * for antialiasing or hairlines (i.e. device-bounds outset by 1, and then |
michael@0 | 127 | * run through the inverse of the matrix). |
michael@0 | 128 | * |
michael@0 | 129 | * If the matrix cannot be inverted, or the current clip is empty, return |
michael@0 | 130 | * false and ignore bounds parameter. |
michael@0 | 131 | */ |
michael@0 | 132 | bool SK_WARN_UNUSED_RESULT |
michael@0 | 133 | computeConservativeLocalClipBounds(SkRect* bounds) const; |
michael@0 | 134 | |
michael@0 | 135 | public: |
michael@0 | 136 | const SkBitmap* fBitmap; // required |
michael@0 | 137 | const SkMatrix* fMatrix; // required |
michael@0 | 138 | const SkRegion* fClip; // DEPRECATED |
michael@0 | 139 | const SkRasterClip* fRC; // required |
michael@0 | 140 | |
michael@0 | 141 | const SkClipStack* fClipStack; // optional |
michael@0 | 142 | SkBaseDevice* fDevice; // optional |
michael@0 | 143 | SkBounder* fBounder; // optional |
michael@0 | 144 | SkDrawProcs* fProcs; // optional |
michael@0 | 145 | |
michael@0 | 146 | #ifdef SK_DEBUG |
michael@0 | 147 | void validate() const; |
michael@0 | 148 | #else |
michael@0 | 149 | void validate() const {} |
michael@0 | 150 | #endif |
michael@0 | 151 | }; |
michael@0 | 152 | |
michael@0 | 153 | #endif |