Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: src/gpu/GrSWMaskHelper.h

Issue 2081383006: Use GrShape in GrPathRenderer. (Closed) Base URL: https://chromium.googlesource.com/skia.git@shapemembers
Patch Set: Address comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrPathRendererChain.cpp ('k') | src/gpu/GrSWMaskHelper.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef GrSWMaskHelper_DEFINED 8 #ifndef GrSWMaskHelper_DEFINED
9 #define GrSWMaskHelper_DEFINED 9 #define GrSWMaskHelper_DEFINED
10 10
11 #include "SkAutoPixmapStorage.h" 11 #include "SkAutoPixmapStorage.h"
12 #include "GrColor.h" 12 #include "GrColor.h"
13 #include "SkBitmap.h" 13 #include "SkBitmap.h"
14 #include "SkDraw.h" 14 #include "SkDraw.h"
15 #include "SkMatrix.h" 15 #include "SkMatrix.h"
16 #include "SkRasterClip.h" 16 #include "SkRasterClip.h"
17 #include "SkRegion.h" 17 #include "SkRegion.h"
18 #include "SkTypes.h" 18 #include "SkTypes.h"
19 19
20 class GrClip; 20 class GrClip;
21 class GrPaint; 21 class GrPaint;
22 class GrShape;
22 class GrTextureProvider; 23 class GrTextureProvider;
23 class GrStyle; 24 class GrStyle;
24 class GrTexture; 25 class GrTexture;
25 class SkPath;
26 class SkStrokeRec;
27 struct GrUserStencilSettings; 26 struct GrUserStencilSettings;
28 27
29 /** 28 /**
30 * The GrSWMaskHelper helps generate clip masks using the software rendering 29 * The GrSWMaskHelper helps generate clip masks using the software rendering
31 * path. It is intended to be used as: 30 * path. It is intended to be used as:
32 * 31 *
33 * GrSWMaskHelper helper(context); 32 * GrSWMaskHelper helper(context);
34 * helper.init(...); 33 * helper.init(...);
35 * 34 *
36 * draw one or more paths/rects specifying the required boolean ops 35 * draw one or more paths/rects specifying the required boolean ops
(...skipping 10 matching lines...) Expand all
47 // set up the internal state in preparation for draws. Since many masks 46 // set up the internal state in preparation for draws. Since many masks
48 // may be accumulated in the helper during creation, "resultBounds" 47 // may be accumulated in the helper during creation, "resultBounds"
49 // allows the caller to specify the region of interest - to limit the 48 // allows the caller to specify the region of interest - to limit the
50 // amount of work. 49 // amount of work.
51 bool init(const SkIRect& resultBounds, const SkMatrix* matrix); 50 bool init(const SkIRect& resultBounds, const SkMatrix* matrix);
52 51
53 // Draw a single rect into the accumulation bitmap using the specified op 52 // Draw a single rect into the accumulation bitmap using the specified op
54 void drawRect(const SkRect& rect, SkRegion::Op op, bool antiAlias, uint8_t a lpha); 53 void drawRect(const SkRect& rect, SkRegion::Op op, bool antiAlias, uint8_t a lpha);
55 54
56 // Draw a single path into the accumuation bitmap using the specified op 55 // Draw a single path into the accumuation bitmap using the specified op
57 void drawPath(const SkPath& path, const GrStyle& style, SkRegion::Op op, 56 void drawShape(const GrShape&, SkRegion::Op op, bool antiAlias, uint8_t alph a);
58 bool antiAlias, uint8_t alpha);
59 57
60 // Move the mask generation results from the internal bitmap to the gpu. 58 // Move the mask generation results from the internal bitmap to the gpu.
61 void toTexture(GrTexture* texture); 59 void toTexture(GrTexture* texture);
62 60
63 // Convert mask generation results to a signed distance field 61 // Convert mask generation results to a signed distance field
64 void toSDF(unsigned char* sdf); 62 void toSDF(unsigned char* sdf);
65 63
66 // Reset the internal bitmap 64 // Reset the internal bitmap
67 void clear(uint8_t alpha) { 65 void clear(uint8_t alpha) {
68 fPixels.erase(SkColorSetARGB(alpha, 0xFF, 0xFF, 0xFF)); 66 fPixels.erase(SkColorSetARGB(alpha, 0xFF, 0xFF, 0xFF));
69 } 67 }
70 68
71 // Canonical usage utility that draws a single path and uploads it 69 // Canonical usage utility that draws a single path and uploads it
72 // to the GPU. The result is returned. 70 // to the GPU. The result is returned.
73 static GrTexture* DrawPathMaskToTexture(GrTextureProvider*, 71 static GrTexture* DrawShapeMaskToTexture(GrTextureProvider*,
74 const SkPath& path, 72 const GrShape&,
75 const GrStyle& style, 73 const SkIRect& resultBounds,
76 const SkIRect& resultBounds, 74 bool antiAlias,
77 bool antiAlias, 75 const SkMatrix* matrix);
78 const SkMatrix* matrix);
79 76
80 // This utility routine is used to add a path's mask to some other draw. 77 // This utility routine is used to add a shape's mask to some other draw.
81 // The ClipMaskManager uses it to accumulate clip masks while the 78 // The ClipMaskManager uses it to accumulate clip masks while the
82 // GrSoftwarePathRenderer uses it to fulfill a drawPath call. 79 // GrSoftwarePathRenderer uses it to fulfill a drawPath call.
83 // It draws with "texture" as a path mask into "target" using "rect" as 80 // It draws with "texture" as a path mask into "target" using "rect" as
84 // geometry and the current drawState. The current drawState is altered to 81 // geometry and the current drawState. The current drawState is altered to
85 // accommodate the mask. 82 // accommodate the mask.
86 // Note that this method assumes that the GrPaint::kTotalStages slot in 83 // Note that this method assumes that the GrPaint::kTotalStages slot in
87 // the draw state can be used to hold the mask texture stage. 84 // the draw state can be used to hold the mask texture stage.
88 // This method is really only intended to be used with the 85 // This method is really only intended to be used with the
89 // output of DrawPathMaskToTexture. 86 // output of DrawPathMaskToTexture.
90 static void DrawToTargetWithPathMask(GrTexture* texture, 87 static void DrawToTargetWithShapeMask(GrTexture* texture,
91 GrDrawContext*, 88 GrDrawContext*,
92 const GrPaint* paint, 89 const GrPaint* paint,
93 const GrUserStencilSettings* userStenci lSettings, 90 const GrUserStencilSettings* userStenc ilSettings,
94 const GrClip&, 91 const GrClip&,
95 GrColor, 92 GrColor,
96 const SkMatrix& viewMatrix, 93 const SkMatrix& viewMatrix,
97 const SkIRect& rect); 94 const SkIRect& rect);
98 95
99 private: 96 private:
100 // Helper function to get a scratch texture suitable for capturing the 97 // Helper function to get a scratch texture suitable for capturing the
101 // result (i.e., right size & format) 98 // result (i.e., right size & format)
102 GrTexture* createTexture(); 99 GrTexture* createTexture();
103 100
104 GrTextureProvider* fTexProvider; 101 GrTextureProvider* fTexProvider;
105 SkMatrix fMatrix; 102 SkMatrix fMatrix;
106 SkAutoPixmapStorage fPixels; 103 SkAutoPixmapStorage fPixels;
107 SkDraw fDraw; 104 SkDraw fDraw;
108 SkRasterClip fRasterClip; 105 SkRasterClip fRasterClip;
109 106
110 typedef SkNoncopyable INHERITED; 107 typedef SkNoncopyable INHERITED;
111 }; 108 };
112 109
113 #endif // GrSWMaskHelper_DEFINED 110 #endif // GrSWMaskHelper_DEFINED
OLDNEW
« no previous file with comments | « src/gpu/GrPathRendererChain.cpp ('k') | src/gpu/GrSWMaskHelper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698