OLD | NEW |
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 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 } | 48 } |
49 | 49 |
50 // set up the internal state in preparation for draws. Since many masks | 50 // set up the internal state in preparation for draws. Since many masks |
51 // may be accumulated in the helper during creation, "resultBounds" | 51 // may be accumulated in the helper during creation, "resultBounds" |
52 // allows the caller to specify the region of interest - to limit the | 52 // allows the caller to specify the region of interest - to limit the |
53 // amount of work. allowCompression should be set to false if you plan on us
ing | 53 // amount of work. allowCompression should be set to false if you plan on us
ing |
54 // your own texture to draw into, and not a scratch texture via getTexture()
. | 54 // your own texture to draw into, and not a scratch texture via getTexture()
. |
55 bool init(const SkIRect& resultBounds, const SkMatrix* matrix, bool allowCom
pression = true); | 55 bool init(const SkIRect& resultBounds, const SkMatrix* matrix, bool allowCom
pression = true); |
56 | 56 |
57 // Draw a single rect into the accumulation bitmap using the specified op | 57 // Draw a single rect into the accumulation bitmap using the specified op |
58 void draw(const SkRect& rect, SkRegion::Op op, | 58 void draw(const SkRect& rect, SkRegion::Op op, bool antiAlias, uint8_t alpha
); |
59 bool antiAlias, uint8_t alpha); | |
60 | 59 |
61 // Draw a single path into the accumuation bitmap using the specified op | 60 // Draw a single path into the accumuation bitmap using the specified op |
62 void draw(const SkPath& path, const SkStrokeRec& stroke, SkRegion::Op op, | 61 void draw(const SkPath& path, const GrStyle& style, SkRegion::Op op, |
63 bool antiAlias, uint8_t alpha); | 62 bool antiAlias, uint8_t alpha); |
64 | 63 |
65 // Move the mask generation results from the internal bitmap to the gpu. | 64 // Move the mask generation results from the internal bitmap to the gpu. |
66 void toTexture(GrTexture* texture); | 65 void toTexture(GrTexture* texture); |
67 | 66 |
68 // Convert mask generation results to a signed distance field | 67 // Convert mask generation results to a signed distance field |
69 void toSDF(unsigned char* sdf); | 68 void toSDF(unsigned char* sdf); |
70 | 69 |
71 // Reset the internal bitmap | 70 // Reset the internal bitmap |
72 void clear(uint8_t alpha) { | 71 void clear(uint8_t alpha) { |
73 fPixels.erase(SkColorSetARGB(alpha, 0xFF, 0xFF, 0xFF)); | 72 fPixels.erase(SkColorSetARGB(alpha, 0xFF, 0xFF, 0xFF)); |
74 } | 73 } |
75 | 74 |
76 // Canonical usage utility that draws a single path and uploads it | 75 // Canonical usage utility that draws a single path and uploads it |
77 // to the GPU. The result is returned. | 76 // to the GPU. The result is returned. |
78 static GrTexture* DrawPathMaskToTexture(GrContext* context, | 77 static GrTexture* DrawPathMaskToTexture(GrContext* context, |
79 const SkPath& path, | 78 const SkPath& path, |
80 const SkStrokeRec& stroke, | 79 const GrStyle& style, |
81 const SkIRect& resultBounds, | 80 const SkIRect& resultBounds, |
82 bool antiAlias, | 81 bool antiAlias, |
83 const SkMatrix* matrix); | 82 const SkMatrix* matrix); |
84 | 83 |
85 // This utility routine is used to add a path's mask to some other draw. | 84 // This utility routine is used to add a path's mask to some other draw. |
86 // The ClipMaskManager uses it to accumulate clip masks while the | 85 // The ClipMaskManager uses it to accumulate clip masks while the |
87 // GrSoftwarePathRenderer uses it to fulfill a drawPath call. | 86 // GrSoftwarePathRenderer uses it to fulfill a drawPath call. |
88 // It draws with "texture" as a path mask into "target" using "rect" as | 87 // It draws with "texture" as a path mask into "target" using "rect" as |
89 // geometry and the current drawState. The current drawState is altered to | 88 // geometry and the current drawState. The current drawState is altered to |
90 // accommodate the mask. | 89 // accommodate the mask. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 const void *data, size_t rowbytes); | 133 const void *data, size_t rowbytes); |
135 | 134 |
136 // Compresses the bitmap stored in fBM and sends the compressed data | 135 // Compresses the bitmap stored in fBM and sends the compressed data |
137 // to the GPU to be stored in 'texture' using sendTextureData. | 136 // to the GPU to be stored in 'texture' using sendTextureData. |
138 void compressTextureData(GrTexture *texture, const GrSurfaceDesc& desc); | 137 void compressTextureData(GrTexture *texture, const GrSurfaceDesc& desc); |
139 | 138 |
140 typedef SkNoncopyable INHERITED; | 139 typedef SkNoncopyable INHERITED; |
141 }; | 140 }; |
142 | 141 |
143 #endif // GrSWMaskHelper_DEFINED | 142 #endif // GrSWMaskHelper_DEFINED |
OLD | NEW |