diff options
author | 2012-08-01 15:57:52 +0000 | |
---|---|---|
committer | 2012-08-01 15:57:52 +0000 | |
commit | 830b8793bb1646bb76817bdc228dd8e2a92bef7d (patch) | |
tree | 153b6cefd991809e6654a70b27814cd16a70950f /debugger/QT/SkGLWidget.cpp | |
parent | 6385314686875ecb484d95b33fcbf08890b5144d (diff) |
Optimization: SkDebugCanvas is capable of pausing and drawing incrementally instead of redrawing all commands.
Review URL: https://codereview.appspot.com/6458056
git-svn-id: http://skia.googlecode.com/svn/trunk@4891 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'debugger/QT/SkGLWidget.cpp')
-rw-r--r-- | debugger/QT/SkGLWidget.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/debugger/QT/SkGLWidget.cpp b/debugger/QT/SkGLWidget.cpp index e3c4161cb4..ff903ad1e1 100644 --- a/debugger/QT/SkGLWidget.cpp +++ b/debugger/QT/SkGLWidget.cpp @@ -18,12 +18,14 @@ SkGLWidget::SkGLWidget() : QGLWidget() { fCurIntf = NULL; fCurContext = NULL; fGpuDevice = NULL; + fCanvas = NULL; } SkGLWidget::~SkGLWidget() { SkSafeUnref(fCurIntf); SkSafeUnref(fCurContext); SkSafeUnref(fGpuDevice); + SkSafeUnref(fCanvas); } void SkGLWidget::initializeGL() { @@ -31,6 +33,7 @@ void SkGLWidget::initializeGL() { fCurContext = GrContext::Create(kOpenGL_Shaders_GrEngine, (GrPlatform3DContext) fCurIntf); GrRenderTarget* curRenderTarget = fCurContext->createPlatformRenderTarget(getDesc(this->width(), this->height())); fGpuDevice = new SkGpuDevice(fCurContext, curRenderTarget); + fCanvas = new SkCanvas(fGpuDevice); curRenderTarget->unref(); glClearColor(1, 1, 1, 0); @@ -41,21 +44,17 @@ void SkGLWidget::initializeGL() { void SkGLWidget::resizeGL(int w, int h) { GrRenderTarget* curRenderTarget = fCurContext->createPlatformRenderTarget(getDesc(w,h)); SkSafeUnref(fGpuDevice); + SkSafeUnref(fCanvas); fGpuDevice = new SkGpuDevice(fCurContext, curRenderTarget); + fCanvas = new SkCanvas(fGpuDevice); drawTo(fIndex); } void SkGLWidget::paintGL() { glClearColor(1, 1, 1, 0); - SkCanvas canvas(fGpuDevice); - canvas.translate(fTransform.fX, fTransform.fY); - if(fScaleFactor < 0) { - canvas.scale((1.0 / -fScaleFactor),(1.0 / -fScaleFactor)); - } else if (fScaleFactor > 0) { - canvas.scale(fScaleFactor, fScaleFactor); - } - fDebugCanvas->drawTo(&canvas, fIndex); - canvas.flush(); + fDebugCanvas->drawTo(fCanvas, fIndex); + // TODO(chudy): Implement an optional flush button in Gui. + fCanvas->flush(); } GrPlatformRenderTargetDesc SkGLWidget::getDesc(int w, int h) { |