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/SkPDFCanon.h

Issue 918813002: PDF: Add (low-memory) SkPDFBitmap class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: mutable bitmaps get copied 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
« no previous file with comments | « src/pdf/SkPDFBitmap.cpp ('k') | src/pdf/SkPDFCanon.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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" 11 #include "SkThread.h"
12 #include "SkTDArray.h" 12 #include "SkTDArray.h"
13 13
14 struct SkIRect; 14 struct SkIRect;
15 class SkBitmap;
15 class SkMatrix; 16 class SkMatrix;
16 class SkPDFFont; 17 class SkPDFFont;
17 class SkPDFGraphicState; 18 class SkPDFGraphicState;
19 class SkPDFBitmap;
18 class SkPaint; 20 class SkPaint;
19 21
20 // This class's fields and methods will eventually become part of 22 // This class's fields and methods will eventually become part of
21 // SkPDFDocument/SkDocument_PDF. For now, it exists as a singleton to 23 // SkPDFDocument/SkDocument_PDF. For now, it exists as a singleton to
22 // preflight that transition. This replaces three global arrays in 24 // preflight that transition. This replaces three global arrays in
23 // SkPDFFont, SkPDFShader, and SkPDFGraphicsContext. 25 // SkPDFFont, SkPDFShader, and SkPDFGraphicsContext.
24 // 26 //
25 // IF YOU ARE LOOKING AT THIS API PLEASE DO NOT WRITE THE CHANGE 27 // IF YOU ARE LOOKING AT THIS API PLEASE DO NOT WRITE THE CHANGE
26 // YOU ARE ABOUT TO WRITE WITHOUT TALKING TO HALCANARY@. 28 // YOU ARE ABOUT TO WRITE WITHOUT TALKING TO HALCANARY@.
27 // 29 //
28 // Note that this class does not create, delete, reference or 30 // Note that this class does not create, delete, reference or
29 // dereference the SkPDFObject objects that it indexes. It is up to 31 // dereference the SkPDFObject objects that it indexes. It is up to
30 // the caller to manage the lifetime of these objects. 32 // the caller to manage the lifetime of these objects.
31 class SkPDFCanon : SkNoncopyable { 33 class SkPDFCanon : SkNoncopyable {
32 public: 34 public:
33 SkPDFCanon(); 35 SkPDFCanon();
34 ~SkPDFCanon(); 36 ~SkPDFCanon();
35 37
36 static SkPDFCanon& GetCanon(); 38 static SkPDFCanon& GetCanon();
37 39
38 // This mutexes will be removed once this class is subsumed into 40 // This mutexes will be removed once this class is subsumed into
39 // SkPDFDocument. 41 // SkPDFDocument.
40 static SkBaseMutex& GetFontMutex(); 42 static SkBaseMutex& GetFontMutex();
41 static SkBaseMutex& GetShaderMutex(); 43 static SkBaseMutex& GetShaderMutex();
42 static SkBaseMutex& GetPaintMutex(); 44 static SkBaseMutex& GetPaintMutex();
45 static SkBaseMutex& GetBitmapMutex();
43 46
44 // Returns exact match if there is one. If not, it returns NULL. 47 // Returns exact match if there is one. If not, it returns NULL.
45 // If there is no exact match, but there is a related font, we 48 // If there is no exact match, but there is a related font, we
46 // still return NULL, but also set *relatedFont. 49 // still return NULL, but also set *relatedFont.
47 SkPDFFont* findFont(uint32_t fontID, 50 SkPDFFont* findFont(uint32_t fontID,
48 uint16_t glyphID, 51 uint16_t glyphID,
49 SkPDFFont** relatedFont) const; 52 SkPDFFont** relatedFont) const;
50 void addFont(SkPDFFont* font, uint32_t fontID, uint16_t fGlyphID); 53 void addFont(SkPDFFont* font, uint32_t fontID, uint16_t fGlyphID);
51 void removeFont(SkPDFFont*); 54 void removeFont(SkPDFFont*);
52 55
53 SkPDFFunctionShader* findFunctionShader(const SkPDFShader::State&) const; 56 SkPDFFunctionShader* findFunctionShader(const SkPDFShader::State&) const;
54 void addFunctionShader(SkPDFFunctionShader*); 57 void addFunctionShader(SkPDFFunctionShader*);
55 void removeFunctionShader(SkPDFFunctionShader*); 58 void removeFunctionShader(SkPDFFunctionShader*);
56 59
57 SkPDFAlphaFunctionShader* findAlphaShader(const SkPDFShader::State&) const; 60 SkPDFAlphaFunctionShader* findAlphaShader(const SkPDFShader::State&) const;
58 void addAlphaShader(SkPDFAlphaFunctionShader*); 61 void addAlphaShader(SkPDFAlphaFunctionShader*);
59 void removeAlphaShader(SkPDFAlphaFunctionShader*); 62 void removeAlphaShader(SkPDFAlphaFunctionShader*);
60 63
61 SkPDFImageShader* findImageShader(const SkPDFShader::State&) const; 64 SkPDFImageShader* findImageShader(const SkPDFShader::State&) const;
62 void addImageShader(SkPDFImageShader*); 65 void addImageShader(SkPDFImageShader*);
63 void removeImageShader(SkPDFImageShader*); 66 void removeImageShader(SkPDFImageShader*);
64 67
65 SkPDFGraphicState* findGraphicState(const SkPaint&) const; 68 SkPDFGraphicState* findGraphicState(const SkPaint&) const;
66 void addGraphicState(SkPDFGraphicState*); 69 void addGraphicState(SkPDFGraphicState*);
67 void removeGraphicState(SkPDFGraphicState*); 70 void removeGraphicState(SkPDFGraphicState*);
68 71
72 SkPDFBitmap* findBitmap(const SkBitmap&) const;
73 void addBitmap(SkPDFBitmap*);
74 void removeBitmap(SkPDFBitmap*);
75
69 private: 76 private:
70 struct FontRec { 77 struct FontRec {
71 SkPDFFont* fFont; 78 SkPDFFont* fFont;
72 uint32_t fFontID; 79 uint32_t fFontID;
73 uint16_t fGlyphID; 80 uint16_t fGlyphID;
74 }; 81 };
75 SkTDArray<FontRec> fFontRecords; 82 SkTDArray<FontRec> fFontRecords;
76 83
77 SkTDArray<SkPDFFunctionShader*> fFunctionShaderRecords; 84 SkTDArray<SkPDFFunctionShader*> fFunctionShaderRecords;
78 85
79 SkTDArray<SkPDFAlphaFunctionShader*> fAlphaShaderRecords; 86 SkTDArray<SkPDFAlphaFunctionShader*> fAlphaShaderRecords;
80 87
81 SkTDArray<SkPDFImageShader*> fImageShaderRecords; 88 SkTDArray<SkPDFImageShader*> fImageShaderRecords;
82 89
83 SkTDArray<SkPDFGraphicState*> fGraphicStateRecords; 90 SkTDArray<SkPDFGraphicState*> fGraphicStateRecords;
91
92 SkTDArray<SkPDFBitmap*> fBitmapRecords;
84 }; 93 };
85 #endif // SkPDFCanon_DEFINED 94 #endif // SkPDFCanon_DEFINED
OLDNEW
« no previous file with comments | « src/pdf/SkPDFBitmap.cpp ('k') | src/pdf/SkPDFCanon.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698