aboutsummaryrefslogtreecommitdiffhomepage
path: root/debugger/QT/SkImageWidget.cpp
diff options
context:
space:
mode:
authorGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-06-06 23:59:28 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-06-06 23:59:28 +0000
commit6ede1fe62bbb4e98f4eff4e4afb1d20e1e070423 (patch)
treedfb6eef74afb49fd61ce0b9dfaa56a4faf5cb5af /debugger/QT/SkImageWidget.cpp
parent7bb28a1679d5d0c07e4cdf983316417cffdc4197 (diff)
Make SkDrawCommands lighter weight
Diffstat (limited to 'debugger/QT/SkImageWidget.cpp')
-rw-r--r--debugger/QT/SkImageWidget.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/debugger/QT/SkImageWidget.cpp b/debugger/QT/SkImageWidget.cpp
index 10fe0b19ff..76b6b21059 100644
--- a/debugger/QT/SkImageWidget.cpp
+++ b/debugger/QT/SkImageWidget.cpp
@@ -15,6 +15,14 @@ SkImageWidget::SkImageWidget(SkDebugger *debugger)
: QWidget()
, fDebugger(debugger) {
this->setStyleSheet("QWidget {background-color: white; border: 1px solid #cccccc;}");
+
+ SkImage::Info info;
+ info.fWidth = kImageWidgetWidth;
+ info.fHeight = kImageWidgetHeight;
+ info.fColorType = SkImage::kPMColor_ColorType;
+ info.fAlphaType = SkImage::kPremul_AlphaType;
+
+ fSurface = SkSurface::NewRasterDirect(info, fPixels, 4 * kImageWidgetWidth);
}
void SkImageWidget::paintEvent(QPaintEvent* event) {
@@ -32,18 +40,14 @@ void SkImageWidget::paintEvent(QPaintEvent* event) {
if (0 != commands.count()) {
SkDrawCommand* command = commands[fDebugger->index()];
- const SkBitmap* bitmap = command->getBitmap();
-
- if (NULL != bitmap) {
- bitmap->lockPixels();
-
+ if (command->render(fSurface->getCanvas())) {
QPoint origin(0,0);
- QImage image((uchar *)bitmap->getPixels(), bitmap->width(),
- bitmap->height(), QImage::Format_ARGB32_Premultiplied);
+ QImage image((uchar*) fPixels,
+ kImageWidgetWidth,
+ kImageWidgetHeight,
+ QImage::Format_ARGB32_Premultiplied);
painter.drawImage(origin, image);
-
- bitmap->unlockPixels();
} else {
painter.drawRect(0, 0, kImageWidgetWidth, kImageWidgetHeight);
}