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

Unified Diff: include/core/SkShader.h

Issue 264843006: create struct to hold all the params passed around for shader::context (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: address review comments Created 6 years, 8 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 | « include/core/SkEmptyShader.h ('k') | include/effects/SkPerlinNoiseShader.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkShader.h
diff --git a/include/core/SkShader.h b/include/core/SkShader.h
index b0a7fd9f8a1474c2872bf9851ca163551f7933d1..32707d7313c789af8118cd9c4510aa94d715c5a9 100644
--- a/include/core/SkShader.h
+++ b/include/core/SkShader.h
@@ -119,10 +119,26 @@ public:
*/
virtual bool isOpaque() const { return false; }
+ /**
+ * ContextRec acts as a parameter bundle for creating Contexts.
+ */
+ struct ContextRec {
+ ContextRec() : fDevice(NULL), fPaint(NULL), fMatrix(NULL) {}
+ ContextRec(const ContextRec& other)
+ : fDevice(other.fDevice), fPaint(other.fPaint), fMatrix(other.fMatrix) {}
+ ContextRec(const SkBitmap& device, const SkPaint& paint, const SkMatrix& matrix)
+ : fDevice(&device)
+ , fPaint(&paint)
+ , fMatrix(&matrix) {}
+
+ const SkBitmap* fDevice; // the bitmap we are drawing into
+ const SkPaint* fPaint; // the current paint associated with the draw
+ const SkMatrix* fMatrix; // the current matrix in the canvas
+ };
+
class Context : public ::SkNoncopyable {
public:
- Context(const SkShader& shader, const SkBitmap& device,
- const SkPaint& paint, const SkMatrix& matrix);
+ Context(const SkShader& shader, const ContextRec&);
virtual ~Context();
@@ -200,8 +216,7 @@ public:
* Subclasses should be sure to call their INHERITED::validContext() if
* they override this method.
*/
- virtual bool validContext(const SkBitmap& device, const SkPaint& paint,
- const SkMatrix& matrix, SkMatrix* totalInverse = NULL) const;
+ virtual bool validContext(const ContextRec&, SkMatrix* totalInverse = NULL) const;
/**
* Create the actual object that does the shading.
@@ -211,10 +226,7 @@ public:
*
* Base class implementation returns NULL.
*/
- virtual Context* createContext(const SkBitmap& device,
- const SkPaint& paint,
- const SkMatrix& matrix,
- void* storage) const;
+ virtual Context* createContext(const ContextRec&, void* storage) const;
/**
* Return the size of a Context returned by createContext.
« no previous file with comments | « include/core/SkEmptyShader.h ('k') | include/effects/SkPerlinNoiseShader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698