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

Side by Side Diff: src/pdf/SkPDFShader.h

Issue 944643002: PDF: Now threadsafe! (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: formatting Created 5 years, 10 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 unified diff | Download patch
OLDNEW
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 "SkPDFResourceDict.h" 13 #include "SkPDFResourceDict.h"
14 #include "SkPDFStream.h" 14 #include "SkPDFStream.h"
15 #include "SkPDFTypes.h" 15 #include "SkPDFTypes.h"
16 16
17 class SkPDFCanon;
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 NULL. The reference count of 33 * invalid in some way, returns NULL. 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(const SkShader& shader, 46 static SkPDFObject* GetPDFShader(SkPDFCanon* canon,
47 const SkShader& shader,
46 const SkMatrix& matrix, 48 const SkMatrix& matrix,
47 const SkIRect& surfaceBBox, 49 const SkIRect& surfaceBBox,
48 SkScalar rasterScale); 50 SkScalar rasterScale);
49 }; 51 };
50 52
51 class SkPDFFunctionShader : public SkPDFDict { 53 class SkPDFFunctionShader : public SkPDFDict {
52 SK_DECLARE_INST_COUNT(SkPDFFunctionShader); 54 SK_DECLARE_INST_COUNT(SkPDFFunctionShader);
53 55
54 public: 56 public:
55 static SkPDFFunctionShader* Create(SkAutoTDelete<SkPDFShader::State>*); 57 static SkPDFFunctionShader* Create(SkPDFCanon*,
58 SkAutoTDelete<SkPDFShader::State>*);
56 virtual ~SkPDFFunctionShader(); 59 virtual ~SkPDFFunctionShader();
57 bool equals(const SkPDFShader::State&) const; 60 bool equals(const SkPDFShader::State&) const;
58 61
59 private: 62 private:
63 SkPDFCanon* fCanon;
60 SkAutoTDelete<const SkPDFShader::State> fShaderState; 64 SkAutoTDelete<const SkPDFShader::State> fShaderState;
61 SkTDArray<SkPDFObject*> fResources; 65 SkTDArray<SkPDFObject*> fResources;
62 explicit SkPDFFunctionShader(SkPDFShader::State* state); 66 SkPDFFunctionShader(SkPDFCanon*, SkPDFShader::State*);
63 typedef SkPDFDict INHERITED; 67 typedef SkPDFDict INHERITED;
64 }; 68 };
65 69
66 /** 70 /**
67 * A shader for PDF gradients. This encapsulates the function shader 71 * A shader for PDF gradients. This encapsulates the function shader
68 * inside a tiling pattern while providing a common pattern interface. 72 * inside a tiling pattern while providing a common pattern interface.
69 * The encapsulation allows the use of a SMask for transparency gradients. 73 * The encapsulation allows the use of a SMask for transparency gradients.
70 */ 74 */
71 class SkPDFAlphaFunctionShader : public SkPDFStream { 75 class SkPDFAlphaFunctionShader : public SkPDFStream {
72 public: 76 public:
73 static SkPDFAlphaFunctionShader* Create(SkAutoTDelete<SkPDFShader::State>*); 77 static SkPDFAlphaFunctionShader* Create(SkPDFCanon*,
78 SkAutoTDelete<SkPDFShader::State>*);
74 virtual ~SkPDFAlphaFunctionShader(); 79 virtual ~SkPDFAlphaFunctionShader();
75 bool equals(const SkPDFShader::State&) const; 80 bool equals(const SkPDFShader::State&) const;
76 81
77 private: 82 private:
83 SkPDFCanon* fCanon;
78 SkAutoTDelete<const SkPDFShader::State> fShaderState; 84 SkAutoTDelete<const SkPDFShader::State> fShaderState;
79 SkAutoTUnref<SkPDFObject> fColorShader; 85 SkAutoTUnref<SkPDFObject> fColorShader;
80 SkAutoTUnref<SkPDFResourceDict> fResourceDict; 86 SkAutoTUnref<SkPDFResourceDict> fResourceDict;
81 explicit SkPDFAlphaFunctionShader(SkPDFShader::State* state); 87 SkPDFAlphaFunctionShader(SkPDFCanon*, SkPDFShader::State*);
82 }; 88 };
83 89
84 class SkPDFImageShader : public SkPDFStream { 90 class SkPDFImageShader : public SkPDFStream {
85 public: 91 public:
86 static SkPDFImageShader* Create(SkAutoTDelete<SkPDFShader::State>*); 92 static SkPDFImageShader* Create(SkPDFCanon*,
93 SkAutoTDelete<SkPDFShader::State>*);
87 virtual ~SkPDFImageShader(); 94 virtual ~SkPDFImageShader();
88 bool equals(const SkPDFShader::State&) const; 95 bool equals(const SkPDFShader::State&) const;
89 96
90 private: 97 private:
98 SkPDFCanon* fCanon;
91 SkAutoTDelete<const SkPDFShader::State> fShaderState; 99 SkAutoTDelete<const SkPDFShader::State> fShaderState;
92 SkTSet<SkPDFObject*> fResources; 100 SkTSet<SkPDFObject*> fResources;
93 explicit SkPDFImageShader(SkPDFShader::State* state); 101 SkPDFImageShader(SkPDFCanon*, SkPDFShader::State*);
94 }; 102 };
95 103
96 #endif 104 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698