diff options
Diffstat (limited to 'src/gpu/gl/GrGpuGL_program.cpp')
-rw-r--r-- | src/gpu/gl/GrGpuGL_program.cpp | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/src/gpu/gl/GrGpuGL_program.cpp b/src/gpu/gl/GrGpuGL_program.cpp index d5e8fbdd79..28f76de2ac 100644 --- a/src/gpu/gl/GrGpuGL_program.cpp +++ b/src/gpu/gl/GrGpuGL_program.cpp @@ -92,13 +92,19 @@ void GrGpuGL::flushViewMatrix(DrawType type) { const SkMatrix& vm = this->getDrawState().getViewMatrix(); if (kStencilPath_DrawType == type) { - if (fHWPathMatrixState.fViewMatrix != vm || + if (fHWPathMatrixState.fLastOrigin != rt->origin() || + fHWPathMatrixState.fViewMatrix != vm || fHWPathMatrixState.fRTSize != viewportSize) { // rescale the coords from skia's "device" coords to GL's normalized coords, - // and perform a y-flip. + // and perform a y-flip if required. SkMatrix m; - m.setScale(SkIntToScalar(2) / rt->width(), SkIntToScalar(-2) / rt->height()); - m.postTranslate(-SK_Scalar1, SK_Scalar1); + if (kBottomLeft_GrSurfaceOrigin == rt->origin()) { + m.setScale(SkIntToScalar(2) / rt->width(), SkIntToScalar(-2) / rt->height()); + m.postTranslate(-SK_Scalar1, SK_Scalar1); + } else { + m.setScale(SkIntToScalar(2) / rt->width(), SkIntToScalar(2) / rt->height()); + m.postTranslate(-SK_Scalar1, -SK_Scalar1); + } m.preConcat(vm); // GL wants a column-major 4x4. @@ -128,14 +134,23 @@ void GrGpuGL::flushViewMatrix(DrawType type) { GL_CALL(LoadMatrixf(mv)); fHWPathMatrixState.fViewMatrix = vm; fHWPathMatrixState.fRTSize = viewportSize; + fHWPathMatrixState.fLastOrigin = rt->origin(); } - } else if (!fCurrentProgram->fViewMatrix.cheapEqualTo(vm) || + } else if (fCurrentProgram->fOrigin != rt->origin() || + !fCurrentProgram->fViewMatrix.cheapEqualTo(vm) || fCurrentProgram->fViewportSize != viewportSize) { SkMatrix m; - m.setAll( - SkIntToScalar(2) / viewportSize.fWidth, 0, -SK_Scalar1, - 0,-SkIntToScalar(2) / viewportSize.fHeight, SK_Scalar1, + if (kBottomLeft_GrSurfaceOrigin == rt->origin()) { + m.setAll( + SkIntToScalar(2) / viewportSize.fWidth, 0, -SK_Scalar1, + 0,-SkIntToScalar(2) / viewportSize.fHeight, SK_Scalar1, + 0, 0, SkMatrix::I()[8]); + } else { + m.setAll( + SkIntToScalar(2) / viewportSize.fWidth, 0, -SK_Scalar1, + 0, SkIntToScalar(2) / viewportSize.fHeight,-SK_Scalar1, 0, 0, SkMatrix::I()[8]); + } m.setConcat(m, vm); // ES doesn't allow you to pass true to the transpose param, @@ -156,6 +171,7 @@ void GrGpuGL::flushViewMatrix(DrawType type) { mt); fCurrentProgram->fViewMatrix = vm; fCurrentProgram->fViewportSize = viewportSize; + fCurrentProgram->fOrigin = rt->origin(); } } |