| 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 { |
| 24 | |
| 25 | public: |
| chudy@google.com | 2d537a1 | 2012-07-31 12:49:52 +0000 | [diff] [blame] | 26 | SkGLWidget(); |
| chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 27 | |
| 28 | ~SkGLWidget(); |
| 29 | |
| 30 | void setDebugCanvas(SkDebugCanvas* debugCanvas) { |
| 31 | fDebugCanvas = debugCanvas; |
| chudy@google.com | 0b5bbb0 | 2012-07-31 19:55:32 +0000 | [diff] [blame] | 32 | fIndex = debugCanvas->getSize() - 1; |
| chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 33 | this->updateGL(); |
| 34 | } |
| 35 | |
| 36 | void drawTo(int index) { |
| 37 | fIndex = index; |
| 38 | this->updateGL(); |
| 39 | } |
| 40 | |
| 41 | void setTranslate(SkIPoint translate) { |
| 42 | fTransform = translate; |
| 43 | } |
| 44 | |
| 45 | void setScale(float scale) { |
| 46 | fScaleFactor = scale; |
| 47 | } |
| 48 | |
| 49 | protected: |
| 50 | void initializeGL(); |
| 51 | void resizeGL(int w, int h); |
| 52 | void paintGL(); |
| 53 | |
| 54 | |
| 55 | private: |
| 56 | const GrGLInterface* fCurIntf; |
| 57 | GrContext* fCurContext; |
| 58 | SkGpuDevice* fGpuDevice; |
| 59 | SkCanvas* fCanvas; |
| 60 | SkDebugCanvas* fDebugCanvas; |
| 61 | int fIndex; |
| 62 | SkIPoint fTransform; |
| 63 | float fScaleFactor; |
| chudy@google.com | ea5488b | 2012-07-26 19:38:22 +0000 | [diff] [blame] | 64 | GrPlatformRenderTargetDesc getDesc(int w, int h); |
| 65 | }; |
| 66 | |
| 67 | #endif /* SKGLWIDGET_H_ */ |