Expand SkImage::getTextureHandle call
AFAICT cc/output/gl_renderer.cc only calls SkImage:getTexture to determine the origin of the backing GrTexture. What do y'all think of this CL as a means of removing that call to getTexture?
One alternative would be to add a new entry point like:
bool SkImage::getBackendTextureDesc(GrBackendTextureDesc* desc) const;
which fills in the entire desc and returns whether the image is texture backed.
Change-Id: Idd302c0a11d69ad08e0100bcf546b3bbaa7cf27e
Reviewed-on: https://skia-review.googlesource.com/7788
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/tests/ImageFilterCacheTest.cpp b/tests/ImageFilterCacheTest.cpp
index 650d4cb..393269a 100644
--- a/tests/ImageFilterCacheTest.cpp
+++ b/tests/ImageFilterCacheTest.cpp
@@ -199,17 +199,37 @@
}
GrBackendTextureDesc backendDesc;
- backendDesc.fConfig = kRGBA_8888_GrPixelConfig;
backendDesc.fFlags = kNone_GrBackendTextureFlag;
+ backendDesc.fOrigin = kTopLeft_GrSurfaceOrigin;
+ backendDesc.fConfig = kRGBA_8888_GrPixelConfig;
backendDesc.fWidth = kFullSize;
backendDesc.fHeight = kFullSize;
backendDesc.fSampleCnt = 0;
backendDesc.fTextureHandle = srcTexture->getTextureHandle();
- sk_sp<SkImage> srcImage(SkImage::MakeFromTexture(ctxInfo.grContext(), backendDesc, kPremul_SkAlphaType));
+ sk_sp<SkImage> srcImage(SkImage::MakeFromTexture(ctxInfo.grContext(),
+ backendDesc,
+ kPremul_SkAlphaType));
if (!srcImage) {
return;
}
+ GrSurfaceOrigin readBackOrigin;
+ GrBackendObject readBackHandle = srcImage->getTextureHandle(false, &readBackOrigin);
+ // TODO: Make it so we can check this (see skbug.com/5019)
+#if 0
+ if (readBackHandle != backendDesc.fTextureHandle) {
+ ERRORF(reporter, "backend mismatch %d %d\n",
+ (int)readBackHandle, (int)backendDesc.fTextureHandle);
+ }
+ REPORTER_ASSERT(reporter, readBackHandle == backendDesc.fTextureHandle);
+#else
+ REPORTER_ASSERT(reporter, SkToBool(readBackHandle));
+#endif
+ if (readBackOrigin != backendDesc.fOrigin) {
+ ERRORF(reporter, "origin mismatch %d %d\n", readBackOrigin, backendDesc.fOrigin);
+ }
+ REPORTER_ASSERT(reporter, readBackOrigin == backendDesc.fOrigin);
+
test_image_backed(reporter, srcImage);
}