OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 | 190 |
191 protected: | 191 protected: |
192 SkCanvas* fCanvas; | 192 SkCanvas* fCanvas; |
193 | 193 |
194 private: | 194 private: |
195 typedef SkCanvas::ClipVisitor INHERITED; | 195 typedef SkCanvas::ClipVisitor INHERITED; |
196 }; | 196 }; |
197 | 197 |
198 // set up the saveLayer commands so that the active ones | 198 // set up the saveLayer commands so that the active ones |
199 // return true in their 'active' method | 199 // return true in their 'active' method |
200 void SkDebugCanvas::markActiveSaveLayers(int index) { | 200 void SkDebugCanvas::markActiveCommands(int index) { |
201 SkTDArray<SkDrawCommand*> activeLayers; | 201 fActiveLayers.rewind(); |
| 202 fActiveCulls.rewind(); |
202 | 203 |
203 for (int i = 0; i < fCommandVector.count(); ++i) { | 204 for (int i = 0; i < fCommandVector.count(); ++i) { |
204 fCommandVector[i]->setActive(false); | 205 fCommandVector[i]->setActive(false); |
205 } | 206 } |
206 | 207 |
207 for (int i = 0; i < index; ++i) { | 208 for (int i = 0; i < index; ++i) { |
208 SkDrawCommand::Action result = fCommandVector[i]->action(); | 209 SkDrawCommand::Action result = fCommandVector[i]->action(); |
209 if (SkDrawCommand::kPush_Action == result) { | 210 if (SkDrawCommand::kPushLayer_Action == result) { |
210 activeLayers.push(fCommandVector[i]); | 211 fActiveLayers.push(fCommandVector[i]); |
211 } else if (SkDrawCommand::kPop_Action == result) { | 212 } else if (SkDrawCommand::kPopLayer_Action == result) { |
212 activeLayers.pop(); | 213 fActiveLayers.pop(); |
| 214 } else if (SkDrawCommand::kPushCull_Action == result) { |
| 215 fActiveCulls.push(fCommandVector[i]); |
| 216 } else if (SkDrawCommand::kPopCull_Action == result) { |
| 217 fActiveCulls.pop(); |
213 } | 218 } |
214 } | 219 } |
215 | 220 |
216 for (int i = 0; i < activeLayers.count(); ++i) { | 221 for (int i = 0; i < fActiveLayers.count(); ++i) { |
217 activeLayers[i]->setActive(true); | 222 fActiveLayers[i]->setActive(true); |
| 223 } |
| 224 |
| 225 for (int i = 0; i < fActiveCulls.count(); ++i) { |
| 226 fActiveCulls[i]->setActive(true); |
218 } | 227 } |
219 } | 228 } |
220 | 229 |
221 void SkDebugCanvas::drawTo(SkCanvas* canvas, int index) { | 230 void SkDebugCanvas::drawTo(SkCanvas* canvas, int index) { |
222 SkASSERT(!fCommandVector.isEmpty()); | 231 SkASSERT(!fCommandVector.isEmpty()); |
223 SkASSERT(index < fCommandVector.count()); | 232 SkASSERT(index < fCommandVector.count()); |
224 int i = 0; | 233 int i = 0; |
225 | 234 |
226 // This only works assuming the canvas and device are the same ones that | 235 // This only works assuming the canvas and device are the same ones that |
227 // were previously drawn into because they need to preserve all saves | 236 // were previously drawn into because they need to preserve all saves |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 } | 270 } |
262 | 271 |
263 if (fTexOverrideFilter != canvas->getDrawFilter()) { | 272 if (fTexOverrideFilter != canvas->getDrawFilter()) { |
264 canvas->setDrawFilter(fTexOverrideFilter); | 273 canvas->setDrawFilter(fTexOverrideFilter); |
265 } | 274 } |
266 } else { | 275 } else { |
267 canvas->setDrawFilter(NULL); | 276 canvas->setDrawFilter(NULL); |
268 } | 277 } |
269 | 278 |
270 if (fMegaVizMode) { | 279 if (fMegaVizMode) { |
271 this->markActiveSaveLayers(index); | 280 this->markActiveCommands(index); |
272 } | 281 } |
273 | 282 |
274 for (; i <= index; i++) { | 283 for (; i <= index; i++) { |
275 if (i == index && fFilter) { | 284 if (i == index && fFilter) { |
276 SkPaint p; | 285 SkPaint p; |
277 p.setColor(0xAAFFFFFF); | 286 p.setColor(0xAAFFFFFF); |
278 canvas->save(); | 287 canvas->save(); |
279 canvas->resetMatrix(); | 288 canvas->resetMatrix(); |
280 SkRect mask; | 289 SkRect mask; |
281 mask.set(SkIntToScalar(0), SkIntToScalar(0), | 290 mask.set(SkIntToScalar(0), SkIntToScalar(0), |
282 SkIntToScalar(fWidth), SkIntToScalar(fHeight)); | 291 SkIntToScalar(fWidth), SkIntToScalar(fHeight)); |
283 canvas->clipRect(mask, SkRegion::kReplace_Op, false); | 292 canvas->clipRect(mask, SkRegion::kReplace_Op, false); |
284 canvas->drawRectCoords(SkIntToScalar(0), SkIntToScalar(0), | 293 canvas->drawRectCoords(SkIntToScalar(0), SkIntToScalar(0), |
285 SkIntToScalar(fWidth), SkIntToScalar(fHeight), p); | 294 SkIntToScalar(fWidth), SkIntToScalar(fHeight), p); |
286 canvas->restore(); | 295 canvas->restore(); |
287 } | 296 } |
288 | 297 |
289 if (fCommandVector[i]->isVisible()) { | 298 if (fCommandVector[i]->isVisible()) { |
290 if (fMegaVizMode && fCommandVector[i]->active()) { | 299 if (fMegaVizMode && fCommandVector[i]->active()) { |
291 // All active saveLayers get replaced with saves so all draws go
to the | 300 // "active" commands execute their visualization behaviors: |
292 // visible canvas | 301 // All active saveLayers get replaced with saves so all draw
s go to the |
293 canvas->save(); | 302 // visible canvas. |
294 ++fOutstandingSaveCount; | 303 // All active culls draw their cull box |
| 304 fCommandVector[i]->vizExecute(canvas); |
295 } else { | 305 } else { |
296 fCommandVector[i]->execute(canvas); | 306 fCommandVector[i]->execute(canvas); |
297 fCommandVector[i]->trackSaveState(&fOutstandingSaveCount); | |
298 } | 307 } |
| 308 |
| 309 fCommandVector[i]->trackSaveState(&fOutstandingSaveCount); |
299 } | 310 } |
300 } | 311 } |
301 | 312 |
302 if (fMegaVizMode) { | 313 if (fMegaVizMode) { |
303 SkRect r = SkRect::MakeWH(SkIntToScalar(fWidth), SkIntToScalar(fHeight))
; | 314 SkRect r = SkRect::MakeWH(SkIntToScalar(fWidth), SkIntToScalar(fHeight))
; |
304 r.outset(SK_Scalar1, SK_Scalar1); | 315 r.outset(SK_Scalar1, SK_Scalar1); |
305 | 316 |
306 canvas->save(); | 317 canvas->save(); |
307 // nuke the CTM | 318 // nuke the CTM |
308 canvas->setMatrix(SkMatrix::I()); | 319 canvas->setMatrix(SkMatrix::I()); |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 | 564 |
554 bool SkDebugCanvas::translate(SkScalar dx, SkScalar dy) { | 565 bool SkDebugCanvas::translate(SkScalar dx, SkScalar dy) { |
555 addDrawCommand(new SkTranslateCommand(dx, dy)); | 566 addDrawCommand(new SkTranslateCommand(dx, dy)); |
556 return true; | 567 return true; |
557 } | 568 } |
558 | 569 |
559 void SkDebugCanvas::toggleCommand(int index, bool toggle) { | 570 void SkDebugCanvas::toggleCommand(int index, bool toggle) { |
560 SkASSERT(index < fCommandVector.count()); | 571 SkASSERT(index < fCommandVector.count()); |
561 fCommandVector[index]->setVisible(toggle); | 572 fCommandVector[index]->setVisible(toggle); |
562 } | 573 } |
OLD | NEW |