OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 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 #include <QtGui> | 9 #include <QtGui> |
10 | 10 |
11 #include "SkDebugger.h" | 11 #include "SkDebugger.h" |
12 #include "SkDrawCommandGeometryWidget.h" | 12 #include "SkDrawCommandGeometryWidget.h" |
13 | 13 |
14 SkDrawCommandGeometryWidget::SkDrawCommandGeometryWidget(SkDebugger *debugger) | 14 SkDrawCommandGeometryWidget::SkDrawCommandGeometryWidget(SkDebugger *debugger) |
15 : QFrame() | 15 : QFrame() |
16 , fDebugger(debugger) { | 16 , fDebugger(debugger) |
17 , fCommandIndex(-1) { | |
17 this->setStyleSheet("QFrame {background-color: black; border: 1px solid #ccc ccc;}"); | 18 this->setStyleSheet("QFrame {background-color: black; border: 1px solid #ccc ccc;}"); |
18 } | 19 } |
19 | 20 |
20 void SkDrawCommandGeometryWidget::resizeEvent(QResizeEvent* event) { | 21 void SkDrawCommandGeometryWidget::resizeEvent(QResizeEvent* event) { |
21 this->QFrame::resizeEvent(event); | 22 this->QFrame::resizeEvent(event); |
22 QRect r = this->contentsRect(); | 23 QRect r = this->contentsRect(); |
23 int dim = std::min(r.width(), r.height()); | 24 int dim = std::min(r.width(), r.height()); |
24 if (dim == 0) { | 25 if (dim == 0) { |
25 fSurface.reset(NULL); | 26 fSurface.reset(NULL); |
26 } else { | 27 } else { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 resultRect.moveCenter(this->contentsRect().center()); | 59 resultRect.moveCenter(this->contentsRect().center()); |
59 | 60 |
60 QImage image(reinterpret_cast<const uchar*>(pixels), | 61 QImage image(reinterpret_cast<const uchar*>(pixels), |
61 info.width(), | 62 info.width(), |
62 info.height(), | 63 info.height(), |
63 QImage::Format_ARGB32_Premultiplied); | 64 QImage::Format_ARGB32_Premultiplied); |
64 painter.drawImage(resultRect, image); | 65 painter.drawImage(resultRect, image); |
65 } | 66 } |
66 } | 67 } |
67 | 68 |
69 void SkDrawCommandGeometryWidget::setDrawCommandIndex(int commandIndex) { | |
70 fCommandIndex = commandIndex; | |
robertphillips
2015/01/05 19:14:09
this-> ?
Kimmo Kinnunen
2015/01/07 07:33:48
Done.
| |
71 updateImage(); | |
72 } | |
73 | |
68 void SkDrawCommandGeometryWidget::updateImage() { | 74 void SkDrawCommandGeometryWidget::updateImage() { |
69 if (!fSurface) { | 75 if (!fSurface) { |
70 return; | 76 return; |
71 } | 77 } |
72 | 78 |
73 bool didRender = false; | 79 bool didRender = false; |
74 const SkTDArray<SkDrawCommand*>& commands = fDebugger->getDrawCommands(); | 80 const SkTDArray<SkDrawCommand*>& commands = fDebugger->getDrawCommands(); |
75 if (0 != commands.count()) { | 81 if (0 != commands.count() && fCommandIndex >= 0) { |
76 SkDrawCommand* command = commands[fDebugger->index()]; | 82 SkASSERT(commands.count() > fCommandIndex); |
83 SkDrawCommand* command = commands[fCommandIndex]; | |
77 didRender = command->render(fSurface->getCanvas()); | 84 didRender = command->render(fSurface->getCanvas()); |
78 } | 85 } |
79 | 86 |
80 if (!didRender) { | 87 if (!didRender) { |
81 fSurface->getCanvas()->clear(SK_ColorTRANSPARENT); | 88 fSurface->getCanvas()->clear(SK_ColorTRANSPARENT); |
82 } | 89 } |
83 | 90 |
84 fSurface->getCanvas()->flush(); | 91 fSurface->getCanvas()->flush(); |
85 update(); | 92 update(); |
86 } | 93 } |
OLD | NEW |