chudy@google.com | 38b08ce | 2012-07-28 23:26:10 +0000 | [diff] [blame] | 1 | /* |
| 2 | * SkRasterWidget.h |
| 3 | * |
| 4 | * Created on: Jul 28, 2012 |
| 5 | * Author: chudy |
| 6 | */ |
| 7 | |
| 8 | |
| 9 | #ifndef SKRASTERWIDGET_H_ |
| 10 | #define SKRASTERWIDGET_H_ |
| 11 | |
| 12 | #include "SkGpuDevice.h" |
| 13 | #include "SkDevice.h" |
| 14 | #include "SkDebugCanvas.h" |
| 15 | |
| 16 | #include <QApplication> |
| 17 | #include <QtGui> |
| 18 | #include <QWidget> |
| 19 | |
| 20 | class SkRasterWidget : public QWidget { |
chudy@google.com | a9e937c | 2012-08-03 17:32:05 +0000 | [diff] [blame] | 21 | Q_OBJECT |
chudy@google.com | 38b08ce | 2012-07-28 23:26:10 +0000 | [diff] [blame] | 22 | |
| 23 | public: |
chudy@google.com | 830b879 | 2012-08-01 15:57:52 +0000 | [diff] [blame] | 24 | SkRasterWidget(); |
chudy@google.com | 38b08ce | 2012-07-28 23:26:10 +0000 | [diff] [blame] | 25 | |
| 26 | ~SkRasterWidget(); |
| 27 | |
| 28 | void drawTo(int index) { |
| 29 | fIndex = index; |
| 30 | this->update(); |
| 31 | } |
| 32 | |
| 33 | void setDebugCanvas(SkDebugCanvas* debugCanvas) { |
| 34 | fDebugCanvas = debugCanvas; |
chudy@google.com | 0b5bbb0 | 2012-07-31 19:55:32 +0000 | [diff] [blame] | 35 | fIndex = debugCanvas->getSize() - 1; |
chudy@google.com | 38b08ce | 2012-07-28 23:26:10 +0000 | [diff] [blame] | 36 | this->update(); |
| 37 | } |
| 38 | |
| 39 | int getBitmapHeight() { |
| 40 | return fBitmap.height(); |
| 41 | } |
| 42 | |
| 43 | int getBitmapWidth() { |
| 44 | return fBitmap.width(); |
| 45 | } |
| 46 | |
chudy@google.com | 38b08ce | 2012-07-28 23:26:10 +0000 | [diff] [blame] | 47 | void setTranslate(SkIPoint transform) { |
| 48 | fTransform = transform; |
| 49 | } |
| 50 | |
| 51 | void setScale(float scale) { |
| 52 | fScaleFactor = scale; |
| 53 | } |
| 54 | |
chudy@google.com | a9e937c | 2012-08-03 17:32:05 +0000 | [diff] [blame] | 55 | signals: |
| 56 | void drawComplete(); |
| 57 | |
chudy@google.com | 38b08ce | 2012-07-28 23:26:10 +0000 | [diff] [blame] | 58 | protected: |
| 59 | void paintEvent(QPaintEvent* event); |
| 60 | |
| 61 | void resizeEvent(QResizeEvent* event); |
| 62 | |
| 63 | private: |
| 64 | SkBitmap fBitmap; |
| 65 | SkDebugCanvas* fDebugCanvas; |
chudy@google.com | 830b879 | 2012-08-01 15:57:52 +0000 | [diff] [blame] | 66 | SkCanvas* fCanvas; |
chudy@google.com | 38b08ce | 2012-07-28 23:26:10 +0000 | [diff] [blame] | 67 | SkDevice* fDevice; |
| 68 | |
chudy@google.com | 38b08ce | 2012-07-28 23:26:10 +0000 | [diff] [blame] | 69 | int fIndex; |
| 70 | SkIPoint fTransform; |
| 71 | float fScaleFactor; |
| 72 | }; |
| 73 | |
| 74 | #endif /* SKRASTERWIDGET_H_ */ |