Update ProxyTests

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

Change-Id: I0753047eeda71a22b6126f932fc14dd242c5a2e7
Reviewed-on: https://skia-review.googlesource.com/4306
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/include/private/GrRenderTargetProxy.h b/include/private/GrRenderTargetProxy.h
index 27e0492..c124ddd 100644
--- a/include/private/GrRenderTargetProxy.h
+++ b/include/private/GrRenderTargetProxy.h
@@ -25,7 +25,7 @@
      */
     static sk_sp<GrRenderTargetProxy> Make(const GrCaps&, const GrSurfaceDesc&,
                                            SkBackingFit, SkBudgeted);
-    static sk_sp<GrRenderTargetProxy> Make(const GrCaps&, sk_sp<GrRenderTarget>);
+    static sk_sp<GrRenderTargetProxy> Make(sk_sp<GrRenderTarget>);
 
     // TODO: add asTextureProxy variants
     GrRenderTargetProxy* asRenderTargetProxy() override { return this; }
@@ -70,7 +70,7 @@
     GrRenderTargetProxy(const GrCaps&, const GrSurfaceDesc&, SkBackingFit, SkBudgeted);
 
     // Wrapped version
-    GrRenderTargetProxy(const GrCaps&, sk_sp<GrRenderTarget> rt);
+    GrRenderTargetProxy(sk_sp<GrRenderTarget> rt);
 
     size_t onGpuMemorySize() const override;
 
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 53ec06c..aabe8fb 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -609,7 +609,7 @@
                                                                const SkSurfaceProps* surfaceProps) {
     ASSERT_SINGLE_OWNER_PRIV
 
-    sk_sp<GrRenderTargetProxy> rtp(GrRenderTargetProxy::Make(*fContext->caps(), std::move(rt)));
+    sk_sp<GrRenderTargetProxy> rtp(GrRenderTargetProxy::Make(std::move(rt)));
 
     return this->drawingManager()->makeRenderTargetContext(std::move(rtp),
                                                            std::move(colorSpace),
@@ -629,7 +629,7 @@
         return nullptr;
     }
 
-    sk_sp<GrRenderTargetProxy> rtp(GrRenderTargetProxy::Make(*fContext->caps(),
+    sk_sp<GrRenderTargetProxy> rtp(GrRenderTargetProxy::Make(
                                                             sk_ref_sp(surface->asRenderTarget())));
 
     return this->drawingManager()->makeRenderTargetContext(std::move(rtp),
@@ -647,7 +647,7 @@
         return nullptr;
     }
 
-    sk_sp<GrRenderTargetProxy> rtp(GrRenderTargetProxy::Make(*fContext->caps(), std::move(rt)));
+    sk_sp<GrRenderTargetProxy> rtp(GrRenderTargetProxy::Make(std::move(rt)));
 
     return this->drawingManager()->makeRenderTargetContext(std::move(rtp),
                                                            std::move(colorSpace),
@@ -666,8 +666,7 @@
         return nullptr;
     }
 
-    sk_sp<GrRenderTargetProxy> rtp(GrRenderTargetProxy::Make(*fContext->caps(),
-                                                             sk_ref_sp(surface->asRenderTarget())));
+    sk_sp<GrRenderTargetProxy> rtp(GrRenderTargetProxy::Make(sk_ref_sp(surface->asRenderTarget())));
 
     return this->drawingManager()->makeRenderTargetContext(std::move(rtp),
                                                            std::move(colorSpace),
diff --git a/src/gpu/GrRenderTargetProxy.cpp b/src/gpu/GrRenderTargetProxy.cpp
index 3809848..d965e6b 100644
--- a/src/gpu/GrRenderTargetProxy.cpp
+++ b/src/gpu/GrRenderTargetProxy.cpp
@@ -30,7 +30,7 @@
 }
 
 // Wrapped version
-GrRenderTargetProxy::GrRenderTargetProxy(const GrCaps& caps, sk_sp<GrRenderTarget> rt)
+GrRenderTargetProxy::GrRenderTargetProxy(sk_sp<GrRenderTarget> rt)
     : INHERITED(std::move(rt), SkBackingFit::kExact)
     , fFlags(fTarget->asRenderTarget()->renderTargetPriv().flags()) {
 }
@@ -97,7 +97,7 @@
     return sk_sp<GrRenderTargetProxy>(new GrRenderTargetProxy(caps, desc, fit, budgeted));
 }
 
-sk_sp<GrRenderTargetProxy> GrRenderTargetProxy::Make(const GrCaps& caps, sk_sp<GrRenderTarget> rt) {
-    return sk_sp<GrRenderTargetProxy>(new GrRenderTargetProxy(caps, rt));
+sk_sp<GrRenderTargetProxy> GrRenderTargetProxy::Make(sk_sp<GrRenderTarget> rt) {
+    return sk_sp<GrRenderTargetProxy>(new GrRenderTargetProxy(rt));
 }
 
diff --git a/tests/ProxyTest.cpp b/tests/ProxyTest.cpp
index b69e410..6b7ab25 100644
--- a/tests/ProxyTest.cpp
+++ b/tests/ProxyTest.cpp
@@ -10,7 +10,6 @@
 #include "Test.h"
 
 #if SK_SUPPORT_GPU
-#include "GrGpu.h"
 #include "GrSurfaceProxy.h"
 #include "GrTextureProxy.h"
 #include "GrRenderTargetPriv.h"
@@ -22,7 +21,8 @@
                           GrSurfaceOrigin origin,
                           int width, int height, 
                           GrPixelConfig config,
-                          uint32_t uniqueID) {
+                          uint32_t uniqueID,
+                          SkBudgeted budgeted) {
     REPORTER_ASSERT(reporter, proxy->origin() == origin);
     REPORTER_ASSERT(reporter, proxy->width() == width);
     REPORTER_ASSERT(reporter, proxy->height() == height);
@@ -30,12 +30,16 @@
     if (SK_InvalidUniqueID != uniqueID) {
         REPORTER_ASSERT(reporter, proxy->uniqueID() == uniqueID);    
     }
+    REPORTER_ASSERT(reporter, proxy->isBudgeted() == budgeted);
 }
 
 static void check_rendertarget(skiatest::Reporter* reporter,
                                GrTextureProvider* provider,
                                GrRenderTargetProxy* rtProxy,
+                               int numSamples,
                                SkBackingFit fit) {
+    REPORTER_ASSERT(reporter, rtProxy->numStencilSamples() == numSamples);
+
     REPORTER_ASSERT(reporter, rtProxy->asTextureProxy() == nullptr); // for now
     REPORTER_ASSERT(reporter, rtProxy->asRenderTargetProxy() == rtProxy);
 
@@ -85,6 +89,7 @@
 
 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
     GrTextureProvider* provider = ctxInfo.grContext()->textureProvider();
+    const GrCaps& caps = *ctxInfo.grContext()->caps();
 
     for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }) {
         for (auto widthHeight : { 100, 128 }) {
@@ -105,13 +110,13 @@
 
                             if (renderable) {
                                 sk_sp<GrRenderTargetProxy> rtProxy(GrRenderTargetProxy::Make(
-                                                                    *ctxInfo.grContext()->caps(),
-                                                                    desc, 
-                                                                    fit,
-                                                                    budgeted));
+                                                                                caps, desc, 
+                                                                                fit, budgeted));
                                 check_surface(reporter, rtProxy.get(), origin,
-                                              widthHeight, widthHeight, config, SK_InvalidUniqueID);
-                                check_rendertarget(reporter, provider, rtProxy.get(), fit);
+                                              widthHeight, widthHeight, config,
+                                              SK_InvalidUniqueID, budgeted);
+                                check_rendertarget(reporter, provider, rtProxy.get(), 
+                                                   numSamples, fit);
                             }
 
                             desc.fSampleCnt = 0;
@@ -121,7 +126,8 @@
                                                                                 fit,
                                                                                 budgeted));
                             check_surface(reporter, texProxy.get(), origin,
-                                          widthHeight, widthHeight, config, SK_InvalidUniqueID);
+                                          widthHeight, widthHeight, config,
+                                          SK_InvalidUniqueID, budgeted);
                             check_texture(reporter, provider, texProxy.get(), fit);
                         }
                     }
@@ -161,17 +167,17 @@
                         backendDesc.fStencilBits = 8;
                         backendDesc.fRenderTargetHandle = 0;
 
-                        GrGpu* gpu = ctxInfo.grContext()->getGpu();
                         sk_sp<GrRenderTarget> defaultFBO(
-                            gpu->wrapBackendRenderTarget(backendDesc, kBorrow_GrWrapOwnership));
+                            provider->wrapBackendRenderTarget(backendDesc));
                         REPORTER_ASSERT(reporter,
                                         !defaultFBO->renderTargetPriv().maxWindowRectangles());
 
-                        sk_sp<GrRenderTargetProxy> rtProxy(
-                            GrRenderTargetProxy::Make(caps, defaultFBO));
+                        sk_sp<GrRenderTargetProxy> rtProxy(GrRenderTargetProxy::Make(defaultFBO));
                         check_surface(reporter, rtProxy.get(), origin,
-                                      kWidthHeight, kWidthHeight, config, defaultFBO->uniqueID());
-                        check_rendertarget(reporter, provider, rtProxy.get(), SkBackingFit::kExact);
+                                      kWidthHeight, kWidthHeight, config,
+                                      defaultFBO->uniqueID(), SkBudgeted::kNo);
+                        check_rendertarget(reporter, provider, rtProxy.get(),
+                                           numSamples, SkBackingFit::kExact);
                     }
 
                     sk_sp<GrTexture> tex;
@@ -185,10 +191,12 @@
                                         caps.maxWindowRectangles() ==
                                         rt->renderTargetPriv().maxWindowRectangles());
 
-                        sk_sp<GrRenderTargetProxy> rtProxy(GrRenderTargetProxy::Make(caps, rt));
+                        sk_sp<GrRenderTargetProxy> rtProxy(GrRenderTargetProxy::Make(rt));
                         check_surface(reporter, rtProxy.get(), origin,
-                                      kWidthHeight, kWidthHeight, config, rt->uniqueID());
-                        check_rendertarget(reporter, provider, rtProxy.get(), SkBackingFit::kExact);
+                                      kWidthHeight, kWidthHeight, config,
+                                      rt->uniqueID(), budgeted);
+                        check_rendertarget(reporter, provider, rtProxy.get(),
+                                           numSamples, SkBackingFit::kExact);
                     }
 
                     if (!tex) {
@@ -199,7 +207,7 @@
 
                     sk_sp<GrTextureProxy> texProxy(GrTextureProxy::Make(tex));
                     check_surface(reporter, texProxy.get(), origin,
-                                  kWidthHeight, kWidthHeight, config, tex->uniqueID());
+                                  kWidthHeight, kWidthHeight, config, tex->uniqueID(), budgeted);
                     check_texture(reporter, provider, texProxy.get(), SkBackingFit::kExact);
                 }
             }