| 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 windowWidth, int windowHeight) |
| 18 : INHERITED(windowWidth, windowHeight) | 18 : INHERITED(windowWidth, windowHeight) |
| 19 , fPicture(NULL) | 19 , fPicture(NULL) |
| 20 , fWindowSize(SkISize::Make(windowWidth, windowHeight)) | 20 , fWindowSize(SkISize::Make(windowWidth, windowHeight)) |
| 21 , fFilter(false) | 21 , fFilter(false) |
| 22 , fMegaVizMode(false) | 22 , fMegaVizMode(false) |
| 23 , fIndex(0) | 23 , fIndex(0) |
| 24 , fOverdrawViz(false) | 24 , fOverdrawViz(false) |
| 25 , fOverdrawFilter(NULL) | 25 , fOverdrawFilter(NULL) |
| 26 , fOverrideTexFiltering(false) | 26 , fOverrideTexFiltering(false) |
| 27 , fTexOverrideFilter(NULL) | 27 , fTexOverrideFilter(NULL) |
| 28 , fOutstandingSaveCount(0) { | 28 , fOutstandingSaveCount(0) { |
| 29 fUserMatrix.reset(); | 29 fUserMatrix.reset(); |
| 30 fDrawNeedsReset = false; |
| 30 | 31 |
| 31 // SkPicturePlayback uses the base-class' quickReject calls to cull clipped | 32 // SkPicturePlayback uses the base-class' quickReject calls to cull clipped |
| 32 // operations. This can lead to problems in the debugger which expects all | 33 // operations. This can lead to problems in the debugger which expects all |
| 33 // the operations in the captured skp to appear in the debug canvas. To | 34 // the operations in the captured skp to appear in the debug canvas. To |
| 34 // circumvent this we create a wide open clip here (an empty clip rect | 35 // circumvent this we create a wide open clip here (an empty clip rect |
| 35 // is not sufficient). | 36 // is not sufficient). |
| 36 // Internally, the SkRect passed to clipRect is converted to an SkIRect and | 37 // Internally, the SkRect passed to clipRect is converted to an SkIRect and |
| 37 // rounded out. The following code creates a nearly maximal rect that will | 38 // rounded out. The following code creates a nearly maximal rect that will |
| 38 // not get collapsed by the coming conversions (Due to precision loss the | 39 // not get collapsed by the coming conversions (Due to precision loss the |
| 39 // inset has to be surprisingly large). | 40 // inset has to be surprisingly large). |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 bitmap.allocPixels(SkImageInfo::MakeN32Premul(1, 1)); | 75 bitmap.allocPixels(SkImageInfo::MakeN32Premul(1, 1)); |
| 75 | 76 |
| 76 SkCanvas canvas(bitmap); | 77 SkCanvas canvas(bitmap); |
| 77 canvas.translate(SkIntToScalar(-x), SkIntToScalar(-y)); | 78 canvas.translate(SkIntToScalar(-x), SkIntToScalar(-y)); |
| 78 this->applyUserTransform(&canvas); | 79 this->applyUserTransform(&canvas); |
| 79 | 80 |
| 80 int layer = 0; | 81 int layer = 0; |
| 81 SkColor prev = bitmap.getColor(0,0); | 82 SkColor prev = bitmap.getColor(0,0); |
| 82 for (int i = 0; i < index; i++) { | 83 for (int i = 0; i < index; i++) { |
| 83 if (fCommandVector[i]->isVisible()) { | 84 if (fCommandVector[i]->isVisible()) { |
| 85 fCommandVector[i]->setUserMatrix(fUserMatrix); |
| 84 fCommandVector[i]->execute(&canvas); | 86 fCommandVector[i]->execute(&canvas); |
| 85 } | 87 } |
| 86 if (prev != bitmap.getColor(0,0)) { | 88 if (prev != bitmap.getColor(0,0)) { |
| 87 layer = i; | 89 layer = i; |
| 88 } | 90 } |
| 89 prev = bitmap.getColor(0,0); | 91 prev = bitmap.getColor(0,0); |
| 90 } | 92 } |
| 91 return layer; | 93 return layer; |
| 92 } | 94 } |
| 93 | 95 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 SkASSERT(index < fCommandVector.count()); | 241 SkASSERT(index < fCommandVector.count()); |
| 240 int i = 0; | 242 int i = 0; |
| 241 | 243 |
| 242 bool pathOpsMode = getAllowSimplifyClip(); | 244 bool pathOpsMode = getAllowSimplifyClip(); |
| 243 canvas->setAllowSimplifyClip(pathOpsMode); | 245 canvas->setAllowSimplifyClip(pathOpsMode); |
| 244 // This only works assuming the canvas and device are the same ones that | 246 // This only works assuming the canvas and device are the same ones that |
| 245 // were previously drawn into because they need to preserve all saves | 247 // were previously drawn into because they need to preserve all saves |
| 246 // and restores. | 248 // and restores. |
| 247 // The visibility filter also requires a full re-draw - otherwise we can | 249 // The visibility filter also requires a full re-draw - otherwise we can |
| 248 // end up drawing the filter repeatedly. | 250 // end up drawing the filter repeatedly. |
| 249 if (fIndex < index && !fFilter && !fMegaVizMode && !pathOpsMode) { | 251 if (fIndex < index && !fFilter && !fMegaVizMode && !pathOpsMode && !fDrawNee
dsReset) { |
| 250 i = fIndex + 1; | 252 i = fIndex + 1; |
| 251 } else { | 253 } else { |
| 252 for (int j = 0; j < fOutstandingSaveCount; j++) { | 254 for (int j = 0; j < fOutstandingSaveCount; j++) { |
| 253 canvas->restore(); | 255 canvas->restore(); |
| 254 } | 256 } |
| 255 canvas->clear(SK_ColorTRANSPARENT); | 257 canvas->clear(SK_ColorTRANSPARENT); |
| 256 canvas->resetMatrix(); | 258 canvas->resetMatrix(); |
| 257 SkRect rect = SkRect::MakeWH(SkIntToScalar(fWindowSize.fWidth), | 259 SkRect rect = SkRect::MakeWH(SkIntToScalar(fWindowSize.fWidth), |
| 258 SkIntToScalar(fWindowSize.fHeight)); | 260 SkIntToScalar(fWindowSize.fHeight)); |
| 259 canvas->clipRect(rect, SkRegion::kReplace_Op); | 261 canvas->clipRect(rect, SkRegion::kReplace_Op); |
| 260 this->applyUserTransform(canvas); | 262 this->applyUserTransform(canvas); |
| 263 fDrawNeedsReset = false; |
| 261 fOutstandingSaveCount = 0; | 264 fOutstandingSaveCount = 0; |
| 262 } | 265 } |
| 263 | 266 |
| 264 // The setting of the draw filter has to go here (rather than in | 267 // The setting of the draw filter has to go here (rather than in |
| 265 // SkRasterWidget) due to the canvas restores this class performs. | 268 // SkRasterWidget) due to the canvas restores this class performs. |
| 266 // Since the draw filter is stored in the layer stack if we | 269 // Since the draw filter is stored in the layer stack if we |
| 267 // call setDrawFilter on anything but the root layer odd things happen. | 270 // call setDrawFilter on anything but the root layer odd things happen. |
| 268 if (fOverdrawViz) { | 271 if (fOverdrawViz) { |
| 269 if (NULL == fOverdrawFilter) { | 272 if (NULL == fOverdrawFilter) { |
| 270 fOverdrawFilter = new SkOverdrawFilter; | 273 fOverdrawFilter = new SkOverdrawFilter; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 295 } | 298 } |
| 296 | 299 |
| 297 if (fCommandVector[i]->isVisible()) { | 300 if (fCommandVector[i]->isVisible()) { |
| 298 if (fMegaVizMode && fCommandVector[i]->active()) { | 301 if (fMegaVizMode && fCommandVector[i]->active()) { |
| 299 // "active" commands execute their visualization behaviors: | 302 // "active" commands execute their visualization behaviors: |
| 300 // All active saveLayers get replaced with saves so all draw
s go to the | 303 // All active saveLayers get replaced with saves so all draw
s go to the |
| 301 // visible canvas. | 304 // visible canvas. |
| 302 // All active culls draw their cull box | 305 // All active culls draw their cull box |
| 303 fCommandVector[i]->vizExecute(canvas); | 306 fCommandVector[i]->vizExecute(canvas); |
| 304 } else { | 307 } else { |
| 308 fCommandVector[i]->setUserMatrix(fUserMatrix); |
| 305 fCommandVector[i]->execute(canvas); | 309 fCommandVector[i]->execute(canvas); |
| 306 } | 310 } |
| 307 | 311 |
| 308 fCommandVector[i]->trackSaveState(&fOutstandingSaveCount); | 312 fCommandVector[i]->trackSaveState(&fOutstandingSaveCount); |
| 309 } | 313 } |
| 310 } | 314 } |
| 311 | 315 |
| 312 if (fMegaVizMode) { | 316 if (fMegaVizMode) { |
| 313 SkRect r = SkRect::MakeWH(SkIntToScalar(fWindowSize.fWidth), | 317 SkRect r = SkRect::MakeWH(SkIntToScalar(fWindowSize.fWidth), |
| 314 SkIntToScalar(fWindowSize.fHeight)); | 318 SkIntToScalar(fWindowSize.fHeight)); |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 } | 731 } |
| 728 | 732 |
| 729 bool SkDebugCanvas::lastClipStackData(const SkPath& devPath) { | 733 bool SkDebugCanvas::lastClipStackData(const SkPath& devPath) { |
| 730 if (fCalledAddStackData) { | 734 if (fCalledAddStackData) { |
| 731 fClipStackData.appendf("<br>"); | 735 fClipStackData.appendf("<br>"); |
| 732 addPathData(devPath, "pathOut"); | 736 addPathData(devPath, "pathOut"); |
| 733 return true; | 737 return true; |
| 734 } | 738 } |
| 735 return false; | 739 return false; |
| 736 } | 740 } |
| OLD | NEW |