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 , fCommandIndex(-1) { |
18 this->setStyleSheet("QFrame {background-color: black; border: 1px solid #ccc
ccc;}"); | 18 this->setStyleSheet("QFrame {background-color: black; border: 1px solid #ccc
ccc;}"); |
19 } | 19 } |
20 | 20 |
21 void SkDrawCommandGeometryWidget::resizeEvent(QResizeEvent* event) { | 21 void SkDrawCommandGeometryWidget::resizeEvent(QResizeEvent* event) { |
22 this->QFrame::resizeEvent(event); | 22 this->QFrame::resizeEvent(event); |
23 QRect r = this->contentsRect(); | 23 QRect r = this->contentsRect(); |
24 int dim = std::min(r.width(), r.height()); | 24 int dim = std::min(r.width(), r.height()); |
25 if (dim == 0) { | 25 if (dim == 0) { |
26 fSurface.reset(nullptr); | 26 fSurface = nullptr; |
27 } else { | 27 } else { |
28 SkImageInfo info = SkImageInfo::MakeN32Premul(dim, dim); | 28 SkImageInfo info = SkImageInfo::MakeN32Premul(dim, dim); |
29 fSurface.reset(SkSurface::NewRaster(info)); | 29 fSurface = SkSurface::MakeRaster(info); |
30 this->updateImage(); | 30 this->updateImage(); |
31 } | 31 } |
32 } | 32 } |
33 | 33 |
34 void SkDrawCommandGeometryWidget::paintEvent(QPaintEvent* event) { | 34 void SkDrawCommandGeometryWidget::paintEvent(QPaintEvent* event) { |
35 this->QFrame::paintEvent(event); | 35 this->QFrame::paintEvent(event); |
36 | 36 |
37 if (!fSurface) { | 37 if (!fSurface) { |
38 return; | 38 return; |
39 } | 39 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 didRender = command->render(fSurface->getCanvas()); | 85 didRender = command->render(fSurface->getCanvas()); |
86 } | 86 } |
87 | 87 |
88 if (!didRender) { | 88 if (!didRender) { |
89 fSurface->getCanvas()->clear(SK_ColorTRANSPARENT); | 89 fSurface->getCanvas()->clear(SK_ColorTRANSPARENT); |
90 } | 90 } |
91 | 91 |
92 fSurface->getCanvas()->flush(); | 92 fSurface->getCanvas()->flush(); |
93 this->update(); | 93 this->update(); |
94 } | 94 } |
OLD | NEW |