| chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2012 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
| 8 | |
| 9 | |
| 10 | #ifndef SKGLWIDGET_H_ |
| 11 | #define SKGLWIDGET_H_ |
| 12 | |
| 13 | #include <QtOpenGL/QGLWidget> |
| 14 | #include "SkDebugCanvas.h" |
| 15 | #include "SkDevice.h" |
| 16 | #include "SkGpuDevice.h" |
| 17 | |
| 18 | #include "GrContext.h" |
| 19 | #include "gl/GrGLInterface.h" |
| 20 | #include "gl/GrGLUtil.h" |
| 21 | #include "GrRenderTarget.h" |
| 22 | |
| 23 | class SkGLWidget : public QGLWidget { |
| chudy@google.com | a9e937c | 2012-08-03 17:32:05 +0000 | [diff] [blame^] | 24 | Q_OBJECT |
| chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 25 | |
| 26 | public: |
| chudy@google.com | 2d537a1 | 2012-07-31 12:49:52 +0000 | [diff] [blame] | 27 | SkGLWidget(); |
| chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 28 | |
| 29 | ~SkGLWidget(); |
| 30 | |
| 31 | void setDebugCanvas(SkDebugCanvas* debugCanvas) { |
| 32 | fDebugCanvas = debugCanvas; |
| chudy@google.com | 0b5bbb0 | 2012-07-31 19:55:32 +0000 | [diff] [blame] | 33 | fIndex = debugCanvas->getSize() - 1; |
| chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 34 | this->updateGL(); |
| 35 | } |
| 36 | |
| 37 | void drawTo(int index) { |
| 38 | fIndex = index; |
| 39 | this->updateGL(); |
| 40 | } |
| 41 | |
| 42 | void setTranslate(SkIPoint translate) { |
| 43 | fTransform = translate; |
| 44 | } |
| 45 | |
| 46 | void setScale(float scale) { |
| 47 | fScaleFactor = scale; |
| 48 | } |
| 49 | |
| chudy@google.com | a9e937c | 2012-08-03 17:32:05 +0000 | [diff] [blame^] | 50 | signals: |
| 51 | void drawComplete(); |
| 52 | |
| chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 53 | protected: |
| 54 | void initializeGL(); |
| 55 | void resizeGL(int w, int h); |
| 56 | void paintGL(); |
| 57 | |
| 58 | |
| 59 | private: |
| 60 | const GrGLInterface* fCurIntf; |
| 61 | GrContext* fCurContext; |
| 62 | SkGpuDevice* fGpuDevice; |
| 63 | SkCanvas* fCanvas; |
| 64 | SkDebugCanvas* fDebugCanvas; |
| 65 | int fIndex; |
| 66 | SkIPoint fTransform; |
| 67 | float fScaleFactor; |
| chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 68 | GrPlatformRenderTargetDesc getDesc(int w, int h); |
| 69 | }; |
| 70 | |
| 71 | #endif /* SKGLWIDGET_H_ */ |