| 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" |
| 10 #include "third_party/skia/include/core/SkCanvas.h" | 11 #include "third_party/skia/include/core/SkCanvas.h" |
| 11 #include "third_party/skia/include/core/SkColorFilter.h" | 12 #include "third_party/skia/include/core/SkColorFilter.h" |
| 12 #include "third_party/skia/include/core/SkDrawLooper.h" | 13 #include "third_party/skia/include/core/SkDrawLooper.h" |
| 13 #include "third_party/skia/include/core/SkImageFilter.h" | 14 #include "third_party/skia/include/core/SkImageFilter.h" |
| 14 #include "third_party/skia/include/core/SkMaskFilter.h" | 15 #include "third_party/skia/include/core/SkMaskFilter.h" |
| 15 #include "third_party/skia/include/core/SkPaint.h" | 16 #include "third_party/skia/include/core/SkPaint.h" |
| 16 #include "third_party/skia/include/core/SkPathEffect.h" | 17 #include "third_party/skia/include/core/SkPathEffect.h" |
| 17 #include "third_party/skia/include/core/SkTypeface.h" | 18 #include "third_party/skia/include/core/SkTypeface.h" |
| 18 | 19 |
| 19 namespace cc { | 20 namespace cc { |
| 20 | 21 |
| 21 using PaintShader = SkShader; | |
| 22 | |
| 23 class CC_PAINT_EXPORT PaintFlags { | 22 class CC_PAINT_EXPORT PaintFlags { |
| 24 public: | 23 public: |
| 25 enum Style { | 24 enum Style { |
| 26 kFill_Style = SkPaint::kFill_Style, | 25 kFill_Style = SkPaint::kFill_Style, |
| 27 kStroke_Style = SkPaint::kStroke_Style, | 26 kStroke_Style = SkPaint::kStroke_Style, |
| 28 kStrokeAndFill_Style = SkPaint::kStrokeAndFill_Style, | 27 kStrokeAndFill_Style = SkPaint::kStrokeAndFill_Style, |
| 29 }; | 28 }; |
| 30 ALWAYS_INLINE Style getStyle() const { | 29 ALWAYS_INLINE Style getStyle() const { |
| 31 return static_cast<Style>(paint_.getStyle()); | 30 return static_cast<Style>(paint_.getStyle()); |
| 32 } | 31 } |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 paint_.setLooper(std::move(looper)); | 191 paint_.setLooper(std::move(looper)); |
| 193 } | 192 } |
| 194 ALWAYS_INLINE bool canComputeFastBounds() const { | 193 ALWAYS_INLINE bool canComputeFastBounds() const { |
| 195 return paint_.canComputeFastBounds(); | 194 return paint_.canComputeFastBounds(); |
| 196 } | 195 } |
| 197 ALWAYS_INLINE const SkRect& computeFastBounds(const SkRect& orig, | 196 ALWAYS_INLINE const SkRect& computeFastBounds(const SkRect& orig, |
| 198 SkRect* storage) const { | 197 SkRect* storage) const { |
| 199 return paint_.computeFastBounds(orig, storage); | 198 return paint_.computeFastBounds(orig, storage); |
| 200 } | 199 } |
| 201 | 200 |
| 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 | |
| 210 private: | 201 private: |
| 211 friend const SkPaint& ToSkPaint(const PaintFlags& flags); | 202 friend const SkPaint& ToSkPaint(const PaintFlags& flags); |
| 212 friend const SkPaint* ToSkPaint(const PaintFlags* flags); | 203 friend const SkPaint* ToSkPaint(const PaintFlags* flags); |
| 213 | 204 |
| 214 SkPaint paint_; | 205 SkPaint paint_; |
| 215 }; | 206 }; |
| 216 | 207 |
| 217 ALWAYS_INLINE const SkPaint& ToSkPaint(const PaintFlags& flags) { | 208 ALWAYS_INLINE const SkPaint& ToSkPaint(const PaintFlags& flags) { |
| 218 return flags.paint_; | 209 return flags.paint_; |
| 219 } | 210 } |
| 220 | 211 |
| 221 ALWAYS_INLINE const SkPaint* ToSkPaint(const PaintFlags* flags) { | 212 ALWAYS_INLINE const SkPaint* ToSkPaint(const PaintFlags* flags) { |
| 222 return &flags->paint_; | 213 return &flags->paint_; |
| 223 } | 214 } |
| 224 | 215 |
| 225 } // namespace cc | 216 } // namespace cc |
| 226 | 217 |
| 227 #endif // CC_PAINT_PAINT_FLAGS_H_ | 218 #endif // CC_PAINT_PAINT_FLAGS_H_ |
| OLD | NEW |