Chromium Code Reviews| 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 { |
|
tomhudson
2016/08/02 20:59:12
This goes from hidden to public and mostly unencap
hal.canary
2016/08/02 21:25:01
SkPDFCanon now uses this directly, rather than via
|
| + 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 |