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 #if SK_SUPPORT_GPU 14 15 #include <QtOpenGL/QGLWidget> 16 #include "SkDebugCanvas.h" 17 #include "SkDebugger.h" 18 #include "SkGpuDevice.h" 19 #include "GrContext.h" 20 #include "gl/GrGLInterface.h" 21 #include "gl/GrGLUtil.h" 22 #include "GrRenderTarget.h" 23 24 class SkGLWidget : public QGLWidget { 25 Q_OBJECT 26 27 public: 28 SkGLWidget(SkDebugger* debugger); 29 30 ~SkGLWidget(); 31 updateImage()32 void updateImage() { 33 this->updateGL(); 34 } 35 void setSampleCount(int sampleCount); 36 37 Q_SIGNALS: 38 void drawComplete(); 39 40 protected: 41 void initializeGL(); 42 void resizeGL(int w, int h); 43 void paintGL(); 44 45 46 private: 47 void createRenderTarget(); 48 sk_sp<const GrGLInterface> fCurIntf; 49 sk_sp<GrContext> fCurContext; 50 51 sk_sp<SkSurface> fGpuSurface; 52 SkCanvas* fCanvas; 53 54 SkDebugger* fDebugger; 55 GrBackendRenderTargetDesc getDesc(int w, int h); 56 }; 57 58 #endif /* SK_SUPPORT_GPU */ 59 60 #endif /* SKGLWIDGET_H_ */ 61