blob: 76257be3c908ea231f2edb70d63bd75b4befe86a [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 {
24
25public:
chudy@google.com2d537a12012-07-31 12:49:52 +000026 SkGLWidget();
chudy@google.comea5488b2012-07-26 19:38:22 +000027
28 ~SkGLWidget();
29
30 void setDebugCanvas(SkDebugCanvas* debugCanvas) {
31 fDebugCanvas = debugCanvas;
chudy@google.com0b5bbb02012-07-31 19:55:32 +000032 fIndex = debugCanvas->getSize() - 1;
chudy@google.comea5488b2012-07-26 19:38:22 +000033 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
49protected:
50 void initializeGL();
51 void resizeGL(int w, int h);
52 void paintGL();
53
54
55private:
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.comea5488b2012-07-26 19:38:22 +000064 GrPlatformRenderTargetDesc getDesc(int w, int h);
65};
66
67#endif /* SKGLWIDGET_H_ */