| 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 width, int height) | 17 SkDebugCanvas::SkDebugCanvas(int windowWidth, int windowHeight) |
| 18 : INHERITED(width, height) | 18 : INHERITED(windowWidth, windowHeight) |
| 19 , fPicture(NULL) | 19 , fPicture(NULL) |
| 20 , fWidth(width) | 20 , fWindowSize(SkISize::Make(windowWidth, windowHeight)) |
| 21 , fHeight(height) | |
| 22 , fFilter(false) | 21 , fFilter(false) |
| 23 , fMegaVizMode(false) | 22 , fMegaVizMode(false) |
| 24 , fIndex(0) | 23 , fIndex(0) |
| 25 , fOverdrawViz(false) | 24 , fOverdrawViz(false) |
| 26 , fOverdrawFilter(NULL) | 25 , fOverdrawFilter(NULL) |
| 27 , fOverrideTexFiltering(false) | 26 , fOverrideTexFiltering(false) |
| 28 , fTexOverrideFilter(NULL) | 27 , fTexOverrideFilter(NULL) |
| 29 , fOutstandingSaveCount(0) { | 28 , fOutstandingSaveCount(0) { |
| 30 fUserMatrix.reset(); | 29 fUserMatrix.reset(); |
| 31 | 30 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 void SkDebugCanvas::applyUserTransform(SkCanvas* canvas) { | 68 void SkDebugCanvas::applyUserTransform(SkCanvas* canvas) { |
| 70 canvas->concat(fUserMatrix); | 69 canvas->concat(fUserMatrix); |
| 71 } | 70 } |
| 72 | 71 |
| 73 int SkDebugCanvas::getCommandAtPoint(int x, int y, int index) { | 72 int SkDebugCanvas::getCommandAtPoint(int x, int y, int index) { |
| 74 SkBitmap bitmap; | 73 SkBitmap bitmap; |
| 75 bitmap.allocPixels(SkImageInfo::MakeN32Premul(1, 1)); | 74 bitmap.allocPixels(SkImageInfo::MakeN32Premul(1, 1)); |
| 76 | 75 |
| 77 SkCanvas canvas(bitmap); | 76 SkCanvas canvas(bitmap); |
| 78 canvas.translate(SkIntToScalar(-x), SkIntToScalar(-y)); | 77 canvas.translate(SkIntToScalar(-x), SkIntToScalar(-y)); |
| 79 applyUserTransform(&canvas); | 78 this->applyUserTransform(&canvas); |
| 80 | 79 |
| 81 int layer = 0; | 80 int layer = 0; |
| 82 SkColor prev = bitmap.getColor(0,0); | 81 SkColor prev = bitmap.getColor(0,0); |
| 83 for (int i = 0; i < index; i++) { | 82 for (int i = 0; i < index; i++) { |
| 84 if (fCommandVector[i]->isVisible()) { | 83 if (fCommandVector[i]->isVisible()) { |
| 85 fCommandVector[i]->execute(&canvas); | 84 fCommandVector[i]->execute(&canvas); |
| 86 } | 85 } |
| 87 if (prev != bitmap.getColor(0,0)) { | 86 if (prev != bitmap.getColor(0,0)) { |
| 88 layer = i; | 87 layer = i; |
| 89 } | 88 } |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 // The visibility filter also requires a full re-draw - otherwise we can | 247 // The visibility filter also requires a full re-draw - otherwise we can |
| 249 // end up drawing the filter repeatedly. | 248 // end up drawing the filter repeatedly. |
| 250 if (fIndex < index && !fFilter && !fMegaVizMode && !pathOpsMode) { | 249 if (fIndex < index && !fFilter && !fMegaVizMode && !pathOpsMode) { |
| 251 i = fIndex + 1; | 250 i = fIndex + 1; |
| 252 } else { | 251 } else { |
| 253 for (int j = 0; j < fOutstandingSaveCount; j++) { | 252 for (int j = 0; j < fOutstandingSaveCount; j++) { |
| 254 canvas->restore(); | 253 canvas->restore(); |
| 255 } | 254 } |
| 256 canvas->clear(SK_ColorTRANSPARENT); | 255 canvas->clear(SK_ColorTRANSPARENT); |
| 257 canvas->resetMatrix(); | 256 canvas->resetMatrix(); |
| 258 SkRect rect = SkRect::MakeWH(SkIntToScalar(fWidth), | 257 SkRect rect = SkRect::MakeWH(SkIntToScalar(fWindowSize.fWidth), |
| 259 SkIntToScalar(fHeight)); | 258 SkIntToScalar(fWindowSize.fHeight)); |
| 260 canvas->clipRect(rect, SkRegion::kReplace_Op ); | 259 canvas->clipRect(rect, SkRegion::kReplace_Op); |
| 261 applyUserTransform(canvas); | 260 this->applyUserTransform(canvas); |
| 262 fOutstandingSaveCount = 0; | 261 fOutstandingSaveCount = 0; |
| 263 } | 262 } |
| 264 | 263 |
| 265 // The setting of the draw filter has to go here (rather than in | 264 // The setting of the draw filter has to go here (rather than in |
| 266 // SkRasterWidget) due to the canvas restores this class performs. | 265 // SkRasterWidget) due to the canvas restores this class performs. |
| 267 // Since the draw filter is stored in the layer stack if we | 266 // Since the draw filter is stored in the layer stack if we |
| 268 // call setDrawFilter on anything but the root layer odd things happen. | 267 // call setDrawFilter on anything but the root layer odd things happen. |
| 269 if (fOverdrawViz) { | 268 if (fOverdrawViz) { |
| 270 if (NULL == fOverdrawFilter) { | 269 if (NULL == fOverdrawFilter) { |
| 271 fOverdrawFilter = new SkOverdrawFilter; | 270 fOverdrawFilter = new SkOverdrawFilter; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 285 } else { | 284 } else { |
| 286 canvas->setDrawFilter(NULL); | 285 canvas->setDrawFilter(NULL); |
| 287 } | 286 } |
| 288 | 287 |
| 289 if (fMegaVizMode) { | 288 if (fMegaVizMode) { |
| 290 this->markActiveCommands(index); | 289 this->markActiveCommands(index); |
| 291 } | 290 } |
| 292 | 291 |
| 293 for (; i <= index; i++) { | 292 for (; i <= index; i++) { |
| 294 if (i == index && fFilter) { | 293 if (i == index && fFilter) { |
| 295 SkPaint p; | 294 canvas->clear(0xAAFFFFFF); |
| 296 p.setColor(0xAAFFFFFF); | |
| 297 canvas->save(); | |
| 298 canvas->resetMatrix(); | |
| 299 SkRect mask; | |
| 300 mask.set(SkIntToScalar(0), SkIntToScalar(0), | |
| 301 SkIntToScalar(fWidth), SkIntToScalar(fHeight)); | |
| 302 canvas->clipRect(mask, SkRegion::kReplace_Op, false); | |
| 303 canvas->drawRectCoords(SkIntToScalar(0), SkIntToScalar(0), | |
| 304 SkIntToScalar(fWidth), SkIntToScalar(fHeight), p); | |
| 305 canvas->restore(); | |
| 306 } | 295 } |
| 307 | 296 |
| 308 if (fCommandVector[i]->isVisible()) { | 297 if (fCommandVector[i]->isVisible()) { |
| 309 if (fMegaVizMode && fCommandVector[i]->active()) { | 298 if (fMegaVizMode && fCommandVector[i]->active()) { |
| 310 // "active" commands execute their visualization behaviors: | 299 // "active" commands execute their visualization behaviors: |
| 311 // All active saveLayers get replaced with saves so all draw
s go to the | 300 // All active saveLayers get replaced with saves so all draw
s go to the |
| 312 // visible canvas. | 301 // visible canvas. |
| 313 // All active culls draw their cull box | 302 // All active culls draw their cull box |
| 314 fCommandVector[i]->vizExecute(canvas); | 303 fCommandVector[i]->vizExecute(canvas); |
| 315 } else { | 304 } else { |
| 316 fCommandVector[i]->execute(canvas); | 305 fCommandVector[i]->execute(canvas); |
| 317 } | 306 } |
| 318 | 307 |
| 319 fCommandVector[i]->trackSaveState(&fOutstandingSaveCount); | 308 fCommandVector[i]->trackSaveState(&fOutstandingSaveCount); |
| 320 } | 309 } |
| 321 } | 310 } |
| 322 | 311 |
| 323 if (fMegaVizMode) { | 312 if (fMegaVizMode) { |
| 324 SkRect r = SkRect::MakeWH(SkIntToScalar(fWidth), SkIntToScalar(fHeight))
; | 313 SkRect r = SkRect::MakeWH(SkIntToScalar(fWindowSize.fWidth), |
| 314 SkIntToScalar(fWindowSize.fHeight)); |
| 325 r.outset(SK_Scalar1, SK_Scalar1); | 315 r.outset(SK_Scalar1, SK_Scalar1); |
| 326 | 316 |
| 327 canvas->save(); | 317 canvas->save(); |
| 328 // nuke the CTM | 318 // nuke the CTM |
| 329 canvas->setMatrix(SkMatrix::I()); | 319 canvas->resetMatrix(); |
| 330 // turn off clipping | 320 // turn off clipping |
| 331 canvas->clipRect(r, SkRegion::kReplace_Op); | 321 canvas->clipRect(r, SkRegion::kReplace_Op); |
| 332 | 322 |
| 333 // visualize existing clips | 323 // visualize existing clips |
| 334 SkDebugClipVisitor visitor(canvas); | 324 SkDebugClipVisitor visitor(canvas); |
| 335 | 325 |
| 336 canvas->replayClips(&visitor); | 326 canvas->replayClips(&visitor); |
| 337 | 327 |
| 338 canvas->restore(); | 328 canvas->restore(); |
| 339 } | 329 } |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 } | 727 } |
| 738 | 728 |
| 739 bool SkDebugCanvas::lastClipStackData(const SkPath& devPath) { | 729 bool SkDebugCanvas::lastClipStackData(const SkPath& devPath) { |
| 740 if (fCalledAddStackData) { | 730 if (fCalledAddStackData) { |
| 741 fClipStackData.appendf("<br>"); | 731 fClipStackData.appendf("<br>"); |
| 742 addPathData(devPath, "pathOut"); | 732 addPathData(devPath, "pathOut"); |
| 743 return true; | 733 return true; |
| 744 } | 734 } |
| 745 return false; | 735 return false; |
| 746 } | 736 } |
| OLD | NEW |