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" |
11 #include "SkDebugCanvas.h" | 11 #include "SkDebugCanvas.h" |
12 #include "SkDrawCommand.h" | 12 #include "SkDrawCommand.h" |
13 #include "SkDrawFilter.h" | 13 #include "SkDrawFilter.h" |
14 #include "SkDevice.h" | 14 #include "SkDevice.h" |
15 #include "SkXfermode.h" | 15 #include "SkXfermode.h" |
16 | 16 |
17 SkDebugCanvas::SkDebugCanvas(int windowWidth, int windowHeight) | 17 SkDebugCanvas::SkDebugCanvas(int width, int height) |
18 : INHERITED(windowWidth, windowHeight) | 18 : INHERITED(width, height) |
19 , fPicture(NULL) | 19 , fPicture(NULL) |
20 , fWindowSize(SkISize::Make(windowWidth, windowHeight)) | |
21 , fFilter(false) | 20 , fFilter(false) |
22 , fMegaVizMode(false) | 21 , fMegaVizMode(false) |
23 , fIndex(0) | 22 , fIndex(0) |
24 , fOverdrawViz(false) | 23 , fOverdrawViz(false) |
25 , fOverdrawFilter(NULL) | 24 , fOverdrawFilter(NULL) |
26 , fOverrideTexFiltering(false) | 25 , fOverrideTexFiltering(false) |
27 , fTexOverrideFilter(NULL) | 26 , fTexOverrideFilter(NULL) |
28 , fOutstandingSaveCount(0) { | 27 , fOutstandingSaveCount(0) { |
29 fUserMatrix.reset(); | 28 fUserMatrix.reset(); |
30 fDrawNeedsReset = false; | 29 fDrawNeedsReset = false; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 for (int i = 0; i < fActiveLayers.count(); ++i) { | 225 for (int i = 0; i < fActiveLayers.count(); ++i) { |
227 fActiveLayers[i]->setActive(true); | 226 fActiveLayers[i]->setActive(true); |
228 } | 227 } |
229 | 228 |
230 } | 229 } |
231 | 230 |
232 void SkDebugCanvas::drawTo(SkCanvas* canvas, int index) { | 231 void SkDebugCanvas::drawTo(SkCanvas* canvas, int index) { |
233 SkASSERT(!fCommandVector.isEmpty()); | 232 SkASSERT(!fCommandVector.isEmpty()); |
234 SkASSERT(index < fCommandVector.count()); | 233 SkASSERT(index < fCommandVector.count()); |
235 int i = 0; | 234 int i = 0; |
| 235 SkRect windowRect = SkRect::MakeWH(SkIntToScalar(canvas->getBaseLayerSize().
width()), |
| 236 SkIntToScalar(canvas->getBaseLayerSize().
height())); |
236 | 237 |
237 bool pathOpsMode = getAllowSimplifyClip(); | 238 bool pathOpsMode = getAllowSimplifyClip(); |
238 canvas->setAllowSimplifyClip(pathOpsMode); | 239 canvas->setAllowSimplifyClip(pathOpsMode); |
239 // This only works assuming the canvas and device are the same ones that | 240 // This only works assuming the canvas and device are the same ones that |
240 // were previously drawn into because they need to preserve all saves | 241 // were previously drawn into because they need to preserve all saves |
241 // and restores. | 242 // and restores. |
242 // The visibility filter also requires a full re-draw - otherwise we can | 243 // The visibility filter also requires a full re-draw - otherwise we can |
243 // end up drawing the filter repeatedly. | 244 // end up drawing the filter repeatedly. |
244 if (fIndex < index && !fFilter && !fMegaVizMode && !pathOpsMode && !fDrawNee
dsReset) { | 245 if (fIndex < index && !fFilter && !fMegaVizMode && !pathOpsMode && !fDrawNee
dsReset) { |
245 i = fIndex + 1; | 246 i = fIndex + 1; |
246 } else { | 247 } else { |
247 for (int j = 0; j < fOutstandingSaveCount; j++) { | 248 for (int j = 0; j < fOutstandingSaveCount; j++) { |
248 canvas->restore(); | 249 canvas->restore(); |
249 } | 250 } |
250 canvas->clear(SK_ColorTRANSPARENT); | 251 canvas->clear(SK_ColorTRANSPARENT); |
251 canvas->resetMatrix(); | 252 canvas->resetMatrix(); |
252 SkRect rect = SkRect::MakeWH(SkIntToScalar(fWindowSize.fWidth), | 253 if (!windowRect.isEmpty()) { |
253 SkIntToScalar(fWindowSize.fHeight)); | 254 canvas->clipRect(windowRect, SkRegion::kReplace_Op); |
254 canvas->clipRect(rect, SkRegion::kReplace_Op); | 255 } |
255 this->applyUserTransform(canvas); | 256 this->applyUserTransform(canvas); |
256 fDrawNeedsReset = false; | 257 fDrawNeedsReset = false; |
257 fOutstandingSaveCount = 0; | 258 fOutstandingSaveCount = 0; |
258 } | 259 } |
259 | 260 |
260 // The setting of the draw filter has to go here (rather than in | 261 // The setting of the draw filter has to go here (rather than in |
261 // SkRasterWidget) due to the canvas restores this class performs. | 262 // SkRasterWidget) due to the canvas restores this class performs. |
262 // Since the draw filter is stored in the layer stack if we | 263 // Since the draw filter is stored in the layer stack if we |
263 // call setDrawFilter on anything but the root layer odd things happen. | 264 // call setDrawFilter on anything but the root layer odd things happen. |
264 if (fOverdrawViz) { | 265 if (fOverdrawViz) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 } else { | 301 } else { |
301 fCommandVector[i]->setUserMatrix(fUserMatrix); | 302 fCommandVector[i]->setUserMatrix(fUserMatrix); |
302 fCommandVector[i]->execute(canvas); | 303 fCommandVector[i]->execute(canvas); |
303 } | 304 } |
304 | 305 |
305 fCommandVector[i]->trackSaveState(&fOutstandingSaveCount); | 306 fCommandVector[i]->trackSaveState(&fOutstandingSaveCount); |
306 } | 307 } |
307 } | 308 } |
308 | 309 |
309 if (fMegaVizMode) { | 310 if (fMegaVizMode) { |
310 SkRect r = SkRect::MakeWH(SkIntToScalar(fWindowSize.fWidth), | |
311 SkIntToScalar(fWindowSize.fHeight)); | |
312 r.outset(SK_Scalar1, SK_Scalar1); | |
313 | |
314 canvas->save(); | 311 canvas->save(); |
315 // nuke the CTM | 312 // nuke the CTM |
316 canvas->resetMatrix(); | 313 canvas->resetMatrix(); |
317 // turn off clipping | 314 // turn off clipping |
318 canvas->clipRect(r, SkRegion::kReplace_Op); | 315 if (!windowRect.isEmpty()) { |
319 | 316 SkRect r = windowRect; |
| 317 r.outset(SK_Scalar1, SK_Scalar1); |
| 318 canvas->clipRect(r, SkRegion::kReplace_Op); |
| 319 } |
320 // visualize existing clips | 320 // visualize existing clips |
321 SkDebugClipVisitor visitor(canvas); | 321 SkDebugClipVisitor visitor(canvas); |
322 | 322 |
323 canvas->replayClips(&visitor); | 323 canvas->replayClips(&visitor); |
324 | 324 |
325 canvas->restore(); | 325 canvas->restore(); |
326 } | 326 } |
327 if (pathOpsMode) { | 327 if (pathOpsMode) { |
328 this->resetClipStackData(); | 328 this->resetClipStackData(); |
329 const SkClipStack* clipStack = canvas->getClipStack(); | 329 const SkClipStack* clipStack = canvas->getClipStack(); |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 } | 689 } |
690 | 690 |
691 bool SkDebugCanvas::lastClipStackData(const SkPath& devPath) { | 691 bool SkDebugCanvas::lastClipStackData(const SkPath& devPath) { |
692 if (fCalledAddStackData) { | 692 if (fCalledAddStackData) { |
693 fClipStackData.appendf("<br>"); | 693 fClipStackData.appendf("<br>"); |
694 addPathData(devPath, "pathOut"); | 694 addPathData(devPath, "pathOut"); |
695 return true; | 695 return true; |
696 } | 696 } |
697 return false; | 697 return false; |
698 } | 698 } |
OLD | NEW |