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 29 matching lines...) Expand all Loading... |
40 return; | 40 return; |
41 } | 41 } |
42 glStencilMask(0xffffffff); | 42 glStencilMask(0xffffffff); |
43 glClearStencil(0); | 43 glClearStencil(0); |
44 glClear(GL_STENCIL_BUFFER_BIT); | 44 glClear(GL_STENCIL_BUFFER_BIT); |
45 | 45 |
46 fCurContext = GrContext::Create(kOpenGL_GrBackend, (GrBackendContext) fCurIn
tf); | 46 fCurContext = GrContext::Create(kOpenGL_GrBackend, (GrBackendContext) fCurIn
tf); |
47 GrBackendRenderTargetDesc desc = this->getDesc(this->width(), this->height()
); | 47 GrBackendRenderTargetDesc desc = this->getDesc(this->width(), this->height()
); |
48 desc.fOrigin = kBottomLeft_GrSurfaceOrigin; | 48 desc.fOrigin = kBottomLeft_GrSurfaceOrigin; |
49 GrRenderTarget* curRenderTarget = fCurContext->wrapBackendRenderTarget(desc)
; | 49 GrRenderTarget* curRenderTarget = fCurContext->wrapBackendRenderTarget(desc)
; |
50 fGpuDevice = SkGpuDevice::Create(curRenderTarget, | 50 fGpuDevice = SkGpuDevice::Create(curRenderTarget); |
51 SkSurfaceProps(SkSurfaceProps::kLegacyFontH
ost_InitType)); | |
52 fCanvas = new SkCanvas(fGpuDevice); | 51 fCanvas = new SkCanvas(fGpuDevice); |
53 curRenderTarget->unref(); | 52 curRenderTarget->unref(); |
54 } | 53 } |
55 | 54 |
56 void SkGLWidget::resizeGL(int w, int h) { | 55 void SkGLWidget::resizeGL(int w, int h) { |
57 if (fCurContext) { | 56 if (fCurContext) { |
58 glDisable(GL_SCISSOR_TEST); | 57 glDisable(GL_SCISSOR_TEST); |
59 glStencilMask(0xffffffff); | 58 glStencilMask(0xffffffff); |
60 glClearStencil(0); | 59 glClearStencil(0); |
61 glClear(GL_STENCIL_BUFFER_BIT); | 60 glClear(GL_STENCIL_BUFFER_BIT); |
62 fCurContext->resetContext(); | 61 fCurContext->resetContext(); |
63 | 62 |
64 GrBackendRenderTargetDesc desc = this->getDesc(w, h); | 63 GrBackendRenderTargetDesc desc = this->getDesc(w, h); |
65 desc.fOrigin = kBottomLeft_GrSurfaceOrigin; | 64 desc.fOrigin = kBottomLeft_GrSurfaceOrigin; |
66 GrRenderTarget* curRenderTarget = fCurContext->wrapBackendRenderTarget(d
esc); | 65 GrRenderTarget* curRenderTarget = fCurContext->wrapBackendRenderTarget(d
esc); |
67 SkSafeUnref(fGpuDevice); | 66 SkSafeUnref(fGpuDevice); |
68 SkSafeUnref(fCanvas); | 67 SkSafeUnref(fCanvas); |
69 fGpuDevice = SkGpuDevice::Create(curRenderTarget, | 68 fGpuDevice = SkGpuDevice::Create(curRenderTarget); |
70 SkSurfaceProps(SkSurfaceProps::kLegacyF
ontHost_InitType)); | |
71 fCanvas = new SkCanvas(fGpuDevice); | 69 fCanvas = new SkCanvas(fGpuDevice); |
72 } | 70 } |
73 fDebugger->setWindowSize(w, h); | 71 fDebugger->setWindowSize(w, h); |
74 draw(); | 72 draw(); |
75 } | 73 } |
76 | 74 |
77 void SkGLWidget::paintGL() { | 75 void SkGLWidget::paintGL() { |
78 if (!this->isHidden() && fCanvas) { | 76 if (!this->isHidden() && fCanvas) { |
79 fDebugger->draw(fCanvas); | 77 fDebugger->draw(fCanvas); |
80 // TODO(chudy): Implement an optional flush button in Gui. | 78 // TODO(chudy): Implement an optional flush button in Gui. |
(...skipping 10 matching lines...) Expand all Loading... |
91 GR_GL_GetIntegerv(fCurIntf, GR_GL_SAMPLES, &desc.fSampleCnt); | 89 GR_GL_GetIntegerv(fCurIntf, GR_GL_SAMPLES, &desc.fSampleCnt); |
92 GR_GL_GetIntegerv(fCurIntf, GR_GL_STENCIL_BITS, &desc.fStencilBits); | 90 GR_GL_GetIntegerv(fCurIntf, GR_GL_STENCIL_BITS, &desc.fStencilBits); |
93 GrGLint buffer; | 91 GrGLint buffer; |
94 GR_GL_GetIntegerv(fCurIntf, GR_GL_FRAMEBUFFER_BINDING, &buffer); | 92 GR_GL_GetIntegerv(fCurIntf, GR_GL_FRAMEBUFFER_BINDING, &buffer); |
95 desc.fRenderTargetHandle = buffer; | 93 desc.fRenderTargetHandle = buffer; |
96 | 94 |
97 return desc; | 95 return desc; |
98 } | 96 } |
99 | 97 |
100 #endif | 98 #endif |
OLD | NEW |