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" |
(...skipping 20 matching lines...) Expand all Loading... |
31 } | 31 } |
32 if (!fCurIntf) { | 32 if (!fCurIntf) { |
33 return; | 33 return; |
34 } | 34 } |
35 // The call may come multiple times, for example after setSampleCount(). Th
e QGLContext will be | 35 // The call may come multiple times, for example after setSampleCount(). Th
e QGLContext will be |
36 // different, but we do not have a mechanism to catch the destroying of QGLC
ontext, so that | 36 // different, but we do not have a mechanism to catch the destroying of QGLC
ontext, so that |
37 // proper resource cleanup could be made. | 37 // proper resource cleanup could be made. |
38 if (fCurContext) { | 38 if (fCurContext) { |
39 fCurContext->abandonContext(); | 39 fCurContext->abandonContext(); |
40 } | 40 } |
41 fGpuDevice.reset(NULL); | 41 fGpuDevice.reset(nullptr); |
42 fCanvas.reset(NULL); | 42 fCanvas.reset(nullptr); |
43 | 43 |
44 fCurContext.reset(GrContext::Create(kOpenGL_GrBackend, (GrBackendContext) fC
urIntf.get())); | 44 fCurContext.reset(GrContext::Create(kOpenGL_GrBackend, (GrBackendContext) fC
urIntf.get())); |
45 } | 45 } |
46 | 46 |
47 void SkGLWidget::createRenderTarget() { | 47 void SkGLWidget::createRenderTarget() { |
48 if (!fCurContext) { | 48 if (!fCurContext) { |
49 return; | 49 return; |
50 } | 50 } |
51 | 51 |
52 glDisable(GL_SCISSOR_TEST); | 52 glDisable(GL_SCISSOR_TEST); |
53 glStencilMask(0xffffffff); | 53 glStencilMask(0xffffffff); |
54 glClearStencil(0); | 54 glClearStencil(0); |
55 glClear(GL_STENCIL_BUFFER_BIT); | 55 glClear(GL_STENCIL_BUFFER_BIT); |
56 fCurContext->resetContext(); | 56 fCurContext->resetContext(); |
57 | 57 |
58 fGpuDevice.reset(NULL); | 58 fGpuDevice.reset(nullptr); |
59 fCanvas.reset(NULL); | 59 fCanvas.reset(nullptr); |
60 | 60 |
61 GrBackendRenderTargetDesc desc = this->getDesc(this->width(), this->height()
); | 61 GrBackendRenderTargetDesc desc = this->getDesc(this->width(), this->height()
); |
62 desc.fOrigin = kBottomLeft_GrSurfaceOrigin; | 62 desc.fOrigin = kBottomLeft_GrSurfaceOrigin; |
63 SkAutoTUnref<GrRenderTarget> curRenderTarget( | 63 SkAutoTUnref<GrRenderTarget> curRenderTarget( |
64 fCurContext->textureProvider()->wrapBackendRenderTarget(desc)); | 64 fCurContext->textureProvider()->wrapBackendRenderTarget(desc)); |
65 SkSurfaceProps props(0, kUnknown_SkPixelGeometry); | 65 SkSurfaceProps props(0, kUnknown_SkPixelGeometry); |
66 fGpuDevice.reset(SkGpuDevice::Create(curRenderTarget, &props, | 66 fGpuDevice.reset(SkGpuDevice::Create(curRenderTarget, &props, |
67 SkGpuDevice::kUninit_InitContents)); | 67 SkGpuDevice::kUninit_InitContents)); |
68 fCanvas.reset(new SkCanvas(fGpuDevice)); | 68 fCanvas.reset(new SkCanvas(fGpuDevice)); |
69 } | 69 } |
(...skipping 21 matching lines...) Expand all Loading... |
91 GR_GL_GetIntegerv(fCurIntf, GR_GL_SAMPLES, &desc.fSampleCnt); | 91 GR_GL_GetIntegerv(fCurIntf, GR_GL_SAMPLES, &desc.fSampleCnt); |
92 GR_GL_GetIntegerv(fCurIntf, GR_GL_STENCIL_BITS, &desc.fStencilBits); | 92 GR_GL_GetIntegerv(fCurIntf, GR_GL_STENCIL_BITS, &desc.fStencilBits); |
93 GrGLint buffer; | 93 GrGLint buffer; |
94 GR_GL_GetIntegerv(fCurIntf, GR_GL_FRAMEBUFFER_BINDING, &buffer); | 94 GR_GL_GetIntegerv(fCurIntf, GR_GL_FRAMEBUFFER_BINDING, &buffer); |
95 desc.fRenderTargetHandle = buffer; | 95 desc.fRenderTargetHandle = buffer; |
96 | 96 |
97 return desc; | 97 return desc; |
98 } | 98 } |
99 | 99 |
100 #endif | 100 #endif |
OLD | NEW |