Remove GrBatch::renderTarget() and use GrBatch::renderTargetUniqueID() instead.
authorBrian Salomon <bsalomon@google.com>
Wed, 30 Nov 2016 15:52:10 +0000 (10:52 -0500)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Wed, 30 Nov 2016 22:11:50 +0000 (22:11 +0000)
Change-Id: I621ed38955e374c79a4d44c0020f9bae9655f001
Reviewed-on: https://skia-review.googlesource.com/5344
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>

src/gpu/GrRenderTargetOpList.cpp
src/gpu/batches/GrBatch.h
src/gpu/batches/GrClearBatch.h
src/gpu/batches/GrClearStencilClipBatch.h
src/gpu/batches/GrCopySurfaceBatch.h
src/gpu/batches/GrDiscardBatch.h
src/gpu/batches/GrDrawBatch.h
src/gpu/batches/GrStencilPathBatch.h

index 40c543d361ade07730c0282c5889b51b9ce3b729..7b16a55c9d13cfc9fd77fa5bb8fa37ef86855ca4 100644 (file)
@@ -186,20 +186,20 @@ bool GrRenderTargetOpList::drawBatches(GrBatchFlushState* flushState) {
     }
     // Draw all the generated geometry.
     SkRandom random;
-    GrRenderTarget* currentRT = nullptr;
+    GrGpuResource::UniqueID currentRTID = GrGpuResource::UniqueID::InvalidID();
     std::unique_ptr<GrGpuCommandBuffer> commandBuffer;
     for (int i = 0; i < fRecordedBatches.count(); ++i) {
         if (!fRecordedBatches[i].fBatch) {
             continue;
         }
-        if (fRecordedBatches[i].fBatch->renderTarget() != currentRT) {
+        if (fRecordedBatches[i].fBatch->renderTargetUniqueID() != currentRTID) {
             if (commandBuffer) {
                 commandBuffer->end();
                 commandBuffer->submit();
                 commandBuffer.reset();
             }
-            currentRT = fRecordedBatches[i].fBatch->renderTarget();
-            if (currentRT) {
+            currentRTID = fRecordedBatches[i].fBatch->renderTargetUniqueID();
+            if (!currentRTID.isInvalid()) {
                 static const GrGpuCommandBuffer::LoadAndStoreInfo kBasicLoadStoreInfo
                     { GrGpuCommandBuffer::LoadOp::kLoad,GrGpuCommandBuffer::StoreOp::kStore,
                       GrColor_ILLEGAL };
index ec81ec9bc0dbfbb10e61d782cd7fd9990c143dec..e4065ecace341af65d0173069ecba5e045182afa 100644 (file)
@@ -20,7 +20,6 @@
 class GrCaps;
 class GrGpuCommandBuffer;
 class GrBatchFlushState;
-class GrRenderTarget;
 
 /**
  * GrBatch is the base class for all Ganesh deferred geometry generators.  To facilitate
@@ -141,9 +140,6 @@ public:
         return string;
     }
 
-    /** Can remove this when multi-draw-buffer lands */
-    virtual GrRenderTarget* renderTarget() const = 0;
-
 protected:
     /**
      * Indicates that the batch will produce geometry that extends beyond its bounds for the
index 724981e658ffc6f44a923c595876b2c8913ca696..24905d36484c463c402de787d10dbfb011f3b923 100644 (file)
@@ -21,7 +21,7 @@ public:
 
     static sk_sp<GrClearBatch> Make(const GrFixedClip& clip, GrColor color, GrRenderTarget* rt) {
         sk_sp<GrClearBatch> batch(new GrClearBatch(clip, color, rt));
-        if (!batch->renderTarget()) {
+        if (!batch->fRenderTarget) {
             return nullptr; // The clip did not contain any pixels within the render target.
         }
         return batch;
@@ -33,8 +33,6 @@ public:
     GrGpuResource::UniqueID renderTargetUniqueID() const override {
         return fRenderTarget.get()->uniqueID();
     }
-    // TODO: store a GrRenderTargetContext instead
-    GrRenderTarget* renderTarget() const override { return fRenderTarget.get(); }
 
     SkString dumpInfo() const override {
         SkString string("Scissor [");
index 7f69f64c16227e8e66d05d94409b822bb6095680..0f2617355dc9f078510e4f9835a1df569c9ff99b 100644 (file)
@@ -35,7 +35,6 @@ public:
     GrGpuResource::UniqueID renderTargetUniqueID() const override {
         return fRenderTarget.get()->uniqueID();
     }
-    GrRenderTarget* renderTarget() const override { return fRenderTarget.get(); }
 
     SkString dumpInfo() const override {
         SkString string("Scissor [");
index a014ccb14751144c76fcf2174bb8b1ddb0c30870..3d9fc78ac3edeb279f78c67f0d079f92a3e4e9c0 100644 (file)
@@ -34,13 +34,11 @@ public:
 
     // TODO: this needs to be updated to return GrSurfaceProxy::UniqueID
     GrGpuResource::UniqueID renderTargetUniqueID() const override {
-        // TODO: When we have CopyContexts it seems that this should return the ID
-        // of the SurfaceProxy underlying the CopyContext.
-        GrRenderTarget* rt = fDst.get()->asRenderTarget();
-        return rt ? rt->uniqueID() : GrGpuResource::UniqueID::InvalidID();
+        // Copy surface doesn't work through a GrGpuCommandBuffer. By returning an invalid RT ID we
+        // force the caller to end the previous command buffer and execute this copy before
+        // beginning a new one.
+        return GrGpuResource::UniqueID::InvalidID();
     }
-    // TODO: this seems odd - figure it out and add a comment!
-    GrRenderTarget* renderTarget() const override { return nullptr; }
 
     SkString dumpInfo() const override {
         SkString string;
@@ -74,7 +72,8 @@ private:
         if (!state->commandBuffer()) {
             state->gpu()->copySurface(fDst.get(), fSrc.get(), fSrcRect, fDstPoint);
         } else {
-            // currently we are not sending copies through the GrGpuCommandBuffer
+            // Currently we are not sending copies through the GrGpuCommandBuffer. See comment in
+            // renderTargetUniqueID().
             SkASSERT(false);
         }
     }
index 799c7462cbb633ff1fa94c2d276a41cba1f893f0..d2ebb4662bbe67ff261ad261ed983272bd358318 100644 (file)
@@ -30,7 +30,6 @@ public:
     GrGpuResource::UniqueID renderTargetUniqueID() const override {
         return fRenderTarget.get()->uniqueID();
     }
-    GrRenderTarget* renderTarget() const override { return fRenderTarget.get(); }
 
     SkString dumpInfo() const override {
         SkString string;
index af1de0dc77f12789e38bbd052239352f59a6824a..95516c93639360a64f266d5075b8ea568823498b 100644 (file)
@@ -75,11 +75,6 @@ public:
         return this->pipeline()->getRenderTarget()->uniqueID();
     }
 
-    // TODO: store a GrRenderTargetContext instead
-    GrRenderTarget* renderTarget() const final {
-        return this->pipeline()->getRenderTarget();
-    }
-
     SkString dumpInfo() const override {
         SkString string;
         string.appendf("RT: %d\n", this->renderTargetUniqueID().asUInt());
index 3a6f82d8a131fcb37206fd38a1f175f47ebd474f..b95c75a5ce6bffe0f298475d5444c117857b0892 100644 (file)
@@ -37,7 +37,6 @@ public:
     GrGpuResource::UniqueID renderTargetUniqueID() const override {
         return fRenderTarget.get()->uniqueID();
     }
-    GrRenderTarget* renderTarget() const override { return fRenderTarget.get(); }
 
     SkString dumpInfo() const override {
         SkString string;