blob: 870b2834b1c037cb4841ede1d79a51629f6584b5 [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
robertphillips@google.come8fe4bc2013-02-13 13:26:13 +000013#if SK_SUPPORT_GPU
14
chudy@google.comea5488b2012-07-26 19:38:22 +000015#include <QtOpenGL/QGLWidget>
16#include "SkDebugCanvas.h"
chudy@google.com607357f2012-08-07 16:12:23 +000017#include "SkDebugger.h"
chudy@google.comea5488b2012-07-26 19:38:22 +000018#include "SkGpuDevice.h"
chudy@google.comea5488b2012-07-26 19:38:22 +000019#include "GrContext.h"
20#include "gl/GrGLInterface.h"
21#include "gl/GrGLUtil.h"
22#include "GrRenderTarget.h"
23
24class SkGLWidget : public QGLWidget {
chudy@google.coma9e937c2012-08-03 17:32:05 +000025Q_OBJECT
chudy@google.comea5488b2012-07-26 19:38:22 +000026
27public:
chudy@google.com607357f2012-08-07 16:12:23 +000028 SkGLWidget(SkDebugger* debugger);
chudy@google.comea5488b2012-07-26 19:38:22 +000029
30 ~SkGLWidget();
31
kkinnunencfdc0e32015-01-13 22:49:02 -080032 void updateImage() {
chudy@google.comea5488b2012-07-26 19:38:22 +000033 this->updateGL();
34 }
commit-bot@chromium.orgfde1e7c2013-08-02 13:59:50 +000035 void setSampleCount(int sampleCount);
chudy@google.comea5488b2012-07-26 19:38:22 +000036
robertphillips9ea8acd2016-03-01 09:34:38 -080037Q_SIGNALS:
chudy@google.coma9e937c2012-08-03 17:32:05 +000038 void drawComplete();
39
chudy@google.comea5488b2012-07-26 19:38:22 +000040protected:
41 void initializeGL();
42 void resizeGL(int w, int h);
43 void paintGL();
44
45
46private:
kkinnunen4be02382014-12-22 06:06:41 -080047 void createRenderTarget();
Hal Canary2db83612016-11-04 13:02:54 -040048 sk_sp<const GrGLInterface> fCurIntf;
49 sk_sp<GrContext> fCurContext;
robertphillips12e96622016-08-01 05:53:23 -070050
51 sk_sp<SkSurface> fGpuSurface;
52 SkCanvas* fCanvas;
53
chudy@google.com607357f2012-08-07 16:12:23 +000054 SkDebugger* fDebugger;
bsalomon@google.com16e3dde2012-10-25 18:43:28 +000055 GrBackendRenderTargetDesc getDesc(int w, int h);
chudy@google.comea5488b2012-07-26 19:38:22 +000056};
57
robertphillips@google.come8fe4bc2013-02-13 13:26:13 +000058#endif /* SK_SUPPORT_GPU */
59
chudy@google.comea5488b2012-07-26 19:38:22 +000060#endif /* SKGLWIDGET_H_ */