OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef SkPDFShader_DEFINED | 10 #ifndef SkPDFShader_DEFINED |
11 #define SkPDFShader_DEFINED | 11 #define SkPDFShader_DEFINED |
12 | 12 |
13 #include "SkPDFStream.h" | 13 #include "SkPDFStream.h" |
14 #include "SkPDFTypes.h" | 14 #include "SkPDFTypes.h" |
15 | 15 |
16 class SkPDFCanon; | 16 class SkPDFCanon; |
| 17 class SkPDFDocument; |
17 class SkMatrix; | 18 class SkMatrix; |
18 class SkShader; | 19 class SkShader; |
19 struct SkIRect; | 20 struct SkIRect; |
20 | 21 |
21 /** \class SkPDFShader | 22 /** \class SkPDFShader |
22 | 23 |
23 In PDF parlance, this is a pattern, used in place of a color when the | 24 In PDF parlance, this is a pattern, used in place of a color when the |
24 pattern color space is selected. | 25 pattern color space is selected. |
25 */ | 26 */ |
26 | 27 |
27 class SkPDFShader { | 28 class SkPDFShader { |
28 public: | 29 public: |
29 class State; | 30 class State; |
30 | 31 |
31 /** Get the PDF shader for the passed SkShader. If the SkShader is | 32 /** Get the PDF shader for the passed SkShader. If the SkShader is |
32 * invalid in some way, returns nullptr. The reference count of | 33 * invalid in some way, returns nullptr. The reference count of |
33 * the object is incremented and it is the caller's responsibility to | 34 * the object is incremented and it is the caller's responsibility to |
34 * unreference it when done. This is needed to accommodate the weak | 35 * unreference it when done. This is needed to accommodate the weak |
35 * reference pattern used when the returned object is new and has no | 36 * reference pattern used when the returned object is new and has no |
36 * other references. | 37 * other references. |
37 * @param shader The SkShader to emulate. | 38 * @param shader The SkShader to emulate. |
38 * @param matrix The current transform. (PDF shaders are absolutely | 39 * @param matrix The current transform. (PDF shaders are absolutely |
39 * positioned, relative to where the page is drawn.) | 40 * positioned, relative to where the page is drawn.) |
40 * @param surfceBBox The bounding box of the drawing surface (with matrix | 41 * @param surfceBBox The bounding box of the drawing surface (with matrix |
41 * already applied). | 42 * already applied). |
42 * @param rasterScale Additional scale to be applied for early | 43 * @param rasterScale Additional scale to be applied for early |
43 * rasterization. | 44 * rasterization. |
44 */ | 45 */ |
45 static SkPDFObject* GetPDFShader(SkPDFCanon* canon, | 46 static SkPDFObject* GetPDFShader(SkPDFDocument* doc, |
46 SkScalar dpi, | 47 SkScalar dpi, |
47 const SkShader& shader, | 48 const SkShader& shader, |
48 const SkMatrix& matrix, | 49 const SkMatrix& matrix, |
49 const SkIRect& surfaceBBox, | 50 const SkIRect& surfaceBBox, |
50 SkScalar rasterScale); | 51 SkScalar rasterScale); |
51 | 52 |
52 static sk_sp<SkPDFArray> MakeRangeObject(); | 53 static sk_sp<SkPDFArray> MakeRangeObject(); |
53 }; | 54 }; |
54 | 55 |
55 class SkPDFFunctionShader final : public SkPDFDict { | 56 class SkPDFFunctionShader final : public SkPDFDict { |
56 public: | 57 public: |
57 static SkPDFFunctionShader* Create(SkPDFCanon*, | 58 static SkPDFFunctionShader* Create(SkPDFCanon*, |
58 SkAutoTDelete<SkPDFShader::State>*); | 59 SkAutoTDelete<SkPDFShader::State>*); |
59 virtual ~SkPDFFunctionShader(); | 60 virtual ~SkPDFFunctionShader(); |
60 bool equals(const SkPDFShader::State&) const; | 61 bool equals(const SkPDFShader::State&) const; |
61 | 62 |
62 private: | 63 private: |
63 SkAutoTDelete<const SkPDFShader::State> fShaderState; | 64 SkAutoTDelete<const SkPDFShader::State> fShaderState; |
64 SkPDFFunctionShader(SkPDFShader::State*); | 65 SkPDFFunctionShader(SkPDFShader::State*); |
65 typedef SkPDFDict INHERITED; | 66 typedef SkPDFDict INHERITED; |
66 }; | 67 }; |
67 | 68 |
68 /** | 69 /** |
69 * A shader for PDF gradients. This encapsulates the function shader | 70 * A shader for PDF gradients. This encapsulates the function shader |
70 * inside a tiling pattern while providing a common pattern interface. | 71 * inside a tiling pattern while providing a common pattern interface. |
71 * The encapsulation allows the use of a SMask for transparency gradients. | 72 * The encapsulation allows the use of a SMask for transparency gradients. |
72 */ | 73 */ |
73 class SkPDFAlphaFunctionShader final : public SkPDFStream { | 74 class SkPDFAlphaFunctionShader final : public SkPDFStream { |
74 public: | 75 public: |
75 static SkPDFAlphaFunctionShader* Create(SkPDFCanon*, | 76 static SkPDFAlphaFunctionShader* Create(SkPDFDocument*, |
76 SkScalar dpi, | 77 SkScalar dpi, |
77 SkAutoTDelete<SkPDFShader::State>*); | 78 SkAutoTDelete<SkPDFShader::State>*); |
78 virtual ~SkPDFAlphaFunctionShader(); | 79 virtual ~SkPDFAlphaFunctionShader(); |
79 bool equals(const SkPDFShader::State&) const; | 80 bool equals(const SkPDFShader::State&) const; |
80 | 81 |
81 private: | 82 private: |
82 SkAutoTDelete<const SkPDFShader::State> fShaderState; | 83 SkAutoTDelete<const SkPDFShader::State> fShaderState; |
83 SkPDFAlphaFunctionShader(SkPDFShader::State*); | 84 SkPDFAlphaFunctionShader(SkPDFShader::State*); |
84 typedef SkPDFStream INHERITED; | 85 typedef SkPDFStream INHERITED; |
85 }; | 86 }; |
86 | 87 |
87 class SkPDFImageShader final : public SkPDFStream { | 88 class SkPDFImageShader final : public SkPDFStream { |
88 public: | 89 public: |
89 static SkPDFImageShader* Create(SkPDFCanon*, | 90 static SkPDFImageShader* Create(SkPDFDocument*, |
90 SkScalar dpi, | 91 SkScalar dpi, |
91 SkAutoTDelete<SkPDFShader::State>*); | 92 SkAutoTDelete<SkPDFShader::State>*); |
92 virtual ~SkPDFImageShader(); | 93 virtual ~SkPDFImageShader(); |
93 bool equals(const SkPDFShader::State&) const; | 94 bool equals(const SkPDFShader::State&) const; |
94 | 95 |
95 private: | 96 private: |
96 SkAutoTDelete<const SkPDFShader::State> fShaderState; | 97 SkAutoTDelete<const SkPDFShader::State> fShaderState; |
97 SkPDFImageShader(SkPDFShader::State*); | 98 SkPDFImageShader(SkPDFShader::State*); |
98 typedef SkPDFStream INHERITED; | 99 typedef SkPDFStream INHERITED; |
99 }; | 100 }; |
100 | 101 |
101 #endif | 102 #endif |
OLD | NEW |