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

Unified Diff: src/pdf/SkPDFShader.h

Issue 2193973002: SkPDF: PDFShader code modernized. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-08-02 (Tuesday) 17:24:52 EDT Created 4 years, 4 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 | « src/pdf/SkPDFGraphicState.cpp ('k') | src/pdf/SkPDFShader.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFShader.h
diff --git a/src/pdf/SkPDFShader.h b/src/pdf/SkPDFShader.h
index a6d36b6f021bc9b6e349c261eaf92d7831c5e770..db13cd50b358a385b4eb9968322fcedfa2f541e3 100644
--- a/src/pdf/SkPDFShader.h
+++ b/src/pdf/SkPDFShader.h
@@ -9,12 +9,13 @@
#ifndef SkPDFShader_DEFINED
#define SkPDFShader_DEFINED
+#include "SkBitmapKey.h"
#include "SkPDFTypes.h"
+#include "SkShader.h"
class SkPDFCanon;
class SkPDFDocument;
class SkMatrix;
-class SkShader;
struct SkIRect;
/** \class SkPDFShader
@@ -25,8 +26,6 @@ struct SkIRect;
class SkPDFShader {
public:
- class State;
-
/** Get the PDF shader for the passed SkShader. If the SkShader is
* invalid in some way, returns nullptr. The reference count of
* the object is incremented and it is the caller's responsibility to
@@ -41,60 +40,47 @@ public:
* @param rasterScale Additional scale to be applied for early
* rasterization.
*/
- static SkPDFObject* GetPDFShader(SkPDFDocument* doc,
- SkScalar dpi,
- SkShader* shader,
- const SkMatrix& matrix,
- const SkIRect& surfaceBBox,
- SkScalar rasterScale);
+ static sk_sp<SkPDFObject> GetPDFShader(SkPDFDocument* doc,
+ SkScalar dpi,
+ SkShader* shader,
+ const SkMatrix& matrix,
+ const SkIRect& surfaceBBox,
+ SkScalar rasterScale);
static sk_sp<SkPDFArray> MakeRangeObject();
-};
-class SkPDFFunctionShader final : public SkPDFDict {
-public:
- static SkPDFFunctionShader* Create(SkPDFCanon*,
- std::unique_ptr<SkPDFShader::State>*);
- virtual ~SkPDFFunctionShader();
- bool equals(const SkPDFShader::State&) const;
-
-private:
- std::unique_ptr<const SkPDFShader::State> fShaderState;
- SkPDFFunctionShader(SkPDFShader::State*);
- typedef SkPDFDict INHERITED;
-};
+ class State {
+ public:
+ SkShader::GradientType fType;
+ SkShader::GradientInfo fInfo;
+ std::unique_ptr<SkColor[]> fColors;
+ std::unique_ptr<SkScalar[]> fStops;
+ SkMatrix fCanvasTransform;
+ SkMatrix fShaderTransform;
+ SkIRect fBBox;
-/**
- * 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 final : public SkPDFStream {
-public:
- static SkPDFAlphaFunctionShader* Create(SkPDFDocument*,
- SkScalar dpi,
- std::unique_ptr<SkPDFShader::State>*);
- virtual ~SkPDFAlphaFunctionShader();
- bool equals(const SkPDFShader::State&) const;
-
-private:
- std::unique_ptr<const SkPDFShader::State> fShaderState;
- SkPDFAlphaFunctionShader(SkPDFShader::State*);
- typedef SkPDFStream INHERITED;
-};
+ SkBitmapKey fBitmapKey;
+ SkShader::TileMode fImageTileModes[2];
-class SkPDFImageShader final : public SkPDFStream {
-public:
- static SkPDFImageShader* Create(SkPDFDocument*,
- SkScalar dpi,
- std::unique_ptr<SkPDFShader::State>*);
- virtual ~SkPDFImageShader();
- bool equals(const SkPDFShader::State&) const;
-
-private:
- std::unique_ptr<const SkPDFShader::State> fShaderState;
- SkPDFImageShader(SkPDFShader::State*);
- typedef SkPDFStream INHERITED;
+ State(SkShader* shader, const SkMatrix& canvasTransform,
+ const SkIRect& bbox, SkScalar rasterScale,
+ SkBitmap* dstImage);
+
+ bool operator==(const State& b) const;
+
+ State MakeAlphaToLuminosityState() const;
+ State MakeOpaqueState() const;
+
+ bool GradientHasAlpha() const;
+
+ State(State&&) = default;
+ State& operator=(State&&) = default;
+
+ private:
+ State(const State& other);
+ State& operator=(const State& rhs);
+ void allocateGradientInfoStorage();
+ };
};
#endif
« no previous file with comments | « src/pdf/SkPDFGraphicState.cpp ('k') | src/pdf/SkPDFShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698