Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(900)

Side by Side Diff: debugger/QT/SkGLWidget.cpp

Issue 915573002: debugger: Abandon context when Qt changes it without notice (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 14 matching lines...) Expand all
25 setFormat(currentFormat); 25 setFormat(currentFormat);
26 } 26 }
27 27
28 void SkGLWidget::initializeGL() { 28 void SkGLWidget::initializeGL() {
29 if (!fCurIntf) { 29 if (!fCurIntf) {
30 fCurIntf.reset(GrGLCreateNativeInterface()); 30 fCurIntf.reset(GrGLCreateNativeInterface());
31 } 31 }
32 if (!fCurIntf) { 32 if (!fCurIntf) {
33 return; 33 return;
34 } 34 }
35 if (!fCurContext) {
36 fCurContext.reset(GrContext::Create(kOpenGL_GrBackend, (GrBackendContext ) fCurIntf.get()));
37 }
38 if (!fCurContext) {
39 return;
40 }
41
42 // 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
43 // 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
44 // proper resource cleanup could be made. Instead, we assume that the underl ying GL context 37 // proper resource cleanup could be made.
45 // never actually changes. If it would, we could not destroy the resources. 38 if (fCurContext) {
39 fCurContext->abandonContext();
40 }
46 fGpuDevice.reset(NULL); 41 fGpuDevice.reset(NULL);
47 fCanvas.reset(NULL); 42 fCanvas.reset(NULL);
43
44 fCurContext.reset(GrContext::Create(kOpenGL_GrBackend, (GrBackendContext) fC urIntf.get()));
48 } 45 }
49 46
50 void SkGLWidget::createRenderTarget() { 47 void SkGLWidget::createRenderTarget() {
51 if (!fCurContext) { 48 if (!fCurContext) {
52 return; 49 return;
53 } 50 }
54 51
55 glDisable(GL_SCISSOR_TEST); 52 glDisable(GL_SCISSOR_TEST);
56 glStencilMask(0xffffffff); 53 glStencilMask(0xffffffff);
57 glClearStencil(0); 54 glClearStencil(0);
(...skipping 11 matching lines...) Expand all
69 fCanvas.reset(new SkCanvas(fGpuDevice)); 66 fCanvas.reset(new SkCanvas(fGpuDevice));
70 } 67 }
71 68
72 void SkGLWidget::resizeGL(int w, int h) { 69 void SkGLWidget::resizeGL(int w, int h) {
73 SkASSERT(w == this->width() && h == this->height()); 70 SkASSERT(w == this->width() && h == this->height());
74 this->createRenderTarget(); 71 this->createRenderTarget();
75 } 72 }
76 73
77 void SkGLWidget::paintGL() { 74 void SkGLWidget::paintGL() {
78 if (!this->isHidden() && fCanvas) { 75 if (!this->isHidden() && fCanvas) {
76 fCurContext->resetContext();
79 fDebugger->draw(fCanvas.get()); 77 fDebugger->draw(fCanvas.get());
80 // TODO(chudy): Implement an optional flush button in Gui. 78 // TODO(chudy): Implement an optional flush button in Gui.
81 fCanvas->flush(); 79 fCanvas->flush();
82 emit drawComplete(); 80 emit drawComplete();
83 } 81 }
84 } 82 }
85 83
86 GrBackendRenderTargetDesc SkGLWidget::getDesc(int w, int h) { 84 GrBackendRenderTargetDesc SkGLWidget::getDesc(int w, int h) {
87 GrBackendRenderTargetDesc desc; 85 GrBackendRenderTargetDesc desc;
88 desc.fWidth = SkScalarRoundToInt(this->width()); 86 desc.fWidth = SkScalarRoundToInt(this->width());
89 desc.fHeight = SkScalarRoundToInt(this->height()); 87 desc.fHeight = SkScalarRoundToInt(this->height());
90 desc.fConfig = kSkia8888_GrPixelConfig; 88 desc.fConfig = kSkia8888_GrPixelConfig;
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698