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

Unified Diff: include/core/SkComposeShader.h

Issue 198193005: Work (in progress) to make SkShader immutable. (Closed) Base URL: https://skia.googlesource.com/skia.git@shaderGenerator
Patch Set: Created 6 years, 9 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
Index: include/core/SkComposeShader.h
diff --git a/include/core/SkComposeShader.h b/include/core/SkComposeShader.h
index 1fefd1369a1c3eec87146f43abeacd02b9aa0c54..438cd971b22a921c5bdb933f728826586299194c 100644
--- a/include/core/SkComposeShader.h
+++ b/include/core/SkComposeShader.h
@@ -20,7 +20,7 @@ class SkXfermode;
This subclass of shader returns the coposition of two other shaders, combined by
a xfermode.
*/
-class SK_API SkComposeShader : public SkShader {
+class SK_API SkComposeShader : public SkShaderGenerator {
public:
/** Create a new compose shader, given shaders A, B, and a combining xfermode mode.
When the xfermode is called, it will be given the result from shader A as its
@@ -31,13 +31,31 @@ public:
@param mode The xfermode that combines the colors from the two shaders. If mode
is null, then SRC_OVER is assumed.
*/
- SkComposeShader(SkShader* sA, SkShader* sB, SkXfermode* mode = NULL);
+ SkComposeShader(SkShaderGenerator* sA, SkShaderGenerator* sB, SkXfermode* mode = NULL);
virtual ~SkComposeShader();
- virtual bool setContext(const SkBitmap&, const SkPaint&,
- const SkMatrix&) SK_OVERRIDE;
- virtual void endContext() SK_OVERRIDE;
- virtual void shadeSpan(int x, int y, SkPMColor[], int count) SK_OVERRIDE;
+ virtual size_t shaderImplSize() const SK_OVERRIDE;
+
+ virtual bool validContext(const SkBitmap&, const SkPaint&,
+ const SkMatrix&) SK_OVERRIDE;
+
+ virtual ShaderImpl* createShaderImpl(const SkBitmap&, const SkPaint&,
+ const SkMatrix&, void*) const SK_OVERRIDE;
+
+ class ComposeImpl : public ShaderImpl {
+ public:
+ // Takes ownership of implA and implB, and calls their destructors.
+ ComposeImpl(const SkComposeShader&, const SkBitmap&, const SkPaint&,
+ const SkMatrix&, ShaderImpl* implA, ShaderImpl* implB);
+
+ ~ComposeImpl();
+
+ virtual void shadeSpan(int x, int y, SkPMColor[], int count) SK_OVERRIDE;
+ private:
+ ShaderImpl* fShaderImplA;
+ ShaderImpl* fShaderImplB;
+ };
+
SK_DEVELOPER_TO_STRING()
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeShader)
@@ -48,11 +66,13 @@ protected:
private:
- SkShader* fShaderA;
- SkShader* fShaderB;
+ SkShaderGenerator* fShaderA;
+ SkShaderGenerator* fShaderB;
SkXfermode* fMode;
- typedef SkShader INHERITED;
+ friend class ComposeImpl;
+
+ typedef SkShaderGenerator INHERITED;
};
#endif

Powered by Google App Engine
This is Rietveld 408576698