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

Side by Side Diff: src/pipe/SkPipeCanvas.h

Issue 2335973003: change write-image to use pipeverbs like everyone else, and add test (Closed)
Patch Set: switch to [define_image] write_image Created 4 years, 3 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 | « no previous file | src/pipe/SkPipeCanvas.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 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
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
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
OLDNEW
« no previous file with comments | « no previous file | src/pipe/SkPipeCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698