Chromium Code Reviews| OLD | NEW | 
|---|---|
| 1 /* | 1 /* | 
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 SkLayerDrawLooper_DEFINED | 8 #ifndef SkLayerDrawLooper_DEFINED | 
| 9 #define SkLayerDrawLooper_DEFINED | 9 #define SkLayerDrawLooper_DEFINED | 
| 10 | 10 | 
| 11 #include "SkDrawLooper.h" | 11 #include "SkDrawLooper.h" | 
| 12 #include "SkPaint.h" | 12 #include "SkPaint.h" | 
| 13 #include "SkPoint.h" | 13 #include "SkPoint.h" | 
| 14 #include "SkXfermode.h" | 14 #include "SkXfermode.h" | 
| 15 | 15 | 
| 16 class SK_API SkLayerDrawLooper : public SkDrawLooper { | 16 class SK_API SkLayerDrawLooper : public SkDrawLooper { | 
| 17 public: | 17 public: | 
| 18 SK_DECLARE_INST_COUNT(SkLayerDrawLooper) | 18 SK_DECLARE_INST_COUNT(SkLayerDrawLooper) | 
| 19 | 19 | 
| 20 SkLayerDrawLooper(); | 20 SkLayerDrawLooper(); | 
| 21 virtual ~SkLayerDrawLooper(); | 21 virtual ~SkLayerDrawLooper(); | 
| 22 | 22 | 
| 23 /** | 23 /** | 
| 24 * Bits specifies which aspects of the layer's paint should replace the | 24 * Bits specifies which aspects of the layer's paint should replace the | 
| 25 * corresponding aspects on the draw's paint. | 25 * corresponding aspects on the draw's paint. | 
| 26 * kEntirePaint_Bits means use the layer's paint completely. | 26 * kEntirePaint_Bits means use the layer's paint completely. | 
| 27 * 0 means ignore the layer's paint... except that LayerInfo's fFlagsMask | 27 * 0 means ignore the layer's paint... except for fColorMode, which is | 
| 28 * and fColorMode are always applied. | 28 * always applied. | 
| 29 */ | 29 */ | 
| 30 enum Bits { | 30 enum Bits { | 
| 31 kStyle_Bit = 1 << 0, //!< use this layer's Style/stroke settings | 31 kStyle_Bit = 1 << 0, //!< use this layer's Style/stroke settings | 
| 32 kTextSkewX_Bit = 1 << 1, //!< use this layer's textskewx | 32 kTextSkewX_Bit = 1 << 1, //!< use this layer's textskewx | 
| 33 kPathEffect_Bit = 1 << 2, //!< use this layer's patheffect | 33 kPathEffect_Bit = 1 << 2, //!< use this layer's patheffect | 
| 34 kMaskFilter_Bit = 1 << 3, //!< use this layer's maskfilter | 34 kMaskFilter_Bit = 1 << 3, //!< use this layer's maskfilter | 
| 35 kShader_Bit = 1 << 4, //!< use this layer's shader | 35 kShader_Bit = 1 << 4, //!< use this layer's shader | 
| 36 kColorFilter_Bit = 1 << 5, //!< use this layer's colorfilter | 36 kColorFilter_Bit = 1 << 5, //!< use this layer's colorfilter | 
| 37 kXfermode_Bit = 1 << 6, //!< use this layer's xfermode | 37 kXfermode_Bit = 1 << 6, //!< use this layer's xfermode | 
| 38 | 38 | 
| 39 /** | 39 /** | 
| 40 * Use the layer's paint entirely, with these exceptions: | 40 * Use the layer's paint entirely, with these exceptions: | 
| 41 * - We never override the draw's paint's text_encoding, since that is | 41 * - We never override the draw's paint's text_encoding, since that is | 
| 42 * used to interpret the text/len parameters in draw[Pos]Text. | 42 * used to interpret the text/len parameters in draw[Pos]Text. | 
| 43 * - Flags and Color are always computed using the LayerInfo's | 43 * - Color are always computed using the LayerInfo's fColorMode. | 
| 
 
scroggo
2014/02/28 15:00:12
nit: Color is*
 
reed1
2014/02/28 15:37:53
Done.
 
 | |
| 44 * fFlagsMask and fColorMode. | |
| 45 */ | 44 */ | 
| 46 kEntirePaint_Bits = -1 | 45 kEntirePaint_Bits = -1 | 
| 47 | 46 | 
| 48 }; | 47 }; | 
| 49 typedef int32_t BitFlags; | 48 typedef int32_t BitFlags; | 
| 50 | 49 | 
| 51 /** | 50 /** | 
| 52 * Info for how to apply the layer's paint and offset. | 51 * Info for how to apply the layer's paint and offset. | 
| 53 * | 52 * | 
| 54 * fFlagsMask selects which flags in the layer's paint should be applied. | |
| 55 * result = (draw-flags & ~fFlagsMask) | (layer-flags & fFlagsMask) | |
| 56 * In the extreme: | |
| 57 * If fFlagsMask is 0, we ignore all of the layer's flags | |
| 58 * If fFlagsMask is -1, we use all of the layer's flags | |
| 59 * | |
| 60 * fColorMode controls how we compute the final color for the layer: | 53 * fColorMode controls how we compute the final color for the layer: | 
| 61 * The layer's paint's color is treated as the SRC | 54 * The layer's paint's color is treated as the SRC | 
| 62 * The draw's paint's color is treated as the DST | 55 * The draw's paint's color is treated as the DST | 
| 63 * final-color = Mode(layers-color, draws-color); | 56 * final-color = Mode(layers-color, draws-color); | 
| 64 * Any SkXfermode::Mode will work. Two common choices are: | 57 * Any SkXfermode::Mode will work. Two common choices are: | 
| 65 * kSrc_Mode: to use the layer's color, ignoring the draw's | 58 * kSrc_Mode: to use the layer's color, ignoring the draw's | 
| 66 * kDst_Mode: to just keep the draw's color, ignoring the layer's | 59 * kDst_Mode: to just keep the draw's color, ignoring the layer's | 
| 67 */ | 60 */ | 
| 68 struct SK_API LayerInfo { | 61 struct SK_API LayerInfo { | 
| 69 #ifdef SK_SUPPORT_LEGACY_LAYERDRAWLOOPER_PAINTFLAGS | |
| 70 uint32_t fFlagsMask; // SkPaint::Flags | |
| 71 #endif | |
| 72 BitFlags fPaintBits; | 62 BitFlags fPaintBits; | 
| 73 SkXfermode::Mode fColorMode; | 63 SkXfermode::Mode fColorMode; | 
| 74 SkVector fOffset; | 64 SkVector fOffset; | 
| 75 bool fPostTranslate; //!< applies to fOffset | 65 bool fPostTranslate; //!< applies to fOffset | 
| 76 | 66 | 
| 77 /** | 67 /** | 
| 78 * Initial the LayerInfo. Defaults to settings that will draw the | 68 * Initial the LayerInfo. Defaults to settings that will draw the | 
| 79 * layer with no changes: e.g. | 69 * layer with no changes: e.g. | 
| 80 * fPaintBits == 0 | 70 * fPaintBits == 0 | 
| 81 * fColorMode == kDst_Mode | 71 * fColorMode == kDst_Mode | 
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 SkLayerDrawLooper* detachLooper(); | 162 SkLayerDrawLooper* detachLooper(); | 
| 173 | 163 | 
| 174 private: | 164 private: | 
| 175 Rec* fRecs; | 165 Rec* fRecs; | 
| 176 Rec* fTopRec; | 166 Rec* fTopRec; | 
| 177 int fCount; | 167 int fCount; | 
| 178 }; | 168 }; | 
| 179 }; | 169 }; | 
| 180 | 170 | 
| 181 #endif | 171 #endif | 
| OLD | NEW |