| OLD | NEW |
| (Empty) | |
| 1 /* |
| 2 * Copyright 2016 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #ifndef SKIA_EXT_CDL_PAINT_H_ |
| 9 #define SKIA_EXT_CDL_PAINT_H_ |
| 10 |
| 11 #include "cdl_common.h" |
| 12 |
| 13 #if CDL_ENABLED |
| 14 |
| 15 #include "cdl_shader.h" |
| 16 #include "third_party/skia/include/core/SkCanvas.h" |
| 17 #include "third_party/skia/include/core/SkColorFilter.h" |
| 18 #include "third_party/skia/include/core/SkDrawLooper.h" |
| 19 #include "third_party/skia/include/core/SkImageFilter.h" |
| 20 #include "third_party/skia/include/core/SkMaskFilter.h" |
| 21 #include "third_party/skia/include/core/SkPaint.h" |
| 22 #include "third_party/skia/include/core/SkPathEffect.h" |
| 23 #include "third_party/skia/include/core/SkTypeface.h" |
| 24 |
| 25 class SK_API CdlPaint { |
| 26 public: |
| 27 CdlPaint(); |
| 28 ~CdlPaint(); |
| 29 CdlPaint(const CdlPaint& paint); |
| 30 |
| 31 SkPaint toSkPaint() const; |
| 32 |
| 33 enum Style { |
| 34 kFill_Style = SkPaint::kFill_Style, |
| 35 kStroke_Style = SkPaint::kStroke_Style, |
| 36 kStrokeAndFill_Style = SkPaint::kStrokeAndFill_Style, |
| 37 }; |
| 38 Style getStyle() const { return (Style)paint_.getStyle(); } |
| 39 void setStyle(Style style) { paint_.setStyle((SkPaint::Style)style); } |
| 40 |
| 41 SkColor getColor() const { return paint_.getColor(); } |
| 42 void setColor(SkColor color) { paint_.setColor(color); } |
| 43 void setARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b) { |
| 44 paint_.setARGB(a, r, g, b); |
| 45 } |
| 46 |
| 47 uint8_t getAlpha() const { return paint_.getAlpha(); } |
| 48 void setAlpha(U8CPU a) { paint_.setAlpha(a); } |
| 49 |
| 50 void setBlendMode(SkBlendMode mode) { paint_.setBlendMode(mode); } |
| 51 SkBlendMode getBlendMode() const { return paint_.getBlendMode(); } |
| 52 bool isSrcOver() const { return paint_.isSrcOver(); } |
| 53 |
| 54 bool isAntiAlias() const { return paint_.isAntiAlias(); } |
| 55 void setAntiAlias(bool aa) { paint_.setAntiAlias(aa); } |
| 56 |
| 57 bool isVerticalText() const { return paint_.isVerticalText(); } |
| 58 void setVerticalText(bool vertical) { paint_.setVerticalText(vertical); } |
| 59 |
| 60 bool isSubpixelText() const { return paint_.isSubpixelText(); } |
| 61 void setSubpixelText(bool subpixelText) { |
| 62 paint_.setSubpixelText(subpixelText); |
| 63 } |
| 64 |
| 65 bool isLCDRenderText() const { return paint_.isLCDRenderText(); } |
| 66 void setLCDRenderText(bool lcdText) { paint_.setLCDRenderText(lcdText); } |
| 67 |
| 68 enum Hinting { |
| 69 kNo_Hinting = SkPaint::kNo_Hinting, |
| 70 kSlight_Hinting = SkPaint::kSlight_Hinting, |
| 71 kNormal_Hinting = SkPaint::kNormal_Hinting, //!< this is the default |
| 72 kFull_Hinting = SkPaint::kFull_Hinting |
| 73 }; |
| 74 |
| 75 Hinting getHinting() const { |
| 76 return static_cast<Hinting>(paint_.getHinting()); |
| 77 } |
| 78 void setHinting(Hinting hintingLevel) { |
| 79 paint_.setHinting(static_cast<SkPaint::Hinting>(hintingLevel)); |
| 80 } |
| 81 |
| 82 bool isAutohinted() const { return paint_.isAutohinted(); } |
| 83 void setAutohinted(bool useAutohinter) { |
| 84 paint_.setAutohinted(useAutohinter); |
| 85 } |
| 86 |
| 87 bool isDither() const { return paint_.isDither(); } |
| 88 void setDither(bool dither) { paint_.setDither(dither); } |
| 89 |
| 90 enum TextEncoding { |
| 91 kUTF8_TextEncoding = |
| 92 SkPaint::kUTF8_TextEncoding, //!< the text parameters are UTF8 |
| 93 kUTF16_TextEncoding = |
| 94 SkPaint::kUTF16_TextEncoding, //!< the text parameters are UTF16 |
| 95 kUTF32_TextEncoding = |
| 96 SkPaint::kUTF32_TextEncoding, //!< the text parameters are UTF32 |
| 97 kGlyphID_TextEncoding = SkPaint::kGlyphID_TextEncoding //!< the text |
| 98 //! parameters are |
| 99 //! glyph indices |
| 100 }; |
| 101 |
| 102 TextEncoding getTextEncoding() const { |
| 103 return static_cast<TextEncoding>(paint_.getTextEncoding()); |
| 104 } |
| 105 void setTextEncoding(TextEncoding encoding) { |
| 106 paint_.setTextEncoding(static_cast<SkPaint::TextEncoding>(encoding)); |
| 107 } |
| 108 |
| 109 SkScalar getTextSize() const { return paint_.getTextSize(); } |
| 110 void setTextSize(SkScalar textSize) { paint_.setTextSize(textSize); } |
| 111 |
| 112 void setFilterQuality(SkFilterQuality quality) { |
| 113 paint_.setFilterQuality(quality); |
| 114 } |
| 115 SkFilterQuality getFilterQuality() const { return paint_.getFilterQuality(); } |
| 116 |
| 117 SkScalar getStrokeWidth() const { return paint_.getStrokeWidth(); } |
| 118 void setStrokeWidth(SkScalar width) { paint_.setStrokeWidth(width); } |
| 119 |
| 120 SkScalar getStrokeMiter() const { return paint_.getStrokeMiter(); } |
| 121 void setStrokeMiter(SkScalar miter) { paint_.setStrokeMiter(miter); } |
| 122 |
| 123 enum Cap { |
| 124 kButt_Cap = SkPaint::kButt_Cap, //!< begin/end contours with no extension |
| 125 kRound_Cap = SkPaint::kRound_Cap, //!< begin/end contours with a |
| 126 //! semi-circle extension |
| 127 kSquare_Cap = SkPaint::kSquare_Cap, //!< begin/end contours with a half |
| 128 //! square extension |
| 129 |
| 130 kLast_Cap = kSquare_Cap, |
| 131 kDefault_Cap = kButt_Cap |
| 132 }; |
| 133 Cap getStrokeCap() const { return static_cast<Cap>(paint_.getStrokeCap()); } |
| 134 void setStrokeCap(Cap cap) { |
| 135 paint_.setStrokeCap(static_cast<SkPaint::Cap>(cap)); |
| 136 } |
| 137 |
| 138 enum Join { |
| 139 kMiter_Join = |
| 140 SkPaint::kMiter_Join, //!< connect path segments with a sharp join |
| 141 kRound_Join = |
| 142 SkPaint::kRound_Join, //!< connect path segments with a round join |
| 143 kBevel_Join = |
| 144 SkPaint::kBevel_Join, //!< connect path segments with a flat bevel join |
| 145 |
| 146 kLast_Join = kBevel_Join, |
| 147 kDefault_Join = kMiter_Join |
| 148 }; |
| 149 Join getStrokeJoin() const { |
| 150 return static_cast<Join>(paint_.getStrokeJoin()); |
| 151 } |
| 152 void setStrokeJoin(Join join) { |
| 153 paint_.setStrokeJoin(static_cast<SkPaint::Join>(join)); |
| 154 } |
| 155 |
| 156 SkTypeface* getTypeface() const { return paint_.getTypeface(); } |
| 157 void setTypeface(sk_sp<SkTypeface> typeface) { paint_.setTypeface(typeface); } |
| 158 |
| 159 SkColorFilter* getColorFilter() const { return paint_.getColorFilter(); } |
| 160 void setColorFilter(sk_sp<SkColorFilter> filter) { |
| 161 paint_.setColorFilter(filter); |
| 162 } |
| 163 |
| 164 SkMaskFilter* getMaskFilter() const { return paint_.getMaskFilter(); } |
| 165 void setMaskFilter(sk_sp<SkMaskFilter> mask) { paint_.setMaskFilter(mask); }; |
| 166 |
| 167 CdlShader* getShader() const { return shader_.get(); } |
| 168 void setShader(sk_sp<CdlShader> shader) { shader_ = shader; } |
| 169 |
| 170 SkPathEffect* getPathEffect() const { return paint_.getPathEffect(); } |
| 171 void setPathEffect(sk_sp<SkPathEffect> effect) { |
| 172 paint_.setPathEffect(effect); |
| 173 } |
| 174 |
| 175 SkImageFilter* getImageFilter() const { return paint_.getImageFilter(); } |
| 176 void setImageFilter(sk_sp<SkImageFilter> filter) { |
| 177 paint_.setImageFilter(filter); |
| 178 } |
| 179 |
| 180 SkDrawLooper* getDrawLooper() const { return paint_.getDrawLooper(); } |
| 181 SkDrawLooper* getLooper() const { return paint_.getLooper(); } |
| 182 void setLooper(sk_sp<SkDrawLooper> looper) { paint_.setLooper(looper); } |
| 183 |
| 184 bool canComputeFastBounds() const { return paint_.canComputeFastBounds(); } |
| 185 const SkRect& computeFastBounds(const SkRect& orig, SkRect* storage) const { |
| 186 return paint_.computeFastBounds(orig, storage); |
| 187 } |
| 188 |
| 189 protected: |
| 190 SkPaint paint_; |
| 191 sk_sp<CdlShader> shader_; |
| 192 }; |
| 193 |
| 194 inline SkPaint ToSkPaint(const CdlPaint& paint) { |
| 195 return paint.toSkPaint(); |
| 196 } |
| 197 |
| 198 #else // CDL_ENABLED |
| 199 |
| 200 #include "third_party/skia/include/core/SkPaint.h" |
| 201 |
| 202 inline SkPaint ToSkPaint(const CdlPaint& paint) { |
| 203 return paint; |
| 204 } |
| 205 |
| 206 #endif // CDL_ENABLED |
| 207 |
| 208 #endif // SKIA_EXT_CDL_LITE_RECORDER_H_ |
| OLD | NEW |