diff options
| author | Scroggo <Scroggo@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-06-16 15:31:26 +0000 |
|---|---|---|
| committer | Scroggo <Scroggo@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-06-16 15:31:26 +0000 |
| commit | 3e7ff9f31daedefd5431e724b94cebbd15d9ac21 (patch) | |
| tree | 1283a6310fcbaaf40662a56237f3ec35cf0018f7 /samplecode/SampleApp.cpp | |
| parent | 6c4cd265e368531f6c73f4bbb0cf073d3899e10c (diff) | |
Better fix for changing the viewport in sample app.
Create a platform description and base the size on the SkWindow
in order to create a RenderTarget, which results in changing the
viewport. This allows us to use only GR calls.
In the Android sample app, fix the problem where nothing is drawn
in the first frame, and default to drawing in GL.
Reviewed at http://codereview.appspot.com/4642043/
git-svn-id: http://skia.googlecode.com/svn/trunk@1615 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'samplecode/SampleApp.cpp')
| -rw-r--r-- | samplecode/SampleApp.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp index 8d5e13d97f..455559c745 100644 --- a/samplecode/SampleApp.cpp +++ b/samplecode/SampleApp.cpp @@ -15,9 +15,7 @@ #include "GrContext.h" #include "SkTypeface.h" -#ifdef ANDROID - #include "gl2.h" -#endif +#include "GrGLInterface.h" #define TEST_GPIPEx @@ -684,7 +682,20 @@ SkCanvas* SampleWindow::beforeChildren(SkCanvas* canvas) { const SkBitmap& bitmap = device->accessBitmap(true); GrRenderTarget* renderTarget; - renderTarget = fGrContext->createRenderTargetFrom3DApiState(); + + GrPlatformSurfaceDesc desc; + desc.reset(); + desc.fSurfaceType = kRenderTarget_GrPlatformSurfaceType; + desc.fWidth = bitmap.width(); + desc.fHeight = bitmap.height(); + desc.fConfig = kRGBA_8888_GrPixelConfig; + desc.fStencilBits = 8; + GrGLint buffer; + GR_GL_GetIntegerv(GR_GL_FRAMEBUFFER_BINDING, &buffer); + desc.fPlatformRenderTarget = buffer; + + renderTarget = static_cast<GrRenderTarget*>( + fGrContext->createPlatformSurface(desc)); fGpuCanvas = new SkGpuCanvas(fGrContext, renderTarget); renderTarget->unref(); @@ -1323,12 +1334,8 @@ void SampleWindow::onSizeChange() { fZoomCenterX = SkScalarHalf(this->width()); fZoomCenterY = SkScalarHalf(this->height()); -#if defined(SK_BUILD_FOR_UNIX) || defined(ANDROID) - if (fGrContext) { - glViewport(0, 0, SkScalarRound(this->width()), - SkScalarRound(this->height())); - fGrContext->resetContext(); - } +#ifdef ANDROID + postInvalDelay(this->getSinkID()); #endif this->updateTitle(); // to refresh our config } |
