Add drawing of paths to debugger

https://codereview.appspot.com/6850082/



git-svn-id: http://skia.googlecode.com/svn/trunk@6532 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/debugger/QT/SkImageWidget.cpp b/debugger/QT/SkImageWidget.cpp
new file mode 100644
index 0000000..36a1b3d
--- /dev/null
+++ b/debugger/QT/SkImageWidget.cpp
@@ -0,0 +1,54 @@
+
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <QtGui>
+
+#include "SkDebugger.h"
+#include "SkImageWidget.h"
+
+SkImageWidget::SkImageWidget(SkDebugger *debugger) 
+    : QWidget()
+    , fDebugger(debugger) {
+    this->setStyleSheet("QWidget {background-color: white; border: 1px solid #cccccc;}");
+}
+
+void SkImageWidget::paintEvent(QPaintEvent* event) {
+    if (this->isHidden()) {
+        return;
+    }
+
+    QPainter painter(this);
+    QStyleOption opt;
+    opt.init(this);
+
+    style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);
+
+    const SkTDArray<SkDrawCommand*>& commands = fDebugger->getDrawCommands();
+    if (0 != commands.count()) {
+        SkDrawCommand* command = commands[fDebugger->index()];
+
+        const SkBitmap* bitmap = command->getBitmap();
+
+        if (NULL != bitmap) {
+            bitmap->lockPixels();
+
+            QPoint origin(0,0);
+            QImage image((uchar *)bitmap->getPixels(), bitmap->width(),
+                    bitmap->height(), QImage::Format_ARGB32_Premultiplied);
+
+            painter.drawImage(origin, image);
+
+            bitmap->unlockPixels();
+        } else {
+            painter.drawRect(0, 0, kImageWidgetWidth, kImageWidgetHeight);
+        }
+    }
+
+    painter.end();
+    emit drawComplete();
+}