aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar chudy@google.com <chudy@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-28 23:26:10 +0000
committerGravatar chudy@google.com <chudy@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-28 23:26:10 +0000
commit38b08ce020f451a66263110b32e70f5022df4f83 (patch)
tree9aa894b799659b7a09627a2adbbcb1e50866a934
parent0ab03397afd3420ea8fd9323d78ddd562a7b7bdf (diff)
Added missing files to fix build.
TBR Review URL: https://codereview.appspot.com/6455058 git-svn-id: http://skia.googlecode.com/svn/trunk@4822 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--debugger/QT/SkDebuggerGUI.cpp2
-rw-r--r--debugger/QT/SkRasterWidget.cpp64
-rw-r--r--debugger/QT/SkRasterWidget.h80
3 files changed, 145 insertions, 1 deletions
diff --git a/debugger/QT/SkDebuggerGUI.cpp b/debugger/QT/SkDebuggerGUI.cpp
index 830f0f6a8e..e497ff77fd 100644
--- a/debugger/QT/SkDebuggerGUI.cpp
+++ b/debugger/QT/SkDebuggerGUI.cpp
@@ -217,7 +217,7 @@ void SkDebuggerGUI::actionSave() {
void SkDebuggerGUI::actionSaveAs() {
QString filename = QFileDialog::getSaveFileName(this, "Save File", "",
"Skia Picture (*skp)");
- if (!filename.endsWith(".skp", Qt::CaseInsensitive))
+ if (!filename.endsWith(".skp", Qt::CaseInsensitive)) {
filename.append(".skp");
}
saveToFile(filename);
diff --git a/debugger/QT/SkRasterWidget.cpp b/debugger/QT/SkRasterWidget.cpp
new file mode 100644
index 0000000000..0549649543
--- /dev/null
+++ b/debugger/QT/SkRasterWidget.cpp
@@ -0,0 +1,64 @@
+
+/*
+ * 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 "SkRasterWidget.h"
+
+SkRasterWidget::SkRasterWidget(QWidget* parent) : QWidget(parent) {
+ fBitmap.setConfig(SkBitmap::kARGB_8888_Config, 800, 800);
+ fBitmap.allocPixels();
+ fBitmap.eraseColor(0);
+ fTransform.set(0,0);
+ fScaleFactor = 1.0;
+ fIndex = 0;
+
+ fDebugCanvas = new SkDebugCanvas();
+ this->setStyleSheet("QWidget {background-color: white; border: 1px solid #cccccc;}");
+}
+
+SkRasterWidget::~SkRasterWidget() {
+ delete fDevice;
+ delete fDebugCanvas;
+}
+
+void SkRasterWidget::resizeEvent(QResizeEvent* event) {
+ fBitmap.setConfig(SkBitmap::kARGB_8888_Config, event->size().width(), event->size().height());
+ fBitmap.allocPixels();
+ delete fDevice;
+ fDevice = new SkDevice(fBitmap);
+ fDebugCanvas->setBounds(event->size().width(), event->size().height());
+ this->update();
+}
+
+void SkRasterWidget::paintEvent(QPaintEvent* event) {
+ fBitmap.eraseColor(0);
+ SkCanvas canvas(fDevice);
+ canvas.translate(fTransform.fX, fTransform.fY);
+ if (fScaleFactor < 0) {
+ canvas.scale((1.0 / -fScaleFactor), (1.0 / -fScaleFactor));
+ } else if (fScaleFactor > 0) {
+ canvas.scale(fScaleFactor, fScaleFactor);
+ }
+
+ fMatrix = canvas.getTotalMatrix();
+ fClip = canvas.getTotalClip().getBounds();
+ fDebugCanvas->drawTo(&canvas, fIndex+1, &fBitmap);
+
+ QPainter painter(this);
+ QStyleOption opt;
+ opt.init(this);
+
+ style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);
+
+ QPoint origin(0,0);
+ QImage image((uchar *)fBitmap.getPixels(), fBitmap.width(),
+ fBitmap.height(), QImage::Format_ARGB32_Premultiplied);
+
+ painter.drawImage(origin, image);
+ painter.end();
+}
diff --git a/debugger/QT/SkRasterWidget.h b/debugger/QT/SkRasterWidget.h
new file mode 100644
index 0000000000..af65792e77
--- /dev/null
+++ b/debugger/QT/SkRasterWidget.h
@@ -0,0 +1,80 @@
+/*
+ * SkRasterWidget.h
+ *
+ * Created on: Jul 28, 2012
+ * Author: chudy
+ */
+
+
+#ifndef SKRASTERWIDGET_H_
+#define SKRASTERWIDGET_H_
+
+#include "SkGpuDevice.h"
+#include "SkDevice.h"
+#include "SkDebugCanvas.h"
+
+#include <QApplication>
+#include <QtGui>
+#include <QWidget>
+
+class SkRasterWidget : public QWidget {
+
+public:
+ SkRasterWidget(QWidget* parent = NULL);
+
+ ~SkRasterWidget();
+
+ void drawTo(int index) {
+ fIndex = index;
+ this->update();
+ }
+
+ void setDebugCanvas(SkDebugCanvas* debugCanvas) {
+ fDebugCanvas = debugCanvas;
+ fIndex = debugCanvas->getSize();
+ this->update();
+ }
+
+ int getBitmapHeight() {
+ return fBitmap.height();
+ }
+
+ int getBitmapWidth() {
+ return fBitmap.width();
+ }
+
+ const SkMatrix& getCurrentMatrix() {
+ return fMatrix;
+ }
+
+ const SkIRect& getCurrentClip() {
+ return fClip;
+ }
+
+ void setTranslate(SkIPoint transform) {
+ fTransform = transform;
+ }
+
+ void setScale(float scale) {
+ fScaleFactor = scale;
+ }
+
+protected:
+ void paintEvent(QPaintEvent* event);
+
+ void resizeEvent(QResizeEvent* event);
+
+private:
+ SkBitmap fBitmap;
+ SkDebugCanvas* fDebugCanvas;
+ SkDevice* fDevice;
+
+ SkMatrix fMatrix;
+ SkIRect fClip;
+
+ int fIndex;
+ SkIPoint fTransform;
+ float fScaleFactor;
+};
+
+#endif /* SKRASTERWIDGET_H_ */