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

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

Issue 1046293002: SkPDF: SkPDFGraphicState Lookup hashtabled (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-04-01 (Wednesday) 16:16:21 EDT Created 5 years, 8 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/core/SkTHash.h ('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 "SkPDFGraphicState.h"
10 #include "SkPDFShader.h" 11 #include "SkPDFShader.h"
11 #include "SkTDArray.h" 12 #include "SkTDArray.h"
13 #include "SkTHash.h"
12 14
13 class SkBitmap; 15 class SkBitmap;
14 class SkPDFFont; 16 class SkPDFFont;
15 class SkPDFGraphicState;
16 class SkPDFBitmap; 17 class SkPDFBitmap;
17 class SkPaint; 18 class SkPaint;
18 19
19 /** 20 /**
20 * The SkPDFCanon canonicalizes objects across PDF pages(SkPDFDevices). 21 * The SkPDFCanon canonicalizes objects across PDF pages(SkPDFDevices).
21 * 22 *
22 * The PDF backend works correctly if: 23 * The PDF backend works correctly if:
23 * - There is no more than one SkPDFCanon for each thread. 24 * - There is no more than one SkPDFCanon for each thread.
24 * - Every SkPDFDevice is given a pointer to a SkPDFCanon on creation. 25 * - Every SkPDFDevice is given a pointer to a SkPDFCanon on creation.
25 * - All SkPDFDevices in a document share the same SkPDFCanon. 26 * - All SkPDFDevices in a document share the same SkPDFCanon.
(...skipping 23 matching lines...) Expand all
49 50
50 SkPDFFunctionShader* findFunctionShader(const SkPDFShader::State&) const; 51 SkPDFFunctionShader* findFunctionShader(const SkPDFShader::State&) const;
51 void addFunctionShader(SkPDFFunctionShader*); 52 void addFunctionShader(SkPDFFunctionShader*);
52 53
53 SkPDFAlphaFunctionShader* findAlphaShader(const SkPDFShader::State&) const; 54 SkPDFAlphaFunctionShader* findAlphaShader(const SkPDFShader::State&) const;
54 void addAlphaShader(SkPDFAlphaFunctionShader*); 55 void addAlphaShader(SkPDFAlphaFunctionShader*);
55 56
56 SkPDFImageShader* findImageShader(const SkPDFShader::State&) const; 57 SkPDFImageShader* findImageShader(const SkPDFShader::State&) const;
57 void addImageShader(SkPDFImageShader*); 58 void addImageShader(SkPDFImageShader*);
58 59
59 SkPDFGraphicState* findGraphicState(const SkPaint&) const; 60 const SkPDFGraphicState* findGraphicState(const SkPDFGraphicState&) const;
60 void addGraphicState(SkPDFGraphicState*); 61 void addGraphicState(const SkPDFGraphicState*);
61 62
62 SkPDFBitmap* findBitmap(const SkBitmap&) const; 63 SkPDFBitmap* findBitmap(const SkBitmap&) const;
63 void addBitmap(SkPDFBitmap*); 64 void addBitmap(SkPDFBitmap*);
64 65
65 private: 66 private:
66 struct FontRec { 67 struct FontRec {
67 SkPDFFont* fFont; 68 SkPDFFont* fFont;
68 uint32_t fFontID; 69 uint32_t fFontID;
69 uint16_t fGlyphID; 70 uint16_t fGlyphID;
70 }; 71 };
71 SkTDArray<FontRec> fFontRecords; 72 SkTDArray<FontRec> fFontRecords;
72 73
73 SkTDArray<SkPDFFunctionShader*> fFunctionShaderRecords; 74 SkTDArray<SkPDFFunctionShader*> fFunctionShaderRecords;
74 75
75 SkTDArray<SkPDFAlphaFunctionShader*> fAlphaShaderRecords; 76 SkTDArray<SkPDFAlphaFunctionShader*> fAlphaShaderRecords;
76 77
77 SkTDArray<SkPDFImageShader*> fImageShaderRecords; 78 SkTDArray<SkPDFImageShader*> fImageShaderRecords;
78 79
79 SkTDArray<SkPDFGraphicState*> fGraphicStateRecords; 80 struct WrapGS {
81 explicit WrapGS(const SkPDFGraphicState* ptr = NULL) : fPtr(ptr) {}
82 const SkPDFGraphicState* fPtr;
83 bool operator==(const WrapGS& rhs) const {
84 SkASSERT(fPtr);
85 SkASSERT(rhs.fPtr);
86 return *fPtr == *rhs.fPtr;
87 }
88 static uint32_t Hash(const WrapGS& w) {
89 SkASSERT(w.fPtr);
90 return w.fPtr->hash();
91 }
92 };
93 SkTHashSet<WrapGS, WrapGS::Hash> fGraphicStateRecords;
80 94
81 SkTDArray<SkPDFBitmap*> fBitmapRecords; 95 SkTDArray<SkPDFBitmap*> fBitmapRecords;
82 }; 96 };
83 #endif // SkPDFCanon_DEFINED 97 #endif // SkPDFCanon_DEFINED
OLDNEW
« no previous file with comments | « src/core/SkTHash.h ('k') | src/pdf/SkPDFCanon.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698