| 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 |
| 11 #include "GrColor.h" | 11 #include "GrColor.h" |
| 12 #include "GrDrawState.h" | 12 #include "GrDrawState.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 "SkTextureCompressor.h" | 18 #include "SkTextureCompressor.h" |
| 19 #include "SkTypes.h" | 19 #include "SkTypes.h" |
| 20 | 20 |
| 21 class GrAutoScratchTexture; | |
| 22 class GrContext; | 21 class GrContext; |
| 23 class GrTexture; | 22 class GrTexture; |
| 24 class SkPath; | 23 class SkPath; |
| 25 class SkStrokeRec; | 24 class SkStrokeRec; |
| 26 class GrDrawTarget; | 25 class GrDrawTarget; |
| 27 | 26 |
| 28 /** | 27 /** |
| 29 * The GrSWMaskHelper helps generate clip masks using the software rendering | 28 * The GrSWMaskHelper helps generate clip masks using the software rendering |
| 30 * path. It is intended to be used as: | 29 * path. It is intended to be used as: |
| 31 * | 30 * |
| (...skipping 22 matching lines...) Expand all Loading... |
| 54 bool init(const SkIRect& resultBounds, const SkMatrix* matrix, bool allowCom
pression = true); | 53 bool init(const SkIRect& resultBounds, const SkMatrix* matrix, bool allowCom
pression = true); |
| 55 | 54 |
| 56 // Draw a single rect into the accumulation bitmap using the specified op | 55 // Draw a single rect into the accumulation bitmap using the specified op |
| 57 void draw(const SkRect& rect, SkRegion::Op op, | 56 void draw(const SkRect& rect, SkRegion::Op op, |
| 58 bool antiAlias, uint8_t alpha); | 57 bool antiAlias, uint8_t alpha); |
| 59 | 58 |
| 60 // Draw a single path into the accumuation bitmap using the specified op | 59 // Draw a single path into the accumuation bitmap using the specified op |
| 61 void draw(const SkPath& path, const SkStrokeRec& stroke, SkRegion::Op op, | 60 void draw(const SkPath& path, const SkStrokeRec& stroke, SkRegion::Op op, |
| 62 bool antiAlias, uint8_t alpha); | 61 bool antiAlias, uint8_t alpha); |
| 63 | 62 |
| 64 // Helper function to get a scratch texture suitable for capturing the | |
| 65 // result (i.e., right size & format) | |
| 66 bool getTexture(GrAutoScratchTexture* texture); | |
| 67 | |
| 68 // Move the mask generation results from the internal bitmap to the gpu. | 63 // Move the mask generation results from the internal bitmap to the gpu. |
| 69 void toTexture(GrTexture* texture); | 64 void toTexture(GrTexture* texture); |
| 70 | 65 |
| 71 // Convert mask generation results to a signed distance field | 66 // Convert mask generation results to a signed distance field |
| 72 void toSDF(unsigned char* sdf); | 67 void toSDF(unsigned char* sdf); |
| 73 | 68 |
| 74 // Reset the internal bitmap | 69 // Reset the internal bitmap |
| 75 void clear(uint8_t alpha) { | 70 void clear(uint8_t alpha) { |
| 76 fBM.eraseColor(SkColorSetARGB(alpha, alpha, alpha, alpha)); | 71 fBM.eraseColor(SkColorSetARGB(alpha, alpha, alpha, alpha)); |
| 77 } | 72 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 93 // accommodate the mask. | 88 // accommodate the mask. |
| 94 // Note that this method assumes that the GrPaint::kTotalStages slot in | 89 // Note that this method assumes that the GrPaint::kTotalStages slot in |
| 95 // the draw state can be used to hold the mask texture stage. | 90 // the draw state can be used to hold the mask texture stage. |
| 96 // This method is really only intended to be used with the | 91 // This method is really only intended to be used with the |
| 97 // output of DrawPathMaskToTexture. | 92 // output of DrawPathMaskToTexture. |
| 98 static void DrawToTargetWithPathMask(GrTexture* texture, | 93 static void DrawToTargetWithPathMask(GrTexture* texture, |
| 99 GrDrawTarget* target, | 94 GrDrawTarget* target, |
| 100 const SkIRect& rect); | 95 const SkIRect& rect); |
| 101 | 96 |
| 102 private: | 97 private: |
| 98 // Helper function to get a scratch texture suitable for capturing the |
| 99 // result (i.e., right size & format) |
| 100 GrTexture* createTexture(); |
| 101 |
| 103 GrContext* fContext; | 102 GrContext* fContext; |
| 104 SkMatrix fMatrix; | 103 SkMatrix fMatrix; |
| 105 SkBitmap fBM; | 104 SkBitmap fBM; |
| 106 SkDraw fDraw; | 105 SkDraw fDraw; |
| 107 SkRasterClip fRasterClip; | 106 SkRasterClip fRasterClip; |
| 108 | 107 |
| 109 // This enum says whether or not we should compress the mask: | 108 // This enum says whether or not we should compress the mask: |
| 110 // kNone_CompressionMode: compression is not supported on this device. | 109 // kNone_CompressionMode: compression is not supported on this device. |
| 111 // kCompress_CompressionMode: compress the bitmap before it gets sent to the
gpu | 110 // kCompress_CompressionMode: compress the bitmap before it gets sent to the
gpu |
| 112 // kBlitter_CompressionMode: write to the bitmap using a special compressed
blitter. | 111 // kBlitter_CompressionMode: write to the bitmap using a special compressed
blitter. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 130 const void *data, int rowbytes); | 129 const void *data, int rowbytes); |
| 131 | 130 |
| 132 // Compresses the bitmap stored in fBM and sends the compressed data | 131 // Compresses the bitmap stored in fBM and sends the compressed data |
| 133 // to the GPU to be stored in 'texture' using sendTextureData. | 132 // to the GPU to be stored in 'texture' using sendTextureData. |
| 134 void compressTextureData(GrTexture *texture, const GrTextureDesc& desc); | 133 void compressTextureData(GrTexture *texture, const GrTextureDesc& desc); |
| 135 | 134 |
| 136 typedef SkNoncopyable INHERITED; | 135 typedef SkNoncopyable INHERITED; |
| 137 }; | 136 }; |
| 138 | 137 |
| 139 #endif // GrSWMaskHelper_DEFINED | 138 #endif // GrSWMaskHelper_DEFINED |
| OLD | NEW |