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

Unified Diff: src/gpu/GrDrawTarget.cpp

Issue 2113303002: Use bounds of batches for render pass bounds (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix int to scalar Created 4 years, 6 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 | « no previous file | src/gpu/vk/GrVkGpu.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrDrawTarget.cpp
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index 94f7293ef93cbce3e7a9d1e8520e5a7612784874..86e0c82f225f1a6cf32e54602cb50c3c2375af82 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -215,6 +215,7 @@ void GrDrawTarget::drawBatches(GrBatchFlushState* flushState) {
SkRandom random;
GrRenderTarget* currentRT = nullptr;
SkAutoTDelete<GrGpuCommandBuffer> commandBuffer;
+ SkRect bounds = SkRect::MakeEmpty();
for (int i = 0; i < fBatches.count(); ++i) {
if (!fBatches[i]) {
continue;
@@ -222,12 +223,16 @@ void GrDrawTarget::drawBatches(GrBatchFlushState* flushState) {
if (fBatches[i]->renderTarget() != currentRT) {
if (commandBuffer) {
commandBuffer->end();
- // For now just use size of whole render target, but this should be updated to
- // only be the actual bounds of the various draws.
- SkIRect bounds = SkIRect::MakeWH(currentRT->width(), currentRT->height());
- commandBuffer->submit(bounds);
+ if (bounds.intersect(0, 0,
+ SkIntToScalar(currentRT->width()),
+ SkIntToScalar(currentRT->height()))) {
+ SkIRect iBounds;
+ bounds.roundOut(&iBounds);
+ commandBuffer->submit(iBounds);
+ }
commandBuffer.reset();
}
+ bounds.setEmpty();
currentRT = fBatches[i]->renderTarget();
if (currentRT) {
static const GrGpuCommandBuffer::LoadAndStoreInfo kBasicLoadStoreInfo
@@ -239,24 +244,30 @@ void GrDrawTarget::drawBatches(GrBatchFlushState* flushState) {
}
flushState->setCommandBuffer(commandBuffer);
}
+ if (commandBuffer) {
+ bounds.join(fBatches[i]->bounds());
+ }
if (fDrawBatchBounds) {
- const SkRect& bounds = fBatches[i]->bounds();
- SkIRect ibounds;
- bounds.roundOut(&ibounds);
+ const SkRect& batchBounds = fBatches[i]->bounds();
+ SkIRect iBatchBounds;
+ batchBounds.roundOut(&iBatchBounds);
// In multi-draw buffer all the batches use the same render target and we won't need to
// get the batchs bounds.
if (GrRenderTarget* rt = fBatches[i]->renderTarget()) {
- fGpu->drawDebugWireRect(rt, ibounds, 0xFF000000 | random.nextU());
+ fGpu->drawDebugWireRect(rt, iBatchBounds, 0xFF000000 | random.nextU());
}
}
fBatches[i]->draw(flushState);
}
if (commandBuffer) {
commandBuffer->end();
- // For now just use size of whole render target, but this should be updated to
- // only be the actual bounds of the various draws.
- SkIRect bounds = SkIRect::MakeWH(currentRT->width(), currentRT->height());
- commandBuffer->submit(bounds);
+ if (bounds.intersect(0, 0,
+ SkIntToScalar(currentRT->width()),
+ SkIntToScalar(currentRT->height()))) {
+ SkIRect iBounds;
+ bounds.roundOut(&iBounds);
+ commandBuffer->submit(iBounds);
+ }
flushState->setCommandBuffer(nullptr);
}
« no previous file with comments | « no previous file | src/gpu/vk/GrVkGpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698