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

Unified Diff: src/image/SkImage_Gpu.cpp

Issue 2250663002: Add alphaType() to SkImage (Closed) Base URL: https://skia.googlesource.com/skia.git@special-image-alpha-type
Patch Set: Remove virtuals from SkImage, slight cleanup Created 4 years, 4 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') | src/image/SkImage_Raster.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 76f19bc31e319bf1922901e76b4009dd362a0c27..eba66f46ed91146d6faa4a8e7e67697fa6215de5 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -51,9 +51,8 @@ SkImageInfo SkImage_Gpu::onImageInfo() const {
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));
+static SkImageInfo make_info(int w, int h, SkAlphaType at, sk_sp<SkColorSpace> colorSpace) {
+ return SkImageInfo::MakeN32(w, h, at, std::move(colorSpace));
}
bool SkImage_Gpu::getROPixels(SkBitmap* dst, CachingHint chint) const {
@@ -64,7 +63,7 @@ bool SkImage_Gpu::getROPixels(SkBitmap* dst, CachingHint chint) const {
return true;
}
- if (!dst->tryAllocPixels(make_info(this->width(), this->height(), this->isOpaque(),
+ if (!dst->tryAllocPixels(make_info(this->width(), this->height(), this->alphaType(),
this->fColorSpace))) {
return false;
}
@@ -88,10 +87,6 @@ GrTexture* SkImage_Gpu::asTextureRef(GrContext* ctx, const GrTextureParams& para
return adjuster.refTextureSafeForParams(params, gammaTreatment, nullptr);
}
-bool SkImage_Gpu::isOpaque() const {
- return GrPixelConfigIsOpaque(fTexture->config()) || fAlphaType == kOpaque_SkAlphaType;
-}
-
static void apply_premul(const SkImageInfo& info, void* pixels, size_t rowBytes) {
switch (info.colorType()) {
case kRGBA_8888_SkColorType:
@@ -309,17 +304,15 @@ sk_sp<SkImage> SkImage::makeTextureImage(GrContext *context) const {
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());
+ 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, at, this->uniqueID());
+ return create_image_from_maker(&maker, this->alphaType(), this->uniqueID());
}
return nullptr;
}
@@ -445,8 +438,7 @@ size_t SkImage::getDeferredTextureImageData(const GrContextThreadSafeProxy& prox
if (!data && !this->peekPixels(nullptr)) {
return 0;
}
- SkAlphaType at = this->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAlphaType;
- info = SkImageInfo::MakeN32(scaledSize.width(), scaledSize.height(), at);
+ info = SkImageInfo::MakeN32(scaledSize.width(), scaledSize.height(), this->alphaType());
pixelSize = SkAlign8(SkAutoPixmapStorage::AllocSize(info, nullptr));
if (fillMode) {
pixmap.alloc(info);
« no previous file with comments | « src/image/SkImage_Gpu.h ('k') | src/image/SkImage_Raster.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698