Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: cc/paint/paint_flags.h

Issue 2893083002: cc: Move SkShader construction to a single spot in PaintShader (Closed)
Patch Set: update Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/paint/discardable_image_store.cc ('k') | cc/paint/paint_flags.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/SkShader.h" 18 #include "third_party/skia/include/core/SkShader.h"
18 #include "third_party/skia/include/core/SkTypeface.h" 19 #include "third_party/skia/include/core/SkTypeface.h"
19 20
20 namespace cc { 21 namespace cc {
21 22
22 using PaintShader = SkShader;
23
24 class CC_PAINT_EXPORT PaintFlags { 23 class CC_PAINT_EXPORT PaintFlags {
25 public: 24 public:
26 enum Style { 25 enum Style {
27 kFill_Style = SkPaint::kFill_Style, 26 kFill_Style = SkPaint::kFill_Style,
28 kStroke_Style = SkPaint::kStroke_Style, 27 kStroke_Style = SkPaint::kStroke_Style,
29 kStrokeAndFill_Style = SkPaint::kStrokeAndFill_Style, 28 kStrokeAndFill_Style = SkPaint::kStrokeAndFill_Style,
30 }; 29 };
31 ALWAYS_INLINE Style getStyle() const { 30 ALWAYS_INLINE Style getStyle() const {
32 return static_cast<Style>(paint_.getStyle()); 31 return static_cast<Style>(paint_.getStyle());
33 } 32 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 } 152 }
154 ALWAYS_INLINE void setColorFilter(sk_sp<SkColorFilter> filter) { 153 ALWAYS_INLINE void setColorFilter(sk_sp<SkColorFilter> filter) {
155 paint_.setColorFilter(std::move(filter)); 154 paint_.setColorFilter(std::move(filter));
156 } 155 }
157 ALWAYS_INLINE SkMaskFilter* getMaskFilter() const { 156 ALWAYS_INLINE SkMaskFilter* getMaskFilter() const {
158 return paint_.getMaskFilter(); 157 return paint_.getMaskFilter();
159 } 158 }
160 ALWAYS_INLINE void setMaskFilter(sk_sp<SkMaskFilter> mask) { 159 ALWAYS_INLINE void setMaskFilter(sk_sp<SkMaskFilter> mask) {
161 paint_.setMaskFilter(std::move(mask)); 160 paint_.setMaskFilter(std::move(mask));
162 } 161 }
163 ALWAYS_INLINE PaintShader* getShader() const { return paint_.getShader(); } 162 // TODO(vmpstr): Remove this from recording calls, since we want to avoid
164 ALWAYS_INLINE void setShader(sk_sp<PaintShader> shader) { 163 // constructing the shader until rasterization.
165 paint_.setShader(std::move(shader)); 164 ALWAYS_INLINE SkShader* getSkShader() const { return paint_.getShader(); }
165
166 // Returns true if the shader has been set on the flags.
167 ALWAYS_INLINE bool HasShader() const { return !!paint_.getShader(); }
168
169 // Returns whether the shader is opaque. Note that it is only valid to call
170 // this function if HasShader() returns true.
171 ALWAYS_INLINE bool ShaderIsOpaque() const {
172 return paint_.getShader()->isOpaque();
173 }
174
175 ALWAYS_INLINE void setShader(std::unique_ptr<PaintShader> shader) {
176 paint_.setShader(shader ? shader->sk_shader() : nullptr);
166 } 177 }
167 ALWAYS_INLINE SkPathEffect* getPathEffect() const { 178 ALWAYS_INLINE SkPathEffect* getPathEffect() const {
168 return paint_.getPathEffect(); 179 return paint_.getPathEffect();
169 } 180 }
170 ALWAYS_INLINE void setPathEffect(sk_sp<SkPathEffect> effect) { 181 ALWAYS_INLINE void setPathEffect(sk_sp<SkPathEffect> effect) {
171 paint_.setPathEffect(std::move(effect)); 182 paint_.setPathEffect(std::move(effect));
172 } 183 }
173 ALWAYS_INLINE bool getFillPath(const SkPath& src, 184 ALWAYS_INLINE bool getFillPath(const SkPath& src,
174 SkPath* dst, 185 SkPath* dst,
175 const SkRect* cullRect = nullptr, 186 const SkRect* cullRect = nullptr,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 return flags.paint_; 230 return flags.paint_;
220 } 231 }
221 232
222 ALWAYS_INLINE const SkPaint* ToSkPaint(const PaintFlags* flags) { 233 ALWAYS_INLINE const SkPaint* ToSkPaint(const PaintFlags* flags) {
223 return &flags->paint_; 234 return &flags->paint_;
224 } 235 }
225 236
226 } // namespace cc 237 } // namespace cc
227 238
228 #endif // CC_PAINT_PAINT_FLAGS_H_ 239 #endif // CC_PAINT_PAINT_FLAGS_H_
OLDNEW
« no previous file with comments | « cc/paint/discardable_image_store.cc ('k') | cc/paint/paint_flags.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698