OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkGLWidget.h" | 10 #include "SkGLWidget.h" |
11 | 11 |
12 #if SK_SUPPORT_GPU | 12 #if SK_SUPPORT_GPU |
13 | 13 |
14 SkGLWidget::SkGLWidget(SkDebugger* debugger) : QGLWidget() { | 14 SkGLWidget::SkGLWidget(SkDebugger* debugger) : QGLWidget() { |
15 this->setStyleSheet("QWidget {background-color: white; border: 1px solid #cc
cccc;}"); | 15 this->setStyleSheet("QWidget {background-color: white; border: 1px solid #cc
cccc;}"); |
16 fDebugger = debugger; | 16 fDebugger = debugger; |
17 fCurIntf = NULL; | 17 fCurIntf = NULL; |
18 fCurContext = NULL; | 18 fCurContext = NULL; |
19 fGpuDevice = NULL; | 19 fGpuDevice = NULL; |
20 fCanvas = NULL; | 20 fCanvas = NULL; |
21 } | 21 } |
22 | 22 |
23 SkGLWidget::~SkGLWidget() { | 23 SkGLWidget::~SkGLWidget() { |
24 SkSafeUnref(fCurIntf); | 24 SkSafeUnref(fCurIntf); |
25 SkSafeUnref(fCurContext); | 25 SkSafeUnref(fCurContext); |
26 SkSafeUnref(fGpuDevice); | 26 SkSafeUnref(fGpuDevice); |
27 SkSafeUnref(fCanvas); | 27 SkSafeUnref(fCanvas); |
28 } | 28 } |
29 | 29 |
| 30 void SkGLWidget::setSampleCount(int sampleCount) |
| 31 { |
| 32 QGLFormat currentFormat = format(); |
| 33 currentFormat.setSampleBuffers(sampleCount > 0); |
| 34 currentFormat.setSamples(sampleCount); |
| 35 setFormat(currentFormat); |
| 36 } |
| 37 |
30 void SkGLWidget::initializeGL() { | 38 void SkGLWidget::initializeGL() { |
31 fCurIntf = GrGLCreateNativeInterface(); | 39 fCurIntf = GrGLCreateNativeInterface(); |
32 if (!fCurIntf) { | 40 if (!fCurIntf) { |
33 return; | 41 return; |
34 } | 42 } |
35 fCurContext = GrContext::Create(kOpenGL_GrBackend, (GrBackendContext) fCurIn
tf); | 43 fCurContext = GrContext::Create(kOpenGL_GrBackend, (GrBackendContext) fCurIn
tf); |
36 GrBackendRenderTargetDesc desc = this->getDesc(this->width(), this->height()
); | 44 GrBackendRenderTargetDesc desc = this->getDesc(this->width(), this->height()
); |
37 desc.fOrigin = kBottomLeft_GrSurfaceOrigin; | 45 desc.fOrigin = kBottomLeft_GrSurfaceOrigin; |
38 GrRenderTarget* curRenderTarget = fCurContext->wrapBackendRenderTarget(desc)
; | 46 GrRenderTarget* curRenderTarget = fCurContext->wrapBackendRenderTarget(desc)
; |
39 fGpuDevice = new SkGpuDevice(fCurContext, curRenderTarget); | 47 fGpuDevice = new SkGpuDevice(fCurContext, curRenderTarget); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 GR_GL_GetIntegerv(fCurIntf, GR_GL_SAMPLES, &desc.fSampleCnt); | 84 GR_GL_GetIntegerv(fCurIntf, GR_GL_SAMPLES, &desc.fSampleCnt); |
77 GR_GL_GetIntegerv(fCurIntf, GR_GL_STENCIL_BITS, &desc.fStencilBits); | 85 GR_GL_GetIntegerv(fCurIntf, GR_GL_STENCIL_BITS, &desc.fStencilBits); |
78 GrGLint buffer; | 86 GrGLint buffer; |
79 GR_GL_GetIntegerv(fCurIntf, GR_GL_FRAMEBUFFER_BINDING, &buffer); | 87 GR_GL_GetIntegerv(fCurIntf, GR_GL_FRAMEBUFFER_BINDING, &buffer); |
80 desc.fRenderTargetHandle = buffer; | 88 desc.fRenderTargetHandle = buffer; |
81 | 89 |
82 return desc; | 90 return desc; |
83 } | 91 } |
84 | 92 |
85 #endif | 93 #endif |
OLD | NEW |