gfx/skia/trunk/src/gpu/GrSWMaskHelper.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 2012 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 GrSWMaskHelper_DEFINED
michael@0 9 #define GrSWMaskHelper_DEFINED
michael@0 10
michael@0 11 #include "GrColor.h"
michael@0 12 #include "GrDrawState.h"
michael@0 13 #include "SkBitmap.h"
michael@0 14 #include "SkDraw.h"
michael@0 15 #include "SkMatrix.h"
michael@0 16 #include "SkRasterClip.h"
michael@0 17 #include "SkRegion.h"
michael@0 18 #include "SkTypes.h"
michael@0 19
michael@0 20 class GrAutoScratchTexture;
michael@0 21 class GrContext;
michael@0 22 class GrTexture;
michael@0 23 class SkPath;
michael@0 24 class SkStrokeRec;
michael@0 25 class GrDrawTarget;
michael@0 26
michael@0 27 /**
michael@0 28 * The GrSWMaskHelper helps generate clip masks using the software rendering
michael@0 29 * path. It is intended to be used as:
michael@0 30 *
michael@0 31 * GrSWMaskHelper helper(context);
michael@0 32 * helper.init(...);
michael@0 33 *
michael@0 34 * draw one or more paths/rects specifying the required boolean ops
michael@0 35 *
michael@0 36 * toTexture(); // to get it from the internal bitmap to the GPU
michael@0 37 *
michael@0 38 * The result of this process will be the final mask (on the GPU) in the
michael@0 39 * upper left hand corner of the texture.
michael@0 40 */
michael@0 41 class GrSWMaskHelper : public SkNoncopyable {
michael@0 42 public:
michael@0 43 GrSWMaskHelper(GrContext* context)
michael@0 44 : fContext(context) {
michael@0 45 }
michael@0 46
michael@0 47 // set up the internal state in preparation for draws. Since many masks
michael@0 48 // may be accumulated in the helper during creation, "resultBounds"
michael@0 49 // allows the caller to specify the region of interest - to limit the
michael@0 50 // amount of work.
michael@0 51 bool init(const SkIRect& resultBounds, const SkMatrix* matrix);
michael@0 52
michael@0 53 // Draw a single rect into the accumulation bitmap using the specified op
michael@0 54 void draw(const SkRect& rect, SkRegion::Op op,
michael@0 55 bool antiAlias, uint8_t alpha);
michael@0 56
michael@0 57 // Draw a single path into the accumuation bitmap using the specified op
michael@0 58 void draw(const SkPath& path, const SkStrokeRec& stroke, SkRegion::Op op,
michael@0 59 bool antiAlias, uint8_t alpha);
michael@0 60
michael@0 61 // Helper function to get a scratch texture suitable for capturing the
michael@0 62 // result (i.e., right size & format)
michael@0 63 bool getTexture(GrAutoScratchTexture* texture);
michael@0 64
michael@0 65 // Move the mask generation results from the internal bitmap to the gpu.
michael@0 66 void toTexture(GrTexture* texture);
michael@0 67
michael@0 68 // Reset the internal bitmap
michael@0 69 void clear(uint8_t alpha) {
michael@0 70 fBM.eraseColor(SkColorSetARGB(alpha, alpha, alpha, alpha));
michael@0 71 }
michael@0 72
michael@0 73 // Canonical usage utility that draws a single path and uploads it
michael@0 74 // to the GPU. The result is returned in "result".
michael@0 75 static GrTexture* DrawPathMaskToTexture(GrContext* context,
michael@0 76 const SkPath& path,
michael@0 77 const SkStrokeRec& stroke,
michael@0 78 const SkIRect& resultBounds,
michael@0 79 bool antiAlias,
michael@0 80 SkMatrix* matrix);
michael@0 81
michael@0 82 // This utility routine is used to add a path's mask to some other draw.
michael@0 83 // The ClipMaskManager uses it to accumulate clip masks while the
michael@0 84 // GrSoftwarePathRenderer uses it to fulfill a drawPath call.
michael@0 85 // It draws with "texture" as a path mask into "target" using "rect" as
michael@0 86 // geometry and the current drawState. The current drawState is altered to
michael@0 87 // accommodate the mask.
michael@0 88 // Note that this method assumes that the GrPaint::kTotalStages slot in
michael@0 89 // the draw state can be used to hold the mask texture stage.
michael@0 90 // This method is really only intended to be used with the
michael@0 91 // output of DrawPathMaskToTexture.
michael@0 92 static void DrawToTargetWithPathMask(GrTexture* texture,
michael@0 93 GrDrawTarget* target,
michael@0 94 const SkIRect& rect);
michael@0 95
michael@0 96 protected:
michael@0 97 private:
michael@0 98 GrContext* fContext;
michael@0 99 SkMatrix fMatrix;
michael@0 100 SkBitmap fBM;
michael@0 101 SkDraw fDraw;
michael@0 102 SkRasterClip fRasterClip;
michael@0 103
michael@0 104 typedef SkNoncopyable INHERITED;
michael@0 105 };
michael@0 106
michael@0 107 #endif // GrSWMaskHelper_DEFINED

mercurial