Add GrOpList and rename GrDrawTarget to GrRenderTargetOpList

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=3910

Change-Id: I026aa26ecc61a0d002e98892dca728536259e8b1
Reviewed-on: https://skia-review.googlesource.com/3910
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/include/private/GrSurfaceProxy.h b/include/private/GrSurfaceProxy.h
index 69656fe..4e2ad3b 100644
--- a/include/private/GrSurfaceProxy.h
+++ b/include/private/GrSurfaceProxy.h
@@ -11,6 +11,7 @@
 #include "GrGpuResource.h"
 #include "SkRect.h"
 
+class GrOpList;
 class GrTextureProxy;
 class GrRenderTargetProxy;
 
@@ -51,13 +52,17 @@
      */
     SkBudgeted isBudgeted() const { return fBudgeted; }
 
+    void setLastOpList(GrOpList* opList);
+    GrOpList* getLastOpList() { return fLastOpList; }
+
 protected:
     // Deferred version
     GrSurfaceProxy(const GrSurfaceDesc& desc, SkBackingFit fit, SkBudgeted budgeted)
         : fDesc(desc)
         , fFit(fit)
         , fBudgeted(budgeted)
-        , fUniqueID(GrGpuResource::CreateUniqueID()) {
+        , fUniqueID(GrGpuResource::CreateUniqueID())
+        , fLastOpList(nullptr) {
     }
 
     // Wrapped version
@@ -66,10 +71,12 @@
         : fDesc(desc)
         , fFit(fit)
         , fBudgeted(budgeted)
-        , fUniqueID(uniqueID) {
+        , fUniqueID(uniqueID)
+        , fLastOpList(nullptr) {
     }
 
-    virtual ~GrSurfaceProxy() {}
+    virtual ~GrSurfaceProxy();
+
 
     // For wrapped resources, 'fDesc' will always be filled in from the wrapped resource.
     const GrSurfaceDesc fDesc;
@@ -83,6 +90,14 @@
     void notifyAllCntsAreZero(CntType) const { delete this; }
     bool notifyRefCountIsZero() const { return true; }
 
+    // The last opList that wrote to or is currently going to write to this surface
+    // The opList can be closed (e.g., no draw context is currently bound
+    // to this renderTarget).
+    // This back-pointer is required so that we can add a dependancy between
+    // the opList used to create the current contents of this surface
+    // and the opList of a destination surface to which this one is being drawn or copied.
+    GrOpList* fLastOpList;
+
     typedef GrIORef<GrSurfaceProxy> INHERITED;
 
     // to access notifyAllCntsAreZero and notifyRefCntIsZero.