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 "SkPDFShader.h" |
| 11 #include "SkThread.h" |
| 12 #include "SkTDArray.h" |
| 13 |
| 14 struct SkIRect; |
| 15 class SkMatrix; |
| 16 class SkPDFFont; |
| 17 class SkPDFGraphicState; |
| 18 class SkPaint; |
| 19 class SkShader; |
| 20 |
| 21 // This class's fields and methods will eventually become part of |
| 22 // SkPDFDocument/SkDocument_PDF. For now, it exists as a singleton to |
| 23 // preflight that transition. This replaces three global arrays in |
| 24 // SkPDFFont, SkPDFShader, and SkPDFGraphicsContext. |
| 25 // |
| 26 // IF YOU ARE LOOKING AT THIS API PLEASE DO NOT WRITE THE CHANGE |
| 27 // YOU ARE ABOUT TO WRITE WITHOUT TALKING TO HALCANARY@. |
| 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 : SkNoncopyable { |
| 33 public: |
| 34 SkPDFCanon(); |
| 35 ~SkPDFCanon(); |
| 36 |
| 37 static SkPDFCanon& GetCanon(); |
| 38 |
| 39 // This mutexes will be removed once this class is subsumed into |
| 40 // SkPDFDocument. |
| 41 static SkBaseMutex& GetFontMutex(); |
| 42 static SkBaseMutex& GetShaderMutex(); |
| 43 static SkBaseMutex& GetPaintMutex(); |
| 44 |
| 45 // Returns exact match if there is one. If not, it returns NULL. |
| 46 // If there is no exact match, but there is a related font, we |
| 47 // still return NULL, but also set *relatedFont. |
| 48 SkPDFFont* findFont(uint32_t fontID, |
| 49 uint16_t glyphID, |
| 50 SkPDFFont** relatedFont) const; |
| 51 void addFont(SkPDFFont* font, uint32_t fontID, uint16_t fGlyphID); |
| 52 void removeFont(SkPDFFont*); |
| 53 |
| 54 SkPDFShader* findShader(const SkPDFShader::State&) const; |
| 55 void addShader(SkPDFShader*); |
| 56 void removeShader(SkPDFShader*); |
| 57 |
| 58 SkPDFGraphicState* findGraphicState(const SkPaint&) const; |
| 59 void addGraphicState(SkPDFGraphicState*); |
| 60 void removeGraphicState(SkPDFGraphicState*); |
| 61 |
| 62 private: |
| 63 struct FontRec { |
| 64 SkPDFFont* fFont; |
| 65 uint32_t fFontID; |
| 66 uint16_t fGlyphID; |
| 67 }; |
| 68 SkTDArray<FontRec> fFontRecords; |
| 69 |
| 70 SkTDArray<SkPDFShader*> fShaderRecords; |
| 71 |
| 72 SkTDArray<SkPDFGraphicState*> fGraphicStateRecords; |
| 73 }; |
| 74 #endif // SkPDFCanon_DEFINED |
OLD | NEW |