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 #include "SkRasterWidget.h" | 9 #include "SkRasterWidget.h" |
10 #include "SkDebugger.h" | 10 #include "SkDebugger.h" |
11 #include <QtGui> | 11 #include <QtGui> |
12 | 12 |
13 SkRasterWidget::SkRasterWidget(SkDebugger *debugger) | 13 SkRasterWidget::SkRasterWidget(SkDebugger *debugger) |
14 : QWidget() | 14 : QWidget() |
15 , fDebugger(debugger) | 15 , fDebugger(debugger) |
16 , fNeedImageUpdate(false) { | 16 , fNeedImageUpdate(false) { |
17 this->setStyleSheet("QWidget {background-color: black; border: 1px solid #cc
cccc;}"); | 17 this->setStyleSheet("QWidget {background-color: black; border: 1px solid #cc
cccc;}"); |
18 } | 18 } |
19 | 19 |
20 void SkRasterWidget::resizeEvent(QResizeEvent* event) { | 20 void SkRasterWidget::resizeEvent(QResizeEvent* event) { |
21 this->QWidget::resizeEvent(event); | 21 this->QWidget::resizeEvent(event); |
22 | 22 |
23 QRect r = this->contentsRect(); | 23 QRect r = this->contentsRect(); |
24 if (r.width() == 0 || r.height() == 0) { | 24 if (r.width() == 0 || r.height() == 0) { |
25 fSurface.reset(NULL); | 25 fSurface.reset(nullptr); |
26 } else { | 26 } else { |
27 SkImageInfo info = SkImageInfo::MakeN32Premul(r.width(), r.height()); | 27 SkImageInfo info = SkImageInfo::MakeN32Premul(r.width(), r.height()); |
28 fSurface.reset(SkSurface::NewRaster(info)); | 28 fSurface.reset(SkSurface::NewRaster(info)); |
29 } | 29 } |
30 this->updateImage(); | 30 this->updateImage(); |
31 } | 31 } |
32 | 32 |
33 void SkRasterWidget::paintEvent(QPaintEvent* event) { | 33 void SkRasterWidget::paintEvent(QPaintEvent* event) { |
34 QPainter painter(this); | 34 QPainter painter(this); |
35 painter.setRenderHint(QPainter::Antialiasing); | 35 painter.setRenderHint(QPainter::Antialiasing); |
(...skipping 28 matching lines...) Expand all Loading... |
64 } | 64 } |
65 } | 65 } |
66 | 66 |
67 void SkRasterWidget::updateImage() { | 67 void SkRasterWidget::updateImage() { |
68 if (!fSurface) { | 68 if (!fSurface) { |
69 return; | 69 return; |
70 } | 70 } |
71 fNeedImageUpdate = true; | 71 fNeedImageUpdate = true; |
72 this->update(); | 72 this->update(); |
73 } | 73 } |
OLD | NEW |