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

Unified Diff: src/pdf/SkPDFShader.h

Issue 873543002: More changes to SkPDFShader to eliminate multiple inheritance! (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 11 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: src/pdf/SkPDFShader.h
diff --git a/src/pdf/SkPDFShader.h b/src/pdf/SkPDFShader.h
index 10532156ad20b77d742b618154d56e25f599e53f..1547aaf8c4d53ccc39e493290cb4055d0d21a42c 100644
--- a/src/pdf/SkPDFShader.h
+++ b/src/pdf/SkPDFShader.h
@@ -10,14 +10,13 @@
#ifndef SkPDFShader_DEFINED
#define SkPDFShader_DEFINED
+#include "SkPDFResourceDict.h"
#include "SkPDFStream.h"
#include "SkPDFTypes.h"
-#include "SkMatrix.h"
-#include "SkRefCnt.h"
-#include "SkShader.h"
-class SkObjRef;
-class SkPDFCatalog;
+class SkMatrix;
+class SkShader;
+struct SkIRect;
/** \class SkPDFShader
@@ -27,6 +26,8 @@ class SkPDFCatalog;
class SkPDFShader {
public:
+ class State;
+
/** Get the PDF shader for the passed SkShader. If the SkShader is
* invalid in some way, returns NULL. The reference count of
* the object is incremented and it is the caller's responsibility to
@@ -38,28 +39,64 @@ public:
* positioned, relative to where the page is drawn.)
* @param surfceBBox The bounding box of the drawing surface (with matrix
* already applied).
- * @param rasterScale Additional scale to be applied for early rasterization.
+ * @param rasterScale Additional scale to be applied for early
+ * rasterization.
*/
static SkPDFObject* GetPDFShader(const SkShader& shader,
const SkMatrix& matrix,
const SkIRect& surfaceBBox,
SkScalar rasterScale);
+};
- class State;
+class SkPDFFunctionShader : public SkPDFDict {
+ SK_DECLARE_INST_COUNT(SkPDFFunctionShader);
+
+public:
+ static SkPDFFunctionShader* Create(SkAutoTDelete<SkPDFShader::State>*);
+ virtual ~SkPDFFunctionShader();
bool equals(const SkPDFShader::State&) const;
+ void getResources(const SkTSet<SkPDFObject*>&,
+ SkTSet<SkPDFObject*>*) SK_OVERRIDE;
+
+private:
+ SkAutoTDelete<const SkPDFShader::State> fShaderState;
+ SkTDArray<SkPDFObject*> fResources;
+ explicit SkPDFFunctionShader(SkPDFShader::State* state);
+ typedef SkPDFDict INHERITED;
+};
-protected:
- SkAutoTDelete<const State> fShaderState;
+/**
+ * A shader for PDF gradients. This encapsulates the function shader
+ * inside a tiling pattern while providing a common pattern interface.
+ * The encapsulation allows the use of a SMask for transparency gradients.
+ */
+class SkPDFAlphaFunctionShader : public SkPDFStream {
+public:
+ static SkPDFAlphaFunctionShader* Create(SkAutoTDelete<SkPDFShader::State>*);
+ virtual ~SkPDFAlphaFunctionShader();
+ void getResources(const SkTSet<SkPDFObject*>&,
+ SkTSet<SkPDFObject*>*) SK_OVERRIDE;
+ bool equals(const SkPDFShader::State&) const;
- // This is an internal method.
- // CanonicalShadersMutex() should already be acquired.
- // This also takes ownership of shaderState.
- static SkPDFObject* GetPDFShaderByState(SkAutoTDelete<SkPDFShader::State>*);
+private:
+ SkAutoTDelete<const SkPDFShader::State> fShaderState;
+ SkAutoTUnref<SkPDFObject> fColorShader;
+ SkAutoTUnref<SkPDFResourceDict> fResourceDict;
+ explicit SkPDFAlphaFunctionShader(SkPDFShader::State* state);
+};
- SkPDFShader(State*);
- virtual ~SkPDFShader();
+class SkPDFImageShader : public SkPDFStream {
+public:
+ static SkPDFImageShader* Create(SkAutoTDelete<SkPDFShader::State>*);
+ virtual ~SkPDFImageShader();
+ void getResources(const SkTSet<SkPDFObject*>&,
+ SkTSet<SkPDFObject*>*) SK_OVERRIDE;
+ bool equals(const SkPDFShader::State&) const;
- virtual SkPDFObject* toPDFObject() = 0;
+private:
+ SkAutoTDelete<const SkPDFShader::State> fShaderState;
+ SkTSet<SkPDFObject*> fResources;
+ explicit SkPDFImageShader(SkPDFShader::State* state);
};
#endif

Powered by Google App Engine
This is Rietveld 408576698