Add texture-specific flags for External & Rectangle textures

For DDLs, Ganesh needs to know about External & Rectangle textures prior to instantiation (or PromiseImage fulfillment). These new flags allow the client to provide this information when the lazyProxy is created.

The new texture flags work analogously to the render target flags:
   GrSurface and GrSurfaceProxy get a new set of accessors for the new flags
   The new flags are set appropriately on a GrGLTexture when it is created
   For wrapped texture proxies the flags are just copied off of the GrSurface
   For lazy-proxies/promise-images the flags are computed up front and passed to the proxy
   The GrSurfaceProxy/GrSurface flags equivalence is verified in GrSurfaceProxy::assign

Change-Id: Ia8e1998aa0a36ce4481bfd9e56be21f990e83148
Reviewed-on: https://skia-review.googlesource.com/114985
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/tests/DeferredDisplayListTest.cpp b/tests/DeferredDisplayListTest.cpp
index 9abe5f9..d9aa522 100644
--- a/tests/DeferredDisplayListTest.cpp
+++ b/tests/DeferredDisplayListTest.cpp
@@ -11,9 +11,12 @@
 
 #include "GrBackendSurface.h"
 #include "GrGpu.h"
+#include "GrTextureProxyPriv.h"
+
 #include "SkCanvas.h"
 #include "SkDeferredDisplayListRecorder.h"
 #include "SkGpuDevice.h"
+#include "SkImage_Gpu.h"
 #include "SkSurface.h"
 #include "SkSurface_Gpu.h"
 #include "SkSurfaceCharacterization.h"
@@ -406,7 +409,7 @@
 
 static void dummy_fulfill_proc(void*, GrBackendTexture*) { SkASSERT(0); }
 static void dummy_release_proc(void*) { SkASSERT(0); }
-static void dummy_done_proc(void*) { SkASSERT(0); }
+static void dummy_done_proc(void*) { }
 
 // Test out the behavior of an invalid DDLRecorder
 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLInvalidRecorder, reporter, ctxInfo) {
@@ -433,7 +436,7 @@
         REPORTER_ASSERT(reporter, !recorder.getCanvas());
         REPORTER_ASSERT(reporter, !recorder.detach());
 
-        GrBackendFormat format;
+        GrBackendFormat format = create_backend_format(context, kRGBA_8888_SkColorType);
         sk_sp<SkImage> image = recorder.makePromiseTexture(format, 32, 32, GrMipMapped::kNo,
                                                            kTopLeft_GrSurfaceOrigin,
                                                            kRGBA_8888_SkColorType,
@@ -464,4 +467,42 @@
     canvas->getGrContext()->flush();
 }
 
+// Check that the texture-specific flags (i.e., for external & rectangle textures) work
+// for promise images. As such, this is a GL-only test.
+DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(DDLTextureFlagsTest, reporter, ctxInfo) {
+    GrContext* context = ctxInfo.grContext();
+
+    SkImageInfo ii = SkImageInfo::MakeN32Premul(32, 32);
+    sk_sp<SkSurface> s = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, ii);
+
+    SkSurfaceCharacterization characterization;
+    SkAssertResult(s->characterize(&characterization));
+
+    SkDeferredDisplayListRecorder recorder(characterization);
+
+    for (GrGLenum target : { GR_GL_TEXTURE_EXTERNAL, GR_GL_TEXTURE_RECTANGLE, GR_GL_TEXTURE_2D } ) {
+        GrBackendFormat format = GrBackendFormat::MakeGL(GR_GL_RGBA8, target);
+
+        sk_sp<SkImage> image = recorder.makePromiseTexture(format, 32, 32, GrMipMapped::kNo,
+                                                           kTopLeft_GrSurfaceOrigin,
+                                                           kRGBA_8888_SkColorType,
+                                                           kPremul_SkAlphaType, nullptr,
+                                                           dummy_fulfill_proc,
+                                                           dummy_release_proc,
+                                                           dummy_done_proc,
+                                                           nullptr);
+        REPORTER_ASSERT(reporter, image);
+
+        GrTextureProxy* backingProxy = ((SkImage_Gpu*) image.get())->peekProxy();
+
+        if (GR_GL_TEXTURE_2D == target) {
+            REPORTER_ASSERT(reporter, !backingProxy->texPriv().doesNotSupportMipMaps());
+            REPORTER_ASSERT(reporter, !backingProxy->texPriv().isClampOnly());
+        } else {
+            REPORTER_ASSERT(reporter, backingProxy->texPriv().doesNotSupportMipMaps());
+            REPORTER_ASSERT(reporter, backingProxy->texPriv().isClampOnly());
+        }
+    }
+
+}
 #endif
diff --git a/tests/EGLImageTest.cpp b/tests/EGLImageTest.cpp
index e65954a..b44f5b2 100644
--- a/tests/EGLImageTest.cpp
+++ b/tests/EGLImageTest.cpp
@@ -13,8 +13,11 @@
 #include "GrContextPriv.h"
 #include "GrRenderTargetContext.h"
 #include "GrShaderCaps.h"
+#include "GrSurfacePriv.h"
 #include "GrTest.h"
+#include "GrTexture.h"
 #include "GrTextureContext.h"
+#include "GrTextureProxyPriv.h"
 #include "gl/GLTestContext.h"
 #include "gl/GrGLGpu.h"
 #include "gl/GrGLUtil.h"
@@ -159,6 +162,13 @@
         return;
     }
 
+    GrTextureProxy* proxy = surfaceContext->asTextureProxy();
+    REPORTER_ASSERT(reporter, proxy->texPriv().doesNotSupportMipMaps());
+    REPORTER_ASSERT(reporter, proxy->priv().peekTexture()->surfacePriv().doesNotSupportMipMaps());
+
+    REPORTER_ASSERT(reporter, proxy->texPriv().isClampOnly());
+    REPORTER_ASSERT(reporter, proxy->priv().peekTexture()->surfacePriv().isClampOnly());
+
     // Should not be able to wrap as a RT
     {
         sk_sp<GrRenderTargetContext> temp =
diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp
index e7512fb..6087aab 100644
--- a/tests/RectangleTextureTest.cpp
+++ b/tests/RectangleTextureTest.cpp
@@ -14,7 +14,9 @@
 #include "GrContextPriv.h"
 #include "GrProxyProvider.h"
 #include "GrRenderTargetContext.h"
+#include "GrSurfacePriv.h"
 #include "GrTest.h"
+#include "GrTextureProxyPriv.h"
 #include "gl/GLTestContext.h"
 #include "gl/GrGLGpu.h"
 #include "gl/GrGLUtil.h"
@@ -135,6 +137,12 @@
             continue;
         }
 
+        SkASSERT(rectProxy->texPriv().doesNotSupportMipMaps());
+        SkASSERT(rectProxy->priv().peekTexture()->surfacePriv().doesNotSupportMipMaps());
+
+        SkASSERT(rectProxy->texPriv().isClampOnly());
+        SkASSERT(rectProxy->priv().peekTexture()->surfacePriv().isClampOnly());
+
         test_basic_draw_as_src(reporter, context, rectProxy, refPixels);
 
         // Test copy to both a texture and RT