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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 fCurContext->resetContext(); | 61 fCurContext->resetContext(); |
62 | 62 |
63 GrBackendRenderTargetDesc desc = this->getDesc(w, h); | 63 GrBackendRenderTargetDesc desc = this->getDesc(w, h); |
64 desc.fOrigin = kBottomLeft_GrSurfaceOrigin; | 64 desc.fOrigin = kBottomLeft_GrSurfaceOrigin; |
65 GrRenderTarget* curRenderTarget = fCurContext->wrapBackendRenderTarget(d
esc); | 65 GrRenderTarget* curRenderTarget = fCurContext->wrapBackendRenderTarget(d
esc); |
66 SkSafeUnref(fGpuDevice); | 66 SkSafeUnref(fGpuDevice); |
67 SkSafeUnref(fCanvas); | 67 SkSafeUnref(fCanvas); |
68 fGpuDevice = SkGpuDevice::Create(curRenderTarget); | 68 fGpuDevice = SkGpuDevice::Create(curRenderTarget); |
69 fCanvas = new SkCanvas(fGpuDevice); | 69 fCanvas = new SkCanvas(fGpuDevice); |
70 } | 70 } |
71 fDebugger->resize(w, h); | 71 fDebugger->setWindowSize(w, h); |
72 draw(); | 72 draw(); |
73 } | 73 } |
74 | 74 |
75 void SkGLWidget::paintGL() { | 75 void SkGLWidget::paintGL() { |
76 if (!this->isHidden() && fCanvas) { | 76 if (!this->isHidden() && fCanvas) { |
77 fDebugger->draw(fCanvas); | 77 fDebugger->draw(fCanvas); |
78 // TODO(chudy): Implement an optional flush button in Gui. | 78 // TODO(chudy): Implement an optional flush button in Gui. |
79 fCanvas->flush(); | 79 fCanvas->flush(); |
80 emit drawComplete(); | 80 emit drawComplete(); |
81 } | 81 } |
82 } | 82 } |
83 | 83 |
84 GrBackendRenderTargetDesc SkGLWidget::getDesc(int w, int h) { | 84 GrBackendRenderTargetDesc SkGLWidget::getDesc(int w, int h) { |
85 GrBackendRenderTargetDesc desc; | 85 GrBackendRenderTargetDesc desc; |
86 desc.fWidth = SkScalarRoundToInt(this->width()); | 86 desc.fWidth = SkScalarRoundToInt(this->width()); |
87 desc.fHeight = SkScalarRoundToInt(this->height()); | 87 desc.fHeight = SkScalarRoundToInt(this->height()); |
88 desc.fConfig = kSkia8888_GrPixelConfig; | 88 desc.fConfig = kSkia8888_GrPixelConfig; |
89 GR_GL_GetIntegerv(fCurIntf, GR_GL_SAMPLES, &desc.fSampleCnt); | 89 GR_GL_GetIntegerv(fCurIntf, GR_GL_SAMPLES, &desc.fSampleCnt); |
90 GR_GL_GetIntegerv(fCurIntf, GR_GL_STENCIL_BITS, &desc.fStencilBits); | 90 GR_GL_GetIntegerv(fCurIntf, GR_GL_STENCIL_BITS, &desc.fStencilBits); |
91 GrGLint buffer; | 91 GrGLint buffer; |
92 GR_GL_GetIntegerv(fCurIntf, GR_GL_FRAMEBUFFER_BINDING, &buffer); | 92 GR_GL_GetIntegerv(fCurIntf, GR_GL_FRAMEBUFFER_BINDING, &buffer); |
93 desc.fRenderTargetHandle = buffer; | 93 desc.fRenderTargetHandle = buffer; |
94 | 94 |
95 return desc; | 95 return desc; |
96 } | 96 } |
97 | 97 |
98 #endif | 98 #endif |
OLD | NEW |