use onPeekBitmap instead of asLegacyBitmap
authorreed <reed@google.com>
Mon, 8 Aug 2016 16:00:29 +0000 (09:00 -0700)
committerCommit bot <commit-bot@chromium.org>
Mon, 8 Aug 2016 16:00:29 +0000 (09:00 -0700)
Since we know we are raster-backed at this point, it is fine, plus it avoids the copy-mutable logic in asLegacyBitmap, which is not needed here (and is slower if our bitmap was built with kNever_SkCopyPixelsMode).

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

Review-Url: https://codereview.chromium.org/2223653002

src/image/SkImage_Gpu.cpp

index c795d54..44bb71c 100644 (file)
@@ -315,12 +315,12 @@ sk_sp<SkImage> SkImage::makeTextureImage(GrContext *context) const {
         GrImageTextureMaker maker(context, cacher, this, kDisallow_CachingHint);
         return create_image_from_maker(&maker, at, this->uniqueID());
     }
-    SkBitmap bmp;
-    if (!this->asLegacyBitmap(&bmp, kRO_LegacyBitmapMode)) {
-        return nullptr;
+
+    if (const SkBitmap* bmp = as_IB(this)->onPeekBitmap()) {
+        GrBitmapTextureMaker maker(context, *bmp);
+        return create_image_from_maker(&maker, at, this->uniqueID());
     }
-    GrBitmapTextureMaker maker(context, bmp);
-    return create_image_from_maker(&maker, at, this->uniqueID());
+    return nullptr;
 }
 
 sk_sp<SkImage> SkImage::makeNonTextureImage() const {