diff options
author | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-06-04 19:05:11 +0000 |
---|---|---|
committer | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-06-04 19:05:11 +0000 |
commit | 4c8837867add05f8d25520f92f6ec52305dda02e (patch) | |
tree | 0b9ef043af779d1b6b3fe3a202ebc00ea646d91c /src/gpu/gl/GrGpuGL_program.cpp | |
parent | 8b0d0f6a9c01f45cd5bacf7aea2a32306fb16684 (diff) |
move texture flush and param update to separate function
Review URL: http://codereview.appspot.com/6266044/
git-svn-id: http://skia.googlecode.com/svn/trunk@4142 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/gl/GrGpuGL_program.cpp')
-rw-r--r-- | src/gpu/gl/GrGpuGL_program.cpp | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/src/gpu/gl/GrGpuGL_program.cpp b/src/gpu/gl/GrGpuGL_program.cpp index e79afe15e2..1f3216f3ef 100644 --- a/src/gpu/gl/GrGpuGL_program.cpp +++ b/src/gpu/gl/GrGpuGL_program.cpp @@ -39,13 +39,6 @@ void GrGpuGL::ProgramCache::abandon() { fCount = 0; } -void GrGpuGL::ProgramCache::invalidateViewMatrices() { - for (int i = 0; i < fCount; ++i) { - // set to illegal matrix - fEntries[i].fProgramData.fViewMatrix = GrMatrix::InvalidMatrix(); - } -} - GrGLProgram::CachedData* GrGpuGL::ProgramCache::getProgramData( const GrGLProgram& desc, GrCustomStage** stages) { @@ -111,15 +104,20 @@ void GrGpuGL::abandonResources(){ #define GL_CALL(X) GR_GL_CALL(this->glInterface(), X) void GrGpuGL::flushViewMatrix() { + const GrGLRenderTarget* rt = static_cast<const GrGLRenderTarget*>(this->getDrawState().getRenderTarget()); + SkISize viewportSize; + const GrGLIRect& viewport = rt->getViewport(); + viewportSize.set(viewport.fWidth, viewport.fHeight); + const GrMatrix& vm = this->getDrawState().getViewMatrix(); - if (!fProgramData->fViewMatrix.cheapEqualTo(vm)) { - const GrRenderTarget* rt = this->getDrawState().getRenderTarget(); - GrAssert(NULL != rt); + if (!fProgramData->fViewMatrix.cheapEqualTo(vm) || + fProgramData->fViewportSize != viewportSize) { + GrMatrix m; m.setAll( - GrIntToScalar(2) / rt->width(), 0, -GR_Scalar1, - 0,-GrIntToScalar(2) / rt->height(), GR_Scalar1, + GrIntToScalar(2) / viewportSize.fWidth, 0, -GR_Scalar1, + 0,-GrIntToScalar(2) / viewportSize.fHeight, GR_Scalar1, 0, 0, GrMatrix::I()[8]); m.setConcat(m, vm); @@ -142,6 +140,7 @@ void GrGpuGL::flushViewMatrix() { GL_CALL(UniformMatrix3fv(fProgramData->fUniLocations.fViewMatrixUni, 1, false, mt)); fProgramData->fViewMatrix = vm; + fProgramData->fViewportSize = viewportSize; } } @@ -438,6 +437,9 @@ bool GrGpuGL::flushGraphicsState(GrPrimitiveType type) { for (int s = 0; s < GrDrawState::kNumStages; ++s) { if (this->isStageEnabled(s)) { + + this->flushBoundTextureAndParams(s); + this->flushTextureMatrixAndDomain(s); this->flushTexelSize(s); @@ -455,6 +457,18 @@ bool GrGpuGL::flushGraphicsState(GrPrimitiveType type) { } } this->flushColorMatrix(); + + GrIRect* rect = NULL; + GrIRect clipBounds; + if (drawState.isClipState() && + fClip.hasConservativeBounds()) { + fClip.getConservativeBounds().roundOut(&clipBounds); + rect = &clipBounds; + } + // This must come after textures are flushed because a texture may need + // to be msaa-resolved (which will modify bound FBO state). + this->flushRenderTarget(rect); + return true; } |