Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(887)

Unified Diff: src/gpu/GrContext.cpp

Issue 586073002: Don't flush on read/write pixels unless necessary (Closed) Base URL: https://skia.googlesource.com/skia.git@iotype
Patch Set: Flush when drawing direct to GrGpu in GrContext Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/gpu/GrSurface.h ('k') | src/gpu/GrInOrderDrawBuffer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrContext.cpp
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index eb8455adbbae89355d4521fbbbeb140ede4643f7..f8eca3682beec53c9357f718fb41883e38cbeeb8 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();
}
@@ -1578,11 +1578,10 @@ void GrContext::copyTexture(GrTexture* src, GrRenderTarget* dst, const SkIPoint*
}
ASSERT_OWNED_RESOURCE(src);
- // Writes pending to the source texture are not tracked, so a flush
- // is required to ensure that the copy captures the most recent contents
- // of the source texture. See similar behavior in
- // GrContext::resolveRenderTarget.
- this->flush();
+
+ if (src->hasPendingWrite() || dst->hasPendingIO()) {
+ this->flush();
+ }
GrDrawTarget::AutoStateRestore asr(fGpu, GrDrawTarget::kReset_ASRInit);
GrDrawState* drawState = fGpu->drawState();
@@ -1715,9 +1714,15 @@ bool GrContext::writeRenderTargetPixels(GrRenderTarget* target,
return false;
}
+ // TODO: Usually this could go to fDrawBuffer but currently
// writeRenderTargetPixels can be called in the midst of drawing another
// object (e.g., when uploading a SW path rendering to the gpu while
- // drawing a rect) so preserve the current geometry.
+ // drawing a rect). So we always draw directly to GrGpu and preserve the current geometry.
+ // But that means we also have to flush the draw buffer if there is a pending IO operation to
+ // the render target.
+ if (!(kDontFlush_PixelOpsFlag & flags) && target->hasPendingIO()) {
+ this->flush();
+ }
SkMatrix matrix;
matrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top));
GrDrawTarget::AutoGeometryAndStatePush agasp(fGpu, GrDrawTarget::kReset_ASRInit, &matrix);
« no previous file with comments | « include/gpu/GrSurface.h ('k') | src/gpu/GrInOrderDrawBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698