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

Unified Diff: src/image/SkImage_Gpu.cpp

Issue 2173513002: Cleanup of code that converts from GPU-backed resources to SkImageInfo (Closed) Base URL: https://skia.googlesource.com/skia.git@fix-sync
Patch Set: 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_Gpu.h ('k') | no next file » | 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 fa697cd4b99ca6e131cd9233087b04ab8e873cb3..c331a295ce6d44031f1c0fb480aa3335b5a8eed2 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -43,6 +43,14 @@ extern void SkTextureImageApplyBudgetedDecision(SkImage* image) {
}
}
+SkImageInfo SkImage_Gpu::onImageInfo() const {
+ SkColorType ct;
+ if (!GrPixelConfigToColorType(fTexture->config(), &ct)) {
+ ct = kUnknown_SkColorType;
+ }
+ return SkImageInfo::Make(fTexture->width(), fTexture->height(), ct, fAlphaType, fColorSpace);
Brian Osman 2016/07/21 20:57:07 This is now slightly different semantically - it u
+}
+
static SkImageInfo make_info(int w, int h, bool isOpaque, sk_sp<SkColorSpace> colorSpace) {
return SkImageInfo::MakeN32(w, h, isOpaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType,
std::move(colorSpace));
@@ -316,17 +324,10 @@ sk_sp<SkImage> SkImage::makeTextureImage(GrContext *context) const {
}
sk_sp<SkImage> SkImage::makeNonTextureImage() const {
- GrTexture* texture = as_IB(this)->peekTexture();
- if (!texture) {
+ if (!this->isTextureBacked()) {
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);
+ SkImageInfo info = as_IB(this)->onImageInfo();
Brian Osman 2016/07/21 20:57:07 Similar to above. We already have the *correct* al
size_t rowBytes = info.minRowBytes();
size_t size = info.getSafeSize(rowBytes);
auto data = SkData::MakeUninitialized(size);
« no previous file with comments | « src/image/SkImage_Gpu.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698