Start using GrGpuCommandBuffer in GrDrawTarget.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2052263003
Review-Url: https://codereview.chromium.org/2078483002
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index 7213a92..d498d49 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -11,6 +11,7 @@
#include "GrCaps.h"
#include "GrDrawContext.h"
#include "GrGpu.h"
+#include "GrGpuCommandBuffer.h"
#include "GrPath.h"
#include "GrPipeline.h"
#include "GrMemoryPool.h"
@@ -209,10 +210,32 @@
void GrDrawTarget::drawBatches(GrBatchFlushState* flushState) {
// Draw all the generated geometry.
SkRandom random;
+ GrRenderTarget* currentRT = nullptr;
+ SkAutoTDelete<GrGpuCommandBuffer> commandBuffer;
for (int i = 0; i < fBatches.count(); ++i) {
if (!fBatches[i]) {
continue;
}
+ 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);
+ commandBuffer.reset();
+ }
+ currentRT = fBatches[i]->renderTarget();
+ if (currentRT) {
+ static const GrGpuCommandBuffer::LoadAndStoreInfo kBasicLoadStoreInfo
+ { GrGpuCommandBuffer::LoadOp::kLoad,GrGpuCommandBuffer::StoreOp::kStore,
+ GrColor_ILLEGAL };
+ commandBuffer.reset(fGpu->createCommandBuffer(currentRT,
+ kBasicLoadStoreInfo, // Color
+ kBasicLoadStoreInfo)); // Stencil
+ }
+ flushState->setCommandBuffer(commandBuffer);
+ }
if (fDrawBatchBounds) {
const SkRect& bounds = fBatches[i]->bounds();
SkIRect ibounds;
@@ -225,6 +248,14 @@
}
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);
+ flushState->setCommandBuffer(nullptr);
+ }
fGpu->finishDrawTarget();
}