clt debugger
Review URL: https://codereview.appspot.com/6267043
git-svn-id: http://skia.googlecode.com/svn/trunk@4404 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/debugger/QT/SkCanvasWidget.h b/debugger/QT/SkCanvasWidget.h
new file mode 100644
index 0000000..a7e1c8a
--- /dev/null
+++ b/debugger/QT/SkCanvasWidget.h
@@ -0,0 +1,118 @@
+
+/*
+ * Copyright 2012 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+
+#ifndef SKCANVASWIDGET_H
+#define SKCANVASWIDGET_H
+
+#include "SkBitmap.h"
+#include "SkCanvas.h"
+#include "SkDebugCanvas.h"
+#include "SkDevice.h"
+#include "SkPicture.h"
+#include <QApplication>
+#include <QtGui>
+#include <QWidget>
+
+/** \class SkCanvasWidget
+
+ The QtWidget encompasses all skia screen drawing elements. It initializes
+ an SkBitmap in memory that our SkCanvas draws to directly in memory.
+ Then using QImage and QPainter we draw those pixels on the screen in
+ this widget.
+ */
+class SkCanvasWidget : public QWidget {
+ Q_OBJECT
+
+public:
+ /**
+ Constructs a widget with the specified parent for layout purposes.
+ @param parent The parent container of this widget
+ */
+ SkCanvasWidget(QWidget *parent);
+
+ ~SkCanvasWidget();
+
+ /**
+ Executes all saved draw commands up to the specified index.
+ @param index The position of the command we draw up to.
+ */
+ void drawTo(int index);
+
+ /**
+ Returns the height of the bitmap.
+ */
+ int getBitmapHeight() { return fBitmap->height(); }
+
+
+ /*
+ Returns the width of the bitmap.
+ */
+ int getBitmapWidth() { return fBitmap->width(); }
+
+ /**
+ TODO(chudy): Refactor into a struct of char**
+ Returns parameter information about the ith draw command.
+ @param: i The index of the draw command we are accessing
+ */
+ std::vector<std::string>* getCurrentCommandInfo(int i) {
+ return fDebugCanvas->getCommandInfoAt(i);
+ }
+
+ /**
+ Returns a vector of strings with all the current canvas draw
+ commands.
+ */
+ std::vector<std::string>* getDrawCommands() {
+ return fDebugCanvas->getDrawCommandsAsStrings();
+ }
+
+ /**
+ Loads a skia picture located at filename.
+ @param filename The name of the file we are loading.
+ */
+ void loadPicture(QString filename);
+
+ /**
+ Toggles the visibility / execution of the draw command at index i.
+ */
+ void toggleCommand(int index) {
+ fDebugCanvas->toggleCommand(index);
+ }
+
+ /**
+ Toggles the visibility / execution of the draw command at index i with
+ the value of toggle.
+ */
+ void toggleCommand(int index, bool toggle) {
+ fDebugCanvas->toggleCommand(index, toggle);
+ }
+
+ /**
+ Toggles drawing filter on all drawing commands previous to current.
+ */
+ void toggleCurrentCommandFilter(bool toggle) {
+ fDebugCanvas->toggleFilter(toggle);
+ }
+
+
+protected:
+ /**
+ Draws the current state of the widget.
+ @param event The event intercepted by Qt
+ */
+ void paintEvent(QPaintEvent *event);
+
+private:
+ SkBitmap* fBitmap;
+ SkCanvas* fCanvas;
+ SkDebugCanvas* fDebugCanvas;
+ SkDevice* fDevice;
+};
+
+#endif