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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/paint/paint_flags.h
diff --git a/cc/paint/paint_flags.h b/cc/paint/paint_flags.h
index c884098e555d0fa5af2f75025c4553b02bf3f2a5..b8e5fb866c7ad29092a9c10d08120dfab117a867 100644
--- a/cc/paint/paint_flags.h
+++ b/cc/paint/paint_flags.h
@@ -7,6 +7,7 @@
#include "base/compiler_specific.h"
#include "cc/paint/paint_export.h"
+#include "cc/paint/paint_shader.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColorFilter.h"
#include "third_party/skia/include/core/SkDrawLooper.h"
@@ -19,8 +20,6 @@
namespace cc {
-using PaintShader = SkShader;
-
class CC_PAINT_EXPORT PaintFlags {
public:
enum Style {
@@ -160,9 +159,21 @@ class CC_PAINT_EXPORT PaintFlags {
ALWAYS_INLINE void setMaskFilter(sk_sp<SkMaskFilter> mask) {
paint_.setMaskFilter(std::move(mask));
}
- ALWAYS_INLINE PaintShader* getShader() const { return paint_.getShader(); }
- ALWAYS_INLINE void setShader(sk_sp<PaintShader> shader) {
- paint_.setShader(std::move(shader));
+ // TODO(vmpstr): Remove this from recording calls, since we want to avoid
+ // constructing the shader until rasterization.
+ ALWAYS_INLINE SkShader* getSkShader() const { return paint_.getShader(); }
+
+ // Returns true if the shader has been set on the flags.
+ ALWAYS_INLINE bool HasShader() const { return !!paint_.getShader(); }
+
+ // Returns whether the shader is opaque. Note that it is only valid to call
+ // this function if HasShader() returns true.
+ ALWAYS_INLINE bool ShaderIsOpaque() const {
+ return paint_.getShader()->isOpaque();
+ }
+
+ ALWAYS_INLINE void setShader(std::unique_ptr<PaintShader> shader) {
+ paint_.setShader(shader ? shader->sk_shader() : nullptr);
}
ALWAYS_INLINE SkPathEffect* getPathEffect() const {
return paint_.getPathEffect();
« 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