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 24 matching lines...) Expand all Loading... | |
35 * draw one or more paths/rects specifying the required boolean ops | 35 * draw one or more paths/rects specifying the required boolean ops |
36 * | 36 * |
37 * toTexture(); // to get it from the internal bitmap to the GPU | 37 * toTexture(); // to get it from the internal bitmap to the GPU |
38 * | 38 * |
39 * The result of this process will be the final mask (on the GPU) in the | 39 * The result of this process will be the final mask (on the GPU) in the |
40 * upper left hand corner of the texture. | 40 * upper left hand corner of the texture. |
41 */ | 41 */ |
42 class GrSWMaskHelper : SkNoncopyable { | 42 class GrSWMaskHelper : SkNoncopyable { |
43 public: | 43 public: |
44 GrSWMaskHelper(GrContext* context) | 44 GrSWMaskHelper(GrContext* context) |
45 : fContext(context), fCompressMask(false) { | 45 : fContext(context) |
46 } | 46 , fCompressionMode(kNone_CompressionMode) |
47 , fCompressedBuffer(NULL) | |
48 , fCompressedBlitter(NULL) | |
robertphillips
2014/08/06 20:54:49
'{' goes on line above
krajcevski
2014/08/06 22:41:59
Done.
| |
49 { } | |
50 | |
51 ~GrSWMaskHelper(); | |
47 | 52 |
48 // set up the internal state in preparation for draws. Since many masks | 53 // set up the internal state in preparation for draws. Since many masks |
49 // may be accumulated in the helper during creation, "resultBounds" | 54 // may be accumulated in the helper during creation, "resultBounds" |
50 // allows the caller to specify the region of interest - to limit the | 55 // allows the caller to specify the region of interest - to limit the |
51 // amount of work. | 56 // amount of work. |
52 bool init(const SkIRect& resultBounds, const SkMatrix* matrix); | 57 bool init(const SkIRect& resultBounds, const SkMatrix* matrix); |
53 | 58 |
54 // Draw a single rect into the accumulation bitmap using the specified op | 59 // Draw a single rect into the accumulation bitmap using the specified op |
55 void draw(const SkRect& rect, SkRegion::Op op, | 60 void draw(const SkRect& rect, SkRegion::Op op, |
56 bool antiAlias, uint8_t alpha); | 61 bool antiAlias, uint8_t alpha); |
(...skipping 30 matching lines...) Expand all Loading... | |
87 // geometry and the current drawState. The current drawState is altered to | 92 // geometry and the current drawState. The current drawState is altered to |
88 // accommodate the mask. | 93 // accommodate the mask. |
89 // Note that this method assumes that the GrPaint::kTotalStages slot in | 94 // Note that this method assumes that the GrPaint::kTotalStages slot in |
90 // the draw state can be used to hold the mask texture stage. | 95 // the draw state can be used to hold the mask texture stage. |
91 // This method is really only intended to be used with the | 96 // This method is really only intended to be used with the |
92 // output of DrawPathMaskToTexture. | 97 // output of DrawPathMaskToTexture. |
93 static void DrawToTargetWithPathMask(GrTexture* texture, | 98 static void DrawToTargetWithPathMask(GrTexture* texture, |
94 GrDrawTarget* target, | 99 GrDrawTarget* target, |
95 const SkIRect& rect); | 100 const SkIRect& rect); |
96 | 101 |
97 protected: | |
98 private: | 102 private: |
99 GrContext* fContext; | 103 GrContext* fContext; |
100 SkMatrix fMatrix; | 104 SkMatrix fMatrix; |
101 SkBitmap fBM; | 105 SkBitmap fBM; |
102 SkDraw fDraw; | 106 SkDraw fDraw; |
103 SkRasterClip fRasterClip; | 107 SkRasterClip fRasterClip; |
104 | 108 |
105 // This flag says whether or not we should compress the mask. If | 109 // This enum says whether or not we should compress the mask: |
106 // it is true, then fCompressedFormat is always valid. | 110 // kNone_CompressionMode: compression is not supported on this device. |
107 bool fCompressMask; | 111 // kCompress_CompressionMode: compress the bitmap before it gets sent to the gpu |
112 // kBlitter_CompressionMode: write to the bitmap using a special compressed blitter. | |
113 enum CompressionMode { | |
114 kNone_CompressionMode, | |
115 kCompress_CompressionMode, | |
116 kBlitter_CompressionMode, | |
117 } fCompressionMode; | |
118 | |
robertphillips
2014/08/06 20:54:49
// These two are only non-NULL is fCompressionMode
krajcevski
2014/08/06 22:41:59
Done.
| |
119 void* fCompressedBuffer; | |
120 SkBlitter* fCompressedBlitter; | |
108 | 121 |
109 // This is the desired format within which to compress the | 122 // This is the desired format within which to compress the |
110 // texture. This value is only valid if fCompressMask is true. | 123 // texture. This value is only valid if fCompressionMode is not kNone_Compre ssionMode. |
111 SkTextureCompressor::Format fCompressedFormat; | 124 SkTextureCompressor::Format fCompressedFormat; |
112 | 125 |
113 // Actually sends the texture data to the GPU. This is called from | 126 // Actually sends the texture data to the GPU. This is called from |
114 // toTexture with the data filled in depending on the texture config. | 127 // toTexture with the data filled in depending on the texture config. |
115 void sendTextureData(GrTexture *texture, const GrTextureDesc& desc, | 128 void sendTextureData(GrTexture *texture, const GrTextureDesc& desc, |
116 const void *data, int rowbytes); | 129 const void *data, int rowbytes); |
117 | 130 |
118 // Compresses the bitmap stored in fBM and sends the compressed data | 131 // Compresses the bitmap stored in fBM and sends the compressed data |
119 // to the GPU to be stored in 'texture' using sendTextureData. | 132 // to the GPU to be stored in 'texture' using sendTextureData. |
120 void compressTextureData(GrTexture *texture, const GrTextureDesc& desc); | 133 void compressTextureData(GrTexture *texture, const GrTextureDesc& desc); |
121 | 134 |
122 typedef SkNoncopyable INHERITED; | 135 typedef SkNoncopyable INHERITED; |
123 }; | 136 }; |
124 | 137 |
125 #endif // GrSWMaskHelper_DEFINED | 138 #endif // GrSWMaskHelper_DEFINED |
OLD | NEW |