| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CC_PAINT_PAINT_FLAGS_H_ | 5 #ifndef CC_PAINT_PAINT_FLAGS_H_ |
| 6 #define CC_PAINT_PAINT_FLAGS_H_ | 6 #define CC_PAINT_PAINT_FLAGS_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "cc/paint/paint_export.h" | 9 #include "cc/paint/paint_export.h" |
| 10 #include "cc/paint/paint_shader.h" | |
| 11 #include "third_party/skia/include/core/SkCanvas.h" | 10 #include "third_party/skia/include/core/SkCanvas.h" |
| 12 #include "third_party/skia/include/core/SkColorFilter.h" | 11 #include "third_party/skia/include/core/SkColorFilter.h" |
| 13 #include "third_party/skia/include/core/SkDrawLooper.h" | 12 #include "third_party/skia/include/core/SkDrawLooper.h" |
| 14 #include "third_party/skia/include/core/SkImageFilter.h" | 13 #include "third_party/skia/include/core/SkImageFilter.h" |
| 15 #include "third_party/skia/include/core/SkMaskFilter.h" | 14 #include "third_party/skia/include/core/SkMaskFilter.h" |
| 16 #include "third_party/skia/include/core/SkPaint.h" | 15 #include "third_party/skia/include/core/SkPaint.h" |
| 17 #include "third_party/skia/include/core/SkPathEffect.h" | 16 #include "third_party/skia/include/core/SkPathEffect.h" |
| 18 #include "third_party/skia/include/core/SkTypeface.h" | 17 #include "third_party/skia/include/core/SkTypeface.h" |
| 19 | 18 |
| 20 namespace cc { | 19 namespace cc { |
| 21 | 20 |
| 21 using PaintShader = SkShader; |
| 22 |
| 22 class CC_PAINT_EXPORT PaintFlags { | 23 class CC_PAINT_EXPORT PaintFlags { |
| 23 public: | 24 public: |
| 24 enum Style { | 25 enum Style { |
| 25 kFill_Style = SkPaint::kFill_Style, | 26 kFill_Style = SkPaint::kFill_Style, |
| 26 kStroke_Style = SkPaint::kStroke_Style, | 27 kStroke_Style = SkPaint::kStroke_Style, |
| 27 kStrokeAndFill_Style = SkPaint::kStrokeAndFill_Style, | 28 kStrokeAndFill_Style = SkPaint::kStrokeAndFill_Style, |
| 28 }; | 29 }; |
| 29 ALWAYS_INLINE Style getStyle() const { | 30 ALWAYS_INLINE Style getStyle() const { |
| 30 return static_cast<Style>(paint_.getStyle()); | 31 return static_cast<Style>(paint_.getStyle()); |
| 31 } | 32 } |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 paint_.setLooper(std::move(looper)); | 192 paint_.setLooper(std::move(looper)); |
| 192 } | 193 } |
| 193 ALWAYS_INLINE bool canComputeFastBounds() const { | 194 ALWAYS_INLINE bool canComputeFastBounds() const { |
| 194 return paint_.canComputeFastBounds(); | 195 return paint_.canComputeFastBounds(); |
| 195 } | 196 } |
| 196 ALWAYS_INLINE const SkRect& computeFastBounds(const SkRect& orig, | 197 ALWAYS_INLINE const SkRect& computeFastBounds(const SkRect& orig, |
| 197 SkRect* storage) const { | 198 SkRect* storage) const { |
| 198 return paint_.computeFastBounds(orig, storage); | 199 return paint_.computeFastBounds(orig, storage); |
| 199 } | 200 } |
| 200 | 201 |
| 202 bool operator==(const PaintFlags& flags) { return flags.paint_ == paint_; } |
| 203 bool operator!=(const PaintFlags& flags) { return flags.paint_ != paint_; } |
| 204 |
| 205 // Returns true if this just represents an opacity blend when |
| 206 // used as saveLayer flags. |
| 207 bool IsSimpleOpacity() const; |
| 208 bool SupportsFoldingAlpha() const; |
| 209 |
| 201 private: | 210 private: |
| 202 friend const SkPaint& ToSkPaint(const PaintFlags& flags); | 211 friend const SkPaint& ToSkPaint(const PaintFlags& flags); |
| 203 friend const SkPaint* ToSkPaint(const PaintFlags* flags); | 212 friend const SkPaint* ToSkPaint(const PaintFlags* flags); |
| 204 | 213 |
| 205 SkPaint paint_; | 214 SkPaint paint_; |
| 206 }; | 215 }; |
| 207 | 216 |
| 208 ALWAYS_INLINE const SkPaint& ToSkPaint(const PaintFlags& flags) { | 217 ALWAYS_INLINE const SkPaint& ToSkPaint(const PaintFlags& flags) { |
| 209 return flags.paint_; | 218 return flags.paint_; |
| 210 } | 219 } |
| 211 | 220 |
| 212 ALWAYS_INLINE const SkPaint* ToSkPaint(const PaintFlags* flags) { | 221 ALWAYS_INLINE const SkPaint* ToSkPaint(const PaintFlags* flags) { |
| 213 return &flags->paint_; | 222 return &flags->paint_; |
| 214 } | 223 } |
| 215 | 224 |
| 216 } // namespace cc | 225 } // namespace cc |
| 217 | 226 |
| 218 #endif // CC_PAINT_PAINT_FLAGS_H_ | 227 #endif // CC_PAINT_PAINT_FLAGS_H_ |
| OLD | NEW |