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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 bool antiAlias, uint8_t alpha); | 62 bool antiAlias, uint8_t alpha); |
63 | 63 |
64 // 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. |
65 void toTexture(GrTexture* texture); | 65 void toTexture(GrTexture* texture); |
66 | 66 |
67 // Convert mask generation results to a signed distance field | 67 // Convert mask generation results to a signed distance field |
68 void toSDF(unsigned char* sdf); | 68 void toSDF(unsigned char* sdf); |
69 | 69 |
70 // Reset the internal bitmap | 70 // Reset the internal bitmap |
71 void clear(uint8_t alpha) { | 71 void clear(uint8_t alpha) { |
72 fBM.eraseColor(SkColorSetARGB(alpha, alpha, alpha, alpha)); | 72 fPixels.erase(SkColorSetARGB(alpha, 0xFF, 0xFF, 0xFF)); |
73 } | 73 } |
74 | 74 |
75 // Canonical usage utility that draws a single path and uploads it | 75 // Canonical usage utility that draws a single path and uploads it |
76 // to the GPU. The result is returned. | 76 // to the GPU. The result is returned. |
77 static GrTexture* DrawPathMaskToTexture(GrContext* context, | 77 static GrTexture* DrawPathMaskToTexture(GrContext* context, |
78 const SkPath& path, | 78 const SkPath& path, |
79 const SkStrokeRec& stroke, | 79 const SkStrokeRec& stroke, |
80 const SkIRect& resultBounds, | 80 const SkIRect& resultBounds, |
81 bool antiAlias, | 81 bool antiAlias, |
82 const SkMatrix* matrix); | 82 const SkMatrix* matrix); |
(...skipping 15 matching lines...) Expand all Loading... |
98 const SkMatrix& viewMatrix, | 98 const SkMatrix& viewMatrix, |
99 const SkIRect& rect); | 99 const SkIRect& rect); |
100 | 100 |
101 private: | 101 private: |
102 // Helper function to get a scratch texture suitable for capturing the | 102 // Helper function to get a scratch texture suitable for capturing the |
103 // result (i.e., right size & format) | 103 // result (i.e., right size & format) |
104 GrTexture* createTexture(); | 104 GrTexture* createTexture(); |
105 | 105 |
106 GrContext* fContext; | 106 GrContext* fContext; |
107 SkMatrix fMatrix; | 107 SkMatrix fMatrix; |
108 SkBitmap fBM; | 108 SkAutoPixmapStorage fPixels; |
109 SkDraw fDraw; | 109 SkDraw fDraw; |
110 SkRasterClip fRasterClip; | 110 SkRasterClip fRasterClip; |
111 | 111 |
112 // This enum says whether or not we should compress the mask: | 112 // This enum says whether or not we should compress the mask: |
113 // kNone_CompressionMode: compression is not supported on this device. | 113 // kNone_CompressionMode: compression is not supported on this device. |
114 // kCompress_CompressionMode: compress the bitmap before it gets sent to the
gpu | 114 // kCompress_CompressionMode: compress the bitmap before it gets sent to the
gpu |
115 // kBlitter_CompressionMode: write to the bitmap using a special compressed
blitter. | 115 // kBlitter_CompressionMode: write to the bitmap using a special compressed
blitter. |
116 enum CompressionMode { | 116 enum CompressionMode { |
117 kNone_CompressionMode, | 117 kNone_CompressionMode, |
118 kCompress_CompressionMode, | 118 kCompress_CompressionMode, |
(...skipping 14 matching lines...) Expand all Loading... |
133 const void *data, size_t rowbytes); | 133 const void *data, size_t rowbytes); |
134 | 134 |
135 // Compresses the bitmap stored in fBM and sends the compressed data | 135 // Compresses the bitmap stored in fBM and sends the compressed data |
136 // to the GPU to be stored in 'texture' using sendTextureData. | 136 // to the GPU to be stored in 'texture' using sendTextureData. |
137 void compressTextureData(GrTexture *texture, const GrSurfaceDesc& desc); | 137 void compressTextureData(GrTexture *texture, const GrSurfaceDesc& desc); |
138 | 138 |
139 typedef SkNoncopyable INHERITED; | 139 typedef SkNoncopyable INHERITED; |
140 }; | 140 }; |
141 | 141 |
142 #endif // GrSWMaskHelper_DEFINED | 142 #endif // GrSWMaskHelper_DEFINED |
OLD | NEW |