Index: src/image/SkImage_Gpu.cpp |
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp |
index 7ce6450058e050175ae7eb8a417d75cc4d6ed5cd..21ef52e4636ff476352a0db524cb0b5e6d8e8a86 100644 |
--- a/src/image/SkImage_Gpu.cpp |
+++ b/src/image/SkImage_Gpu.cpp |
@@ -332,6 +332,31 @@ sk_sp<SkImage> SkImage::makeTextureImage(GrContext *context) const { |
return create_image_from_maker(&maker, at, this->uniqueID()); |
} |
+sk_sp<SkImage> SkImage::makeNonTextureImage() const { |
+ GrTexture* texture = as_IB(this)->peekTexture(); |
+ if (!texture) { |
+ return sk_ref_sp(const_cast<SkImage*>(this)); |
+ } |
+ SkColorType ct; |
+ sk_sp<SkColorSpace> cs; |
+ if (!GrPixelConfigToColorAndColorSpace(texture->config(), &ct, &cs)) { |
+ return nullptr; |
+ } |
+ SkAlphaType at = this->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAlphaType; |
+ auto info = SkImageInfo::Make(this->width(), this->height(), ct, at, cs); |
+ size_t rowBytes = info.minRowBytes(); |
+ size_t size = info.getSafeSize(rowBytes); |
+ auto data = SkData::MakeUninitialized(size); |
+ if (!data) { |
+ return nullptr; |
+ } |
+ SkPixmap pm(info, data->writable_data(), rowBytes); |
+ if (!this->readPixels(pm, 0, 0, kDisallow_CachingHint)) { |
+ return nullptr; |
+ } |
+ return MakeRasterData(info, data, rowBytes); |
+} |
+ |
sk_sp<SkImage> SkImage::MakeTextureFromPixmap(GrContext* ctx, const SkPixmap& pixmap, |
SkBudgeted budgeted) { |
if (!ctx) { |