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

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

Issue 1372783003: SkPDF: Implement drawImage*() properly (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-09-30 (Wednesday) 21:22:24 EDT Created 5 years, 2 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 "SkBitmap.h"
10 #include "SkPDFGraphicState.h" 11 #include "SkPDFGraphicState.h"
11 #include "SkPDFShader.h" 12 #include "SkPDFShader.h"
12 #include "SkTDArray.h" 13 #include "SkTDArray.h"
13 #include "SkTHash.h" 14 #include "SkTHash.h"
14 15
15 class SkBitmap;
16 class SkPDFFont; 16 class SkPDFFont;
17 class SkPDFBitmap;
18 class SkPaint; 17 class SkPaint;
18 class SkImage;
19
20 class SkBitmapKey {
21 public:
22 SkBitmapKey() : fSubset(SkIRect::MakeEmpty()), fGenID(0) {}
23 explicit SkBitmapKey(const SkBitmap& bm)
24 : fSubset(bm.getSubset()), fGenID(bm.getGenerationID()) {}
25 bool operator==(const SkBitmapKey& rhs) const {
26 return fGenID == rhs.fGenID && fSubset == rhs.fSubset;
27 }
28
29 private:
30 SkIRect fSubset;
31 uint32_t fGenID;
32 };
19 33
20 /** 34 /**
21 * The SkPDFCanon canonicalizes objects across PDF pages(SkPDFDevices). 35 * The SkPDFCanon canonicalizes objects across PDF pages(SkPDFDevices).
22 * 36 *
23 * The PDF backend works correctly if: 37 * The PDF backend works correctly if:
24 * - There is no more than one SkPDFCanon for each thread. 38 * - There is no more than one SkPDFCanon for each thread.
25 * - Every SkPDFDevice is given a pointer to a SkPDFCanon on creation. 39 * - Every SkPDFDevice is given a pointer to a SkPDFCanon on creation.
26 * - All SkPDFDevices in a document share the same SkPDFCanon. 40 * - All SkPDFDevices in a document share the same SkPDFCanon.
27 * The SkDocument_PDF class makes this happen by owning a single 41 * The SkDocument_PDF class makes this happen by owning a single
28 * SkPDFCanon. 42 * SkPDFCanon.
(...skipping 24 matching lines...) Expand all
53 67
54 SkPDFAlphaFunctionShader* findAlphaShader(const SkPDFShader::State&) const; 68 SkPDFAlphaFunctionShader* findAlphaShader(const SkPDFShader::State&) const;
55 void addAlphaShader(SkPDFAlphaFunctionShader*); 69 void addAlphaShader(SkPDFAlphaFunctionShader*);
56 70
57 SkPDFImageShader* findImageShader(const SkPDFShader::State&) const; 71 SkPDFImageShader* findImageShader(const SkPDFShader::State&) const;
58 void addImageShader(SkPDFImageShader*); 72 void addImageShader(SkPDFImageShader*);
59 73
60 const SkPDFGraphicState* findGraphicState(const SkPDFGraphicState&) const; 74 const SkPDFGraphicState* findGraphicState(const SkPDFGraphicState&) const;
61 void addGraphicState(const SkPDFGraphicState*); 75 void addGraphicState(const SkPDFGraphicState*);
62 76
63 SkPDFBitmap* findBitmap(const SkBitmap&) const; 77 SkPDFObject* findPDFBitmap(const SkImage* image) const;
64 void addBitmap(SkPDFBitmap*); 78 void addPDFBitmap(uint32_t imageUniqueID, SkPDFObject*);
79 const SkImage* bitmapToImage(const SkBitmap&);
65 80
66 private: 81 private:
67 struct FontRec { 82 struct FontRec {
68 SkPDFFont* fFont; 83 SkPDFFont* fFont;
69 uint32_t fFontID; 84 uint32_t fFontID;
70 uint16_t fGlyphID; 85 uint16_t fGlyphID;
71 }; 86 };
72 SkTDArray<FontRec> fFontRecords; 87 SkTDArray<FontRec> fFontRecords;
73 88
74 SkTDArray<SkPDFFunctionShader*> fFunctionShaderRecords; 89 SkTDArray<SkPDFFunctionShader*> fFunctionShaderRecords;
(...skipping 10 matching lines...) Expand all
85 SkASSERT(rhs.fPtr); 100 SkASSERT(rhs.fPtr);
86 return *fPtr == *rhs.fPtr; 101 return *fPtr == *rhs.fPtr;
87 } 102 }
88 static uint32_t Hash(const WrapGS& w) { 103 static uint32_t Hash(const WrapGS& w) {
89 SkASSERT(w.fPtr); 104 SkASSERT(w.fPtr);
90 return w.fPtr->hash(); 105 return w.fPtr->hash();
91 } 106 }
92 }; 107 };
93 SkTHashSet<WrapGS, WrapGS::Hash> fGraphicStateRecords; 108 SkTHashSet<WrapGS, WrapGS::Hash> fGraphicStateRecords;
94 109
95 SkTDArray<SkPDFBitmap*> fBitmapRecords; 110 SkTHashMap<SkBitmapKey, const SkImage*> fBitmapToImageMap;
111 SkTHashMap<uint32_t /*ImageUniqueID*/, SkPDFObject*> fPDFBitmapMap;
96 }; 112 };
97 #endif // SkPDFCanon_DEFINED 113 #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