OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 #include "GrContext.h" | 8 #include "GrContext.h" |
9 #include "GrLayerCache.h" | 9 #include "GrLayerCache.h" |
10 #include "GrRecordReplaceDraw.h" | 10 #include "GrRecordReplaceDraw.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 // Used by GrRecordReplaceDraw. It intercepts nested drawPicture calls and | 49 // Used by GrRecordReplaceDraw. It intercepts nested drawPicture calls and |
50 // also draws them with replaced layers. | 50 // also draws them with replaced layers. |
51 class ReplaceDraw : public SkRecords::Draw { | 51 class ReplaceDraw : public SkRecords::Draw { |
52 public: | 52 public: |
53 ReplaceDraw(SkCanvas* canvas, GrLayerCache* layerCache, | 53 ReplaceDraw(SkCanvas* canvas, GrLayerCache* layerCache, |
54 SkPicture const* const drawablePicts[], int drawableCount, | 54 SkPicture const* const drawablePicts[], int drawableCount, |
55 const SkPicture* topLevelPicture, | 55 const SkPicture* topLevelPicture, |
56 const SkPicture* picture, | 56 const SkPicture* picture, |
57 const SkMatrix& initialMatrix, | 57 const SkMatrix& initialMatrix, |
58 SkDrawPictureCallback* callback, | 58 SkPicture::AbortCallback* callback, |
59 const unsigned* opIndices, int numIndices) | 59 const unsigned* opIndices, int numIndices) |
60 : INHERITED(canvas, drawablePicts, NULL, drawableCount) | 60 : INHERITED(canvas, drawablePicts, NULL, drawableCount) |
61 , fCanvas(canvas) | 61 , fCanvas(canvas) |
62 , fLayerCache(layerCache) | 62 , fLayerCache(layerCache) |
63 , fTopLevelPicture(topLevelPicture) | 63 , fTopLevelPicture(topLevelPicture) |
64 , fPicture(picture) | 64 , fPicture(picture) |
65 , fInitialMatrix(initialMatrix) | 65 , fInitialMatrix(initialMatrix) |
66 , fCallback(callback) | 66 , fCallback(callback) |
67 , fIndex(0) | 67 , fIndex(0) |
68 , fNumReplaced(0) { | 68 , fNumReplaced(0) { |
(...skipping 16 matching lines...) Expand all Loading... |
85 // The SkRecord and BBH were recorded in identity space. This canva
s | 85 // The SkRecord and BBH were recorded in identity space. This canva
s |
86 // is not necessarily in that same space. getClipBounds() returns u
s | 86 // is not necessarily in that same space. getClipBounds() returns u
s |
87 // this canvas' clip bounds transformed back into identity space, wh
ich | 87 // this canvas' clip bounds transformed back into identity space, wh
ich |
88 // lets us query the BBH. | 88 // lets us query the BBH. |
89 SkRect query = { 0, 0, 0, 0 }; | 89 SkRect query = { 0, 0, 0, 0 }; |
90 (void)fCanvas->getClipBounds(&query); | 90 (void)fCanvas->getClipBounds(&query); |
91 | 91 |
92 bbh->search(query, &fOps); | 92 bbh->search(query, &fOps); |
93 | 93 |
94 for (fIndex = 0; fIndex < fOps.count(); ++fIndex) { | 94 for (fIndex = 0; fIndex < fOps.count(); ++fIndex) { |
95 if (fCallback && fCallback->abortDrawing()) { | 95 if (fCallback && fCallback->abort()) { |
96 return fNumReplaced; | 96 return fNumReplaced; |
97 } | 97 } |
98 | 98 |
99 record->visit<void>(fOps[fIndex], *this); | 99 record->visit<void>(fOps[fIndex], *this); |
100 } | 100 } |
101 | 101 |
102 } else { | 102 } else { |
103 for (fIndex = 0; fIndex < (int) record->count(); ++fIndex) { | 103 for (fIndex = 0; fIndex < (int) record->count(); ++fIndex) { |
104 if (fCallback && fCallback->abortDrawing()) { | 104 if (fCallback && fCallback->abort()) { |
105 return fNumReplaced; | 105 return fNumReplaced; |
106 } | 106 } |
107 | 107 |
108 record->visit<void>(fIndex, *this); | 108 record->visit<void>(fIndex, *this); |
109 } | 109 } |
110 } | 110 } |
111 | 111 |
112 return fNumReplaced; | 112 return fNumReplaced; |
113 } | 113 } |
114 | 114 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 return; | 174 return; |
175 } | 175 } |
176 | 176 |
177 // This is a fail for layer hoisting | 177 // This is a fail for layer hoisting |
178 this->INHERITED::operator()(sl); | 178 this->INHERITED::operator()(sl); |
179 | 179 |
180 fOpIndexStack.pop(); | 180 fOpIndexStack.pop(); |
181 } | 181 } |
182 | 182 |
183 private: | 183 private: |
184 SkCanvas* fCanvas; | 184 SkCanvas* fCanvas; |
185 GrLayerCache* fLayerCache; | 185 GrLayerCache* fLayerCache; |
186 const SkPicture* fTopLevelPicture; | 186 const SkPicture* fTopLevelPicture; |
187 const SkPicture* fPicture; | 187 const SkPicture* fPicture; |
188 const SkMatrix fInitialMatrix; | 188 const SkMatrix fInitialMatrix; |
189 SkDrawPictureCallback* fCallback; | 189 SkPicture::AbortCallback* fCallback; |
190 | 190 |
191 SkTDArray<unsigned> fOps; | 191 SkTDArray<unsigned> fOps; |
192 int fIndex; | 192 int fIndex; |
193 int fNumReplaced; | 193 int fNumReplaced; |
194 | 194 |
195 // The op code indices of all the enclosing drawPicture and saveLayer calls | 195 // The op code indices of all the enclosing drawPicture and saveLayer calls |
196 SkTDArray<unsigned> fOpIndexStack; | 196 SkTDArray<unsigned> fOpIndexStack; |
197 | 197 |
198 typedef Draw INHERITED; | 198 typedef Draw INHERITED; |
199 }; | 199 }; |
200 | 200 |
201 int GrRecordReplaceDraw(const SkPicture* picture, | 201 int GrRecordReplaceDraw(const SkPicture* picture, |
202 SkCanvas* canvas, | 202 SkCanvas* canvas, |
203 GrLayerCache* layerCache, | 203 GrLayerCache* layerCache, |
204 const SkMatrix& initialMatrix, | 204 const SkMatrix& initialMatrix, |
205 SkDrawPictureCallback* callback) { | 205 SkPicture::AbortCallback* callback) { |
206 SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/); | 206 SkAutoCanvasRestore saveRestore(canvas, true /*save now, restore at exit*/); |
207 | 207 |
208 // TODO: drawablePicts? | 208 // TODO: drawablePicts? |
209 ReplaceDraw draw(canvas, layerCache, NULL, 0, | 209 ReplaceDraw draw(canvas, layerCache, NULL, 0, |
210 picture, picture, | 210 picture, picture, |
211 initialMatrix, callback, NULL, 0); | 211 initialMatrix, callback, NULL, 0); |
212 return draw.draw(); | 212 return draw.draw(); |
213 } | 213 } |
OLD | NEW |