OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 #ifndef SkPDFCanon_DEFINED | 7 #ifndef SkPDFCanon_DEFINED |
8 #define SkPDFCanon_DEFINED | 8 #define SkPDFCanon_DEFINED |
9 | 9 |
10 #include "SkPDFShader.h" | 10 #include "SkPDFShader.h" |
11 #include "SkThread.h" | |
12 #include "SkTDArray.h" | 11 #include "SkTDArray.h" |
13 | 12 |
14 struct SkIRect; | |
15 class SkBitmap; | 13 class SkBitmap; |
16 class SkMatrix; | |
17 class SkPDFFont; | 14 class SkPDFFont; |
18 class SkPDFGraphicState; | 15 class SkPDFGraphicState; |
19 class SkPDFBitmap; | 16 class SkPDFBitmap; |
20 class SkPaint; | 17 class SkPaint; |
21 | 18 |
22 // This class's fields and methods will eventually become part of | 19 /** |
23 // SkPDFDocument/SkDocument_PDF. For now, it exists as a singleton to | 20 * The SkPDFCanon canonicalizes objects across PDF pages(SkPDFDevices). |
24 // preflight that transition. This replaces three global arrays in | 21 * |
25 // SkPDFFont, SkPDFShader, and SkPDFGraphicsContext. | 22 * The PDF backend works correctly if: |
26 // | 23 * - There is no more than one SkPDFCanon for each thread. |
27 // IF YOU ARE LOOKING AT THIS API PLEASE DO NOT WRITE THE CHANGE | 24 * - Every SkPDFDevice is given a pointer to a SkPDFCanon on creation. |
28 // YOU ARE ABOUT TO WRITE WITHOUT TALKING TO HALCANARY@. | 25 * - All SkPDFDevices in a document share the same SkPDFCanon. |
29 // | 26 * The SkDocument_PDF class makes this happen by owning a single |
30 // Note that this class does not create, delete, reference or | 27 * SkPDFCanon. |
31 // dereference the SkPDFObject objects that it indexes. It is up to | 28 * |
32 // the caller to manage the lifetime of these objects. | 29 * Note that this class does not create, delete, reference or |
| 30 * dereference the SkPDFObject objects that it indexes. It is up to |
| 31 * the caller to manage the lifetime of these objects. |
| 32 */ |
33 class SkPDFCanon : SkNoncopyable { | 33 class SkPDFCanon : SkNoncopyable { |
34 public: | 34 public: |
35 SkPDFCanon(); | 35 SkPDFCanon(); |
36 ~SkPDFCanon(); | 36 ~SkPDFCanon(); |
37 | 37 |
38 static SkPDFCanon& GetCanon(); | |
39 | |
40 // This mutexes will be removed once this class is subsumed into | |
41 // SkPDFDocument. | |
42 static SkBaseMutex& GetFontMutex(); | |
43 static SkBaseMutex& GetShaderMutex(); | |
44 static SkBaseMutex& GetPaintMutex(); | |
45 static SkBaseMutex& GetBitmapMutex(); | |
46 | |
47 // Returns exact match if there is one. If not, it returns NULL. | 38 // Returns exact match if there is one. If not, it returns NULL. |
48 // If there is no exact match, but there is a related font, we | 39 // If there is no exact match, but there is a related font, we |
49 // still return NULL, but also set *relatedFont. | 40 // still return NULL, but also set *relatedFont. |
50 SkPDFFont* findFont(uint32_t fontID, | 41 SkPDFFont* findFont(uint32_t fontID, |
51 uint16_t glyphID, | 42 uint16_t glyphID, |
52 SkPDFFont** relatedFont) const; | 43 SkPDFFont** relatedFont) const; |
53 void addFont(SkPDFFont* font, uint32_t fontID, uint16_t fGlyphID); | 44 void addFont(SkPDFFont* font, uint32_t fontID, uint16_t fGlyphID); |
54 void removeFont(SkPDFFont*); | 45 void removeFont(SkPDFFont*); |
55 | 46 |
56 SkPDFFunctionShader* findFunctionShader(const SkPDFShader::State&) const; | 47 SkPDFFunctionShader* findFunctionShader(const SkPDFShader::State&) const; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 | 85 |
95 SkTDArray<SkPDFAlphaFunctionShader*> fAlphaShaderRecords; | 86 SkTDArray<SkPDFAlphaFunctionShader*> fAlphaShaderRecords; |
96 | 87 |
97 SkTDArray<SkPDFImageShader*> fImageShaderRecords; | 88 SkTDArray<SkPDFImageShader*> fImageShaderRecords; |
98 | 89 |
99 SkTDArray<SkPDFGraphicState*> fGraphicStateRecords; | 90 SkTDArray<SkPDFGraphicState*> fGraphicStateRecords; |
100 | 91 |
101 SkTDArray<SkPDFBitmap*> fBitmapRecords; | 92 SkTDArray<SkPDFBitmap*> fBitmapRecords; |
102 }; | 93 }; |
103 #endif // SkPDFCanon_DEFINED | 94 #endif // SkPDFCanon_DEFINED |
OLD | NEW |