Index: debugger/QT/SkGLWidget.cpp |
=================================================================== |
--- debugger/QT/SkGLWidget.cpp (revision 9826) |
+++ debugger/QT/SkGLWidget.cpp (working copy) |
@@ -29,6 +29,9 @@ |
void SkGLWidget::initializeGL() { |
fCurIntf = GrGLCreateNativeInterface(); |
+ if (!fCurIntf) { |
+ return; |
+ } |
fCurContext = GrContext::Create(kOpenGL_GrBackend, (GrBackendContext) fCurIntf); |
GrBackendRenderTargetDesc desc = this->getDesc(this->width(), this->height()); |
desc.fOrigin = kBottomLeft_GrSurfaceOrigin; |
@@ -43,19 +46,21 @@ |
} |
void SkGLWidget::resizeGL(int w, int h) { |
- GrBackendRenderTargetDesc desc = this->getDesc(w, h); |
- desc.fOrigin = kBottomLeft_GrSurfaceOrigin; |
- GrRenderTarget* curRenderTarget = fCurContext->wrapBackendRenderTarget(desc); |
- SkSafeUnref(fGpuDevice); |
- SkSafeUnref(fCanvas); |
- fGpuDevice = new SkGpuDevice(fCurContext, curRenderTarget); |
- fCanvas = new SkCanvas(fGpuDevice); |
+ if (fCurContext) { |
+ GrBackendRenderTargetDesc desc = this->getDesc(w, h); |
+ desc.fOrigin = kBottomLeft_GrSurfaceOrigin; |
+ GrRenderTarget* curRenderTarget = fCurContext->wrapBackendRenderTarget(desc); |
+ SkSafeUnref(fGpuDevice); |
+ SkSafeUnref(fCanvas); |
+ fGpuDevice = new SkGpuDevice(fCurContext, curRenderTarget); |
+ fCanvas = new SkCanvas(fGpuDevice); |
+ } |
fDebugger->resize(w, h); |
draw(); |
} |
void SkGLWidget::paintGL() { |
- if (!this->isHidden()) { |
+ if (!this->isHidden() && fCanvas) { |
fDebugger->draw(fCanvas); |
// TODO(chudy): Implement an optional flush button in Gui. |
fCanvas->flush(); |