OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2015 Google Inc. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license that can be | |
5 * found in the LICENSE file. | |
6 */ | |
7 #ifndef SkPDFCanon_DEFINED | |
8 #define SkPDFCanon_DEFINED | |
9 | |
10 #include "SkThread.h" | |
11 #include "SkTDArray.h" | |
12 | |
13 class SkBaseMutex; | |
14 class SkIRect; | |
15 class SkMatrix; | |
16 class SkPDFFont; | |
17 class SkPDFGraphicState; | |
18 class SkPDFShader; | |
19 class SkPDFShaderState; | |
20 class SkPaint; | |
21 class SkShader; | |
22 class SkTypeface; | |
23 | |
24 // This class's fields and methods will eventually become part of | |
25 // SkPDFDocument/SkDocument_PDF. For now, it exists as a singleton to | |
26 // preflight that transition. This replaces three global arrays in | |
27 // SkPDFFont, SkPDFShader, and SkPDFGraphicsContext. | |
28 // | |
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 class SkPDFCanon { | |
33 public: | |
34 static SkPDFCanon& GetCanon(); | |
35 | |
36 // This mutexes will be removed once this class is subsumed into | |
37 // SkPDFDocument. | |
mtklein
2015/01/20 21:59:51
Let's be louder about how much of a minefield this
hal.canary
2015/01/21 17:07:50
Done.
| |
38 static SkBaseMutex& GetFontMutex(); | |
39 static SkBaseMutex& GetShaderMutex(); | |
40 static SkBaseMutex& GetPaintMutex(); | |
41 | |
42 SkPDFFont* findFont(uint32_t fontID, | |
mtklein
2015/01/20 21:59:51
Add a brief comment for this? The others look str
hal.canary
2015/01/21 17:07:50
Done.
| |
43 uint16_t glyphID, | |
44 SkPDFFont** relatedFont) const; | |
45 void addFont(SkPDFFont* font, uint32_t fontID, uint16_t fGlyphID); | |
46 void removeFont(SkPDFFont*); | |
47 | |
48 SkPDFShader* findShader(const SkPDFShaderState&) const; | |
49 void addShader(SkPDFShader*); | |
50 void removeShader(SkPDFShader*); | |
51 | |
52 SkPDFGraphicState* findGraphicState(const SkPaint&) const; | |
53 void addGraphicState(SkPDFGraphicState*); | |
54 void removeGraphicState(SkPDFGraphicState*); | |
55 | |
56 private: | |
57 struct FontRec { | |
58 SkPDFFont* fFont; | |
59 uint32_t fFontID; | |
60 uint16_t fGlyphID; | |
61 }; | |
62 SkTDArray<FontRec> fFontRecords; | |
63 | |
64 SkTDArray<SkPDFShader*> fShaderRecords; | |
65 | |
66 SkTDArray<SkPDFGraphicState*> fGraphicStateRecords; | |
67 | |
68 SkBaseMutex* fFontMutex; | |
djsollen
2015/01/21 14:10:27
why pointers to global variables? if the cannon is
mtklein
2015/01/21 15:14:40
I missed this the first time around. I too don't
hal.canary
2015/01/21 17:07:50
Acknowledged.
hal.canary
2015/01/21 17:07:50
I forgot to delete those.
| |
69 SkBaseMutex* fShaderMutex; | |
70 SkBaseMutex* fPaintMutex; | |
71 | |
72 SkPDFCanon(); | |
73 ~SkPDFCanon(); | |
74 static SkPDFCanon* Create(); | |
djsollen
2015/01/21 14:10:27
Any reason to expose the Create/Destroy functions
mtklein
2015/01/21 15:14:40
I believe this allows the constructor and destruct
hal.canary
2015/01/21 17:07:50
Acknowledged.
hal.canary
2015/01/21 17:07:50
I needed to because I made the constructor private
| |
75 static void Destroy(SkPDFCanon*); | |
76 }; | |
77 #endif // SkPDFCanon_DEFINED | |
OLD | NEW |