SkGLWidget.h revision a9e937c7b712b024de108fa963f92d0e70e4a296
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
23class SkGLWidget : public QGLWidget {
24Q_OBJECT
25
26public:
27    SkGLWidget();
28
29    ~SkGLWidget();
30
31    void setDebugCanvas(SkDebugCanvas* debugCanvas) {
32        fDebugCanvas = debugCanvas;
33        fIndex = debugCanvas->getSize() - 1;
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
50signals:
51    void drawComplete();
52
53protected:
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;
68    GrPlatformRenderTargetDesc getDesc(int w, int h);
69};
70
71#endif /* SKGLWIDGET_H_ */
72