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, bool antiAlias, uint8_t alpha
); | 58 void draw(const SkRect& rect, SkRegion::Op op, |
| 59 bool antiAlias, uint8_t alpha); |
59 | 60 |
60 // Draw a single path into the accumuation bitmap using the specified op | 61 // Draw a single path into the accumuation bitmap using the specified op |
61 void draw(const SkPath& path, const GrStyle& style, SkRegion::Op op, | 62 void draw(const SkPath& path, const SkStrokeRec& stroke, SkRegion::Op op, |
62 bool antiAlias, uint8_t alpha); | 63 bool antiAlias, uint8_t alpha); |
63 | 64 |
64 // Move the mask generation results from the internal bitmap to the gpu. | 65 // Move the mask generation results from the internal bitmap to the gpu. |
65 void toTexture(GrTexture* texture); | 66 void toTexture(GrTexture* texture); |
66 | 67 |
67 // Convert mask generation results to a signed distance field | 68 // Convert mask generation results to a signed distance field |
68 void toSDF(unsigned char* sdf); | 69 void toSDF(unsigned char* sdf); |
69 | 70 |
70 // Reset the internal bitmap | 71 // Reset the internal bitmap |
71 void clear(uint8_t alpha) { | 72 void clear(uint8_t alpha) { |
72 fPixels.erase(SkColorSetARGB(alpha, 0xFF, 0xFF, 0xFF)); | 73 fPixels.erase(SkColorSetARGB(alpha, 0xFF, 0xFF, 0xFF)); |
73 } | 74 } |
74 | 75 |
75 // Canonical usage utility that draws a single path and uploads it | 76 // Canonical usage utility that draws a single path and uploads it |
76 // to the GPU. The result is returned. | 77 // to the GPU. The result is returned. |
77 static GrTexture* DrawPathMaskToTexture(GrContext* context, | 78 static GrTexture* DrawPathMaskToTexture(GrContext* context, |
78 const SkPath& path, | 79 const SkPath& path, |
79 const GrStyle& style, | 80 const SkStrokeRec& stroke, |
80 const SkIRect& resultBounds, | 81 const SkIRect& resultBounds, |
81 bool antiAlias, | 82 bool antiAlias, |
82 const SkMatrix* matrix); | 83 const SkMatrix* matrix); |
83 | 84 |
84 // This utility routine is used to add a path's mask to some other draw. | 85 // This utility routine is used to add a path's mask to some other draw. |
85 // The ClipMaskManager uses it to accumulate clip masks while the | 86 // The ClipMaskManager uses it to accumulate clip masks while the |
86 // GrSoftwarePathRenderer uses it to fulfill a drawPath call. | 87 // GrSoftwarePathRenderer uses it to fulfill a drawPath call. |
87 // It draws with "texture" as a path mask into "target" using "rect" as | 88 // It draws with "texture" as a path mask into "target" using "rect" as |
88 // geometry and the current drawState. The current drawState is altered to | 89 // geometry and the current drawState. The current drawState is altered to |
89 // accommodate the mask. | 90 // accommodate the mask. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 const void *data, size_t rowbytes); | 134 const void *data, size_t rowbytes); |
134 | 135 |
135 // Compresses the bitmap stored in fBM and sends the compressed data | 136 // Compresses the bitmap stored in fBM and sends the compressed data |
136 // to the GPU to be stored in 'texture' using sendTextureData. | 137 // to the GPU to be stored in 'texture' using sendTextureData. |
137 void compressTextureData(GrTexture *texture, const GrSurfaceDesc& desc); | 138 void compressTextureData(GrTexture *texture, const GrSurfaceDesc& desc); |
138 | 139 |
139 typedef SkNoncopyable INHERITED; | 140 typedef SkNoncopyable INHERITED; |
140 }; | 141 }; |
141 | 142 |
142 #endif // GrSWMaskHelper_DEFINED | 143 #endif // GrSWMaskHelper_DEFINED |
OLD | NEW |