diff options
author | 2016-07-22 06:26:11 -0700 | |
---|---|---|
committer | 2016-07-22 06:26:11 -0700 | |
commit | 396fcdba14a0101ed43dcc3863585bf50c4ed6cc (patch) | |
tree | 2aaf20c22567931dd16dbe7f1779c0709d2bc62e /src/image | |
parent | a5ba329c81dd6e21f8d610b56416d9f45259fa42 (diff) |
Cleanup of code that converts from GPU-backed resources to SkImageInfo
Functions like GrMakeInfoFromTexture encouraged incorrect code to be
written. Similarly, the ability to construct an info from any GrSurface
was never going to be correct. Luckily, the only client of that had all
of the correct parameters much higher on the stack (and dictated or
replaced most of the properties of the returned info anyway).
With this, I can finally remove the color space as an output of the
pixel config -> color type conversion, which was never going to be
correct.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2173513002
Review-Url: https://codereview.chromium.org/2173513002
Diffstat (limited to 'src/image')
-rw-r--r-- | src/image/SkImage_Gpu.cpp | 19 | ||||
-rw-r--r-- | src/image/SkImage_Gpu.h | 5 |
2 files changed, 11 insertions, 13 deletions
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index fa697cd4b9..c331a295ce 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); +} + 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(); size_t rowBytes = info.minRowBytes(); size_t size = info.getSafeSize(rowBytes); auto data = SkData::MakeUninitialized(size); diff --git a/src/image/SkImage_Gpu.h b/src/image/SkImage_Gpu.h index 0e9169d8d0..5faaa7526b 100644 --- a/src/image/SkImage_Gpu.h +++ b/src/image/SkImage_Gpu.h @@ -27,10 +27,7 @@ public: SkBudgeted); ~SkImage_Gpu() override; - SkImageInfo onImageInfo() const override { - return GrMakeInfoFromTexture(fTexture, fTexture->width(), fTexture->height(), isOpaque(), - fColorSpace); - } + SkImageInfo onImageInfo() const override; void applyBudgetDecision() const { if (SkBudgeted::kYes == fBudgeted) { |