blob: 5eeb1cbcad9a1b921793058c2359e37728d7912f [file] [log] [blame]
chudy@google.comea5488b2012-07-26 19:38:22 +00001
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
23class SkGLWidget : public QGLWidget {
chudy@google.coma9e937c2012-08-03 17:32:05 +000024Q_OBJECT
chudy@google.comea5488b2012-07-26 19:38:22 +000025
26public:
chudy@google.com2d537a12012-07-31 12:49:52 +000027 SkGLWidget();
chudy@google.comea5488b2012-07-26 19:38:22 +000028
29 ~SkGLWidget();
30
31 void setDebugCanvas(SkDebugCanvas* debugCanvas) {
32 fDebugCanvas = debugCanvas;
chudy@google.com0b5bbb02012-07-31 19:55:32 +000033 fIndex = debugCanvas->getSize() - 1;
chudy@google.comea5488b2012-07-26 19:38:22 +000034 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.coma9e937c2012-08-03 17:32:05 +000050signals:
51 void drawComplete();
52
chudy@google.comea5488b2012-07-26 19:38:22 +000053protected:
54 void initializeGL();
55 void resizeGL(int w, int h);
56 void paintGL();
57
58
59private:
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.comea5488b2012-07-26 19:38:22 +000068 GrPlatformRenderTargetDesc getDesc(int w, int h);
69};
70
71#endif /* SKGLWIDGET_H_ */