OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 | 7 |
8 #ifndef SkPipeCanvas_DEFINED | 8 #ifndef SkPipeCanvas_DEFINED |
9 #define SkPipeCanvas_DEFINED | 9 #define SkPipeCanvas_DEFINED |
10 | 10 |
11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
12 #include "SkDeduper.h" | 12 #include "SkDeduper.h" |
13 #include "SkImage.h" | 13 #include "SkImage.h" |
14 #include "SkPipe.h" | 14 #include "SkPipe.h" |
15 #include "SkTypeface.h" | 15 #include "SkTypeface.h" |
16 #include "SkWriteBuffer.h" | 16 #include "SkWriteBuffer.h" |
17 | 17 |
18 class SkPipeCanvas; | 18 class SkPipeCanvas; |
19 class SkPipeWriter; | 19 class SkPipeWriter; |
20 | 20 |
21 template <typename T> class SkTIndexSet { | 21 template <typename T> class SkTIndexSet { |
22 public: | 22 public: |
23 void reset() { fArray.reset(); } | 23 void reset() { fArray.reset(); } |
24 | 24 |
25 // returns the found index or 0 | 25 // returns the found index or 0 |
26 int find(const T& key) { | 26 int find(const T& key) const { |
27 const Rec* stop = fArray.end(); | 27 const Rec* stop = fArray.end(); |
28 for (const Rec* curr = fArray.begin(); curr < stop; ++curr) { | 28 for (const Rec* curr = fArray.begin(); curr < stop; ++curr) { |
29 if (key == curr->fKey) { | 29 if (key == curr->fKey) { |
30 return curr->fIndex; | 30 return curr->fIndex; |
31 } | 31 } |
32 } | 32 } |
33 return 0; | 33 return 0; |
34 } | 34 } |
35 | 35 |
36 // returns the new index | 36 // returns the new index |
(...skipping 20 matching lines...) Expand all Loading... |
57 fImages.reset(); | 57 fImages.reset(); |
58 fPictures.reset(); | 58 fPictures.reset(); |
59 fTypefaces.reset(); | 59 fTypefaces.reset(); |
60 fFactories.reset(); | 60 fFactories.reset(); |
61 } | 61 } |
62 | 62 |
63 void setCanvas(SkPipeCanvas* canvas) { fPipeCanvas = canvas; } | 63 void setCanvas(SkPipeCanvas* canvas) { fPipeCanvas = canvas; } |
64 void setStream(SkWStream* stream) { fStream = stream; } | 64 void setStream(SkWStream* stream) { fStream = stream; } |
65 void setTypefaceSerializer(SkTypefaceSerializer* tfs) { fTFSerializer = tfs;
} | 65 void setTypefaceSerializer(SkTypefaceSerializer* tfs) { fTFSerializer = tfs;
} |
66 | 66 |
| 67 // returns 0 if not found |
| 68 int findImage(SkImage* image) const { return fImages.find(image->uniqueID())
; } |
| 69 |
67 int findOrDefineImage(SkImage*) override; | 70 int findOrDefineImage(SkImage*) override; |
68 int findOrDefinePicture(SkPicture*) override; | 71 int findOrDefinePicture(SkPicture*) override; |
69 int findOrDefineTypeface(SkTypeface*) override; | 72 int findOrDefineTypeface(SkTypeface*) override; |
70 int findOrDefineFactory(SkFlattenable*) override; | 73 int findOrDefineFactory(SkFlattenable*) override; |
71 | 74 |
72 private: | 75 private: |
73 SkPipeCanvas* fPipeCanvas = nullptr; | 76 SkPipeCanvas* fPipeCanvas = nullptr; |
74 SkWStream* fStream = nullptr; | 77 SkWStream* fStream = nullptr; |
75 | 78 |
76 SkTypefaceSerializer* fTFSerializer = nullptr; | 79 SkTypefaceSerializer* fTFSerializer = nullptr; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 SkPipeDeduper* fDeduper; | 160 SkPipeDeduper* fDeduper; |
158 SkWStream* fStream; | 161 SkWStream* fStream; |
159 | 162 |
160 friend class SkPipeWriter; | 163 friend class SkPipeWriter; |
161 | 164 |
162 typedef SkCanvas INHERITED; | 165 typedef SkCanvas INHERITED; |
163 }; | 166 }; |
164 | 167 |
165 | 168 |
166 #endif | 169 #endif |
OLD | NEW |