aboutsummaryrefslogtreecommitdiffhomepage
path: root/debugger/QT
diff options
context:
space:
mode:
Diffstat (limited to 'debugger/QT')
-rw-r--r--debugger/QT/SkImageWidget.cpp22
-rw-r--r--debugger/QT/SkImageWidget.h9
2 files changed, 21 insertions, 10 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);
}
diff --git a/debugger/QT/SkImageWidget.h b/debugger/QT/SkImageWidget.h
index 594b21a2f6..f36857b420 100644
--- a/debugger/QT/SkImageWidget.h
+++ b/debugger/QT/SkImageWidget.h
@@ -11,6 +11,7 @@
#include <QWidget>
+#include "SkSurface.h"
class SkDebugger;
class SkImageWidget : public QWidget {
@@ -18,6 +19,10 @@ class SkImageWidget : public QWidget {
public:
SkImageWidget(SkDebugger* debugger);
+
+ virtual ~SkImageWidget() {
+ fSurface->unref();
+ }
void draw() {
this->update();
@@ -33,7 +38,9 @@ protected:
void paintEvent(QPaintEvent* event);
private:
- SkDebugger *fDebugger;
+ SkDebugger* fDebugger;
+ char fPixels[kImageWidgetHeight * 4 * kImageWidgetWidth];
+ SkSurface* fSurface;
};
#endif /* SKIMAGEWIDGET_H_ */