sk_sp<SkImage> SkImage::makeTextureImage(GrContext *context) const { if (!context) { return nullptr; } if (GrTexture* peek = as_IB(this)->peekTexture()) { return peek->getContext() == context ? sk_ref_sp(const_cast<SkImage*>(this)) : nullptr; } if (SkImageCacherator* cacher = as_IB(this)->peekCacherator()) { GrImageTextureMaker maker(context, cacher, this, kDisallow_CachingHint); return create_image_from_maker(&maker, this->alphaType(), this->uniqueID()); } if (const SkBitmap* bmp = as_IB(this)->onPeekBitmap()) { GrBitmapTextureMaker maker(context, *bmp); return create_image_from_maker(&maker, this->alphaType(), this->uniqueID()); } return nullptr; }
sk_sp<SkImage> SkImage::makeTextureImage(GrContext *context) const { if (!context) { return nullptr; } if (GrTexture* peek = as_IB(this)->peekTexture()) { return peek->getContext() == context ? sk_ref_sp(const_cast<SkImage*>(this)) : nullptr; } // No way to check whether a image is premul or not? SkAlphaType at = this->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAlphaType; if (SkImageCacherator* cacher = as_IB(this)->peekCacherator()) { 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; } GrBitmapTextureMaker maker(context, bmp); return create_image_from_maker(&maker, at, this->uniqueID()); }