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 <QtGui> | 9 #include <QtGui> |
10 | 10 |
11 #include "SkDebugger.h" | 11 #include "SkDebugger.h" |
12 #include "SkImageWidget.h" | 12 #include "SkImageWidget.h" |
13 | 13 |
14 SkImageWidget::SkImageWidget(SkDebugger *debugger) | 14 SkImageWidget::SkImageWidget(SkDebugger *debugger) |
15 : QWidget() | 15 : QWidget() |
16 , fDebugger(debugger) { | 16 , fDebugger(debugger) |
| 17 { |
17 this->setStyleSheet("QWidget {background-color: white; border: 1px solid #cc
cccc;}"); | 18 this->setStyleSheet("QWidget {background-color: white; border: 1px solid #cc
cccc;}"); |
18 | 19 |
19 SkImageInfo info; | 20 SkImageInfo info = SkImageInfo::MakeN32Premul(kImageWidgetWidth, kImageWidge
tHeight); |
20 info.fWidth = kImageWidgetWidth; | |
21 info.fHeight = kImageWidgetHeight; | |
22 info.fColorType = kN32_SkColorType; | |
23 info.fAlphaType = kPremul_SkAlphaType; | |
24 | |
25 fSurface = SkSurface::NewRasterDirect(info, fPixels, 4 * kImageWidgetWidth); | 21 fSurface = SkSurface::NewRasterDirect(info, fPixels, 4 * kImageWidgetWidth); |
26 } | 22 } |
27 | 23 |
28 void SkImageWidget::paintEvent(QPaintEvent* event) { | 24 void SkImageWidget::paintEvent(QPaintEvent* event) { |
29 if (this->isHidden()) { | 25 if (this->isHidden()) { |
30 return; | 26 return; |
31 } | 27 } |
32 | 28 |
33 QPainter painter(this); | 29 QPainter painter(this); |
34 QStyleOption opt; | 30 QStyleOption opt; |
(...skipping 14 matching lines...) Expand all Loading... |
49 | 45 |
50 painter.drawImage(origin, image); | 46 painter.drawImage(origin, image); |
51 } else { | 47 } else { |
52 painter.drawRect(0, 0, kImageWidgetWidth, kImageWidgetHeight); | 48 painter.drawRect(0, 0, kImageWidgetWidth, kImageWidgetHeight); |
53 } | 49 } |
54 } | 50 } |
55 | 51 |
56 painter.end(); | 52 painter.end(); |
57 emit drawComplete(); | 53 emit drawComplete(); |
58 } | 54 } |
OLD | NEW |