tweak SkImage documentation
- fix syntactic nits
- add how to check result of getBackendTexture
- add example
R=robertphillips@google.com
TBR=reed@google.com
Docs-Preview: https://skia.org/?cl=118590
Bug: skia:6898
Change-Id: I60cfcf448dc2f201ecc34d33ead707d0c3e3b86b
Reviewed-on: https://skia-review.googlesource.com/118590
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Cary Clark <caryclark@skia.org>
diff --git a/docs/SkImage_Reference.bmh b/docs/SkImage_Reference.bmh
index 7aad9ae..7d93555 100644
--- a/docs/SkImage_Reference.bmh
+++ b/docs/SkImage_Reference.bmh
@@ -1395,8 +1395,11 @@
#In Property
#Line # returns GPU reference to Image as texture ##
-Retrieves the backend texture. If there is none an invalid object will be returned.
-If flushPendingGrContextIO is true, complete deferred I/O operations.
+Retrieves the backend texture. If Image has no backend texture, an invalid
+object is returned. Call GrBackendTexture::isValid to determine if the result
+is valid.
+
+If flushPendingGrContextIO is true, completes deferred I/O operations.
If origin in not nullptr, copies location of content drawn into Image.
@@ -1405,9 +1408,26 @@
kBottomLeft_GrSurfaceOrigin; or nullptr
##
-#Return back-end API texture handle. Invalid on failure. ##
+#Return back-end API texture handle; invalid on failure ##
-#NoExample
+#Example
+#Image 3
+#Platform gpu
+ GrContext* grContext = canvas->getGrContext();
+ if (!grContext) {
+ canvas->drawString("GPU only!", 20, 40, SkPaint());
+ return;
+ }
+ sk_sp<SkImage> imageFromBackend = SkImage::MakeFromAdoptedTexture(grContext, backEndTexture,
+ kBottomLeft_GrSurfaceOrigin, kRGBA_8888_SkColorType, kOpaque_SkAlphaType);
+ GrBackendTexture textureFromImage = imageFromBackend->getBackendTexture(false);
+ if (!textureFromImage.isValid()) {
+ return;
+ }
+ sk_sp<SkImage> imageFromTexture = SkImage::MakeFromAdoptedTexture(grContext, textureFromImage,
+ kTopLeft_GrSurfaceOrigin, kRGBA_8888_SkColorType, kOpaque_SkAlphaType);
+ canvas->drawImage(imageFromTexture, 0, 0);
+ canvas->drawImage(imageFromBackend, 128, 128);
##
#SeeAlso MakeFromTexture isTextureBacked