Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(748)

Unified Diff: src/image/SkImage_Gpu.cpp

Issue 2147493004: Add a function to convert a texture backed SkImage to raster. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: cleanup Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/image/SkImage.cpp ('k') | tests/ImageTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « src/image/SkImage.cpp ('k') | tests/ImageTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698