diff options
author | bsalomon <bsalomon@google.com> | 2014-09-22 08:17:02 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-22 08:17:02 -0700 |
commit | 150723b9298772a5096bec7acd2999c5c9d66239 (patch) | |
tree | e3df3dd490dc1fa001d5f6d3fbf887f2f9b4adf5 /src/gpu | |
parent | 4a8126e7f81384526629b1e21bf89b632ea13cd9 (diff) |
Don't flush on read/write pixels unless necessary
BUG=skia:2889
R=robertphillips@google.com
Author: bsalomon@google.com
Review URL: https://codereview.chromium.org/586073002
Diffstat (limited to 'src/gpu')
-rwxr-xr-x | src/gpu/GrContext.cpp | 4 | ||||
-rw-r--r-- | src/gpu/GrInOrderDrawBuffer.cpp | 2 | ||||
-rw-r--r-- | src/gpu/GrSurface.cpp | 36 |
3 files changed, 39 insertions, 3 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index eb8455adbb..afe396d653 100755 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -1347,7 +1347,7 @@ bool GrContext::writeTexturePixels(GrTexture* texture, } } - if (!(kDontFlush_PixelOpsFlag & flags)) { + if (!(kDontFlush_PixelOpsFlag & flags) && texture->hasPendingIO()) { this->flush(); } @@ -1418,7 +1418,7 @@ bool GrContext::readRenderTargetPixels(GrRenderTarget* target, } } - if (!(kDontFlush_PixelOpsFlag & flags)) { + if (!(kDontFlush_PixelOpsFlag & flags) && target->hasPendingWrite()) { this->flush(); } diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp index efbe8611da..b9e84c0a99 100644 --- a/src/gpu/GrInOrderDrawBuffer.cpp +++ b/src/gpu/GrInOrderDrawBuffer.cpp @@ -833,7 +833,7 @@ void GrInOrderDrawBuffer::geometrySourceWillPop(const GeometrySrcState& restored void GrInOrderDrawBuffer::recordStateIfNecessary() { if (fStates.empty()) { - fStates.push_back() = this->getDrawState(); + this->convertDrawStateToPendingExec(&fStates.push_back(this->getDrawState())); this->addToCmdBuffer(kSetState_Cmd); return; } diff --git a/src/gpu/GrSurface.cpp b/src/gpu/GrSurface.cpp index 52ab4fd11d..d15cbdf6e2 100644 --- a/src/gpu/GrSurface.cpp +++ b/src/gpu/GrSurface.cpp @@ -44,3 +44,39 @@ bool GrSurface::savePixels(const char* filename) { return true; } + +bool GrSurface::hasPendingRead() const { + const GrTexture* thisTex = this->asTexture(); + if (thisTex && thisTex->internalHasPendingRead()) { + return true; + } + const GrRenderTarget* thisRT = this->asRenderTarget(); + if (thisRT && thisRT->internalHasPendingRead()) { + return true; + } + return false; +} + +bool GrSurface::hasPendingWrite() const { + const GrTexture* thisTex = this->asTexture(); + if (thisTex && thisTex->internalHasPendingWrite()) { + return true; + } + const GrRenderTarget* thisRT = this->asRenderTarget(); + if (thisRT && thisRT->internalHasPendingWrite()) { + return true; + } + return false; +} + +bool GrSurface::hasPendingIO() const { + const GrTexture* thisTex = this->asTexture(); + if (thisTex && thisTex->internalHasPendingIO()) { + return true; + } + const GrRenderTarget* thisRT = this->asRenderTarget(); + if (thisRT && thisRT->internalHasPendingIO()) { + return true; + } + return false; +} |