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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 drawTo(canvas, fCommandVector.count() - 1); | 67 drawTo(canvas, fCommandVector.count() - 1); |
68 } | 68 } |
69 } | 69 } |
70 | 70 |
71 void SkDebugCanvas::applyUserTransform(SkCanvas* canvas) { | 71 void SkDebugCanvas::applyUserTransform(SkCanvas* canvas) { |
72 canvas->concat(fUserMatrix); | 72 canvas->concat(fUserMatrix); |
73 } | 73 } |
74 | 74 |
75 int SkDebugCanvas::getCommandAtPoint(int x, int y, int index) { | 75 int SkDebugCanvas::getCommandAtPoint(int x, int y, int index) { |
76 SkBitmap bitmap; | 76 SkBitmap bitmap; |
77 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 1, 1); | 77 bitmap.allocPixels(SkImageInfo::MakeN32Premul(1, 1)); |
78 bitmap.allocPixels(); | |
79 | 78 |
80 SkCanvas canvas(bitmap); | 79 SkCanvas canvas(bitmap); |
81 canvas.translate(SkIntToScalar(-x), SkIntToScalar(-y)); | 80 canvas.translate(SkIntToScalar(-x), SkIntToScalar(-y)); |
82 applyUserTransform(&canvas); | 81 applyUserTransform(&canvas); |
83 | 82 |
84 int layer = 0; | 83 int layer = 0; |
85 SkColor prev = bitmap.getColor(0,0); | 84 SkColor prev = bitmap.getColor(0,0); |
86 for (int i = 0; i < index; i++) { | 85 for (int i = 0; i < index; i++) { |
87 if (fCommandVector[i]->isVisible()) { | 86 if (fCommandVector[i]->isVisible()) { |
88 fCommandVector[i]->execute(&canvas); | 87 fCommandVector[i]->execute(&canvas); |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 | 467 |
469 bool SkDebugCanvas::translate(SkScalar dx, SkScalar dy) { | 468 bool SkDebugCanvas::translate(SkScalar dx, SkScalar dy) { |
470 addDrawCommand(new SkTranslateCommand(dx, dy)); | 469 addDrawCommand(new SkTranslateCommand(dx, dy)); |
471 return true; | 470 return true; |
472 } | 471 } |
473 | 472 |
474 void SkDebugCanvas::toggleCommand(int index, bool toggle) { | 473 void SkDebugCanvas::toggleCommand(int index, bool toggle) { |
475 SkASSERT(index < fCommandVector.count()); | 474 SkASSERT(index < fCommandVector.count()); |
476 fCommandVector[index]->setVisible(toggle); | 475 fCommandVector[index]->setVisible(toggle); |
477 } | 476 } |
OLD | NEW |