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

Unified Diff: src/codec/SkWebpCodec.cpp

Issue 1895383002: Revert of Add SkEncodedInfo to report properties of encoded image data (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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/codec/SkWebpCodec.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkWebpCodec.cpp
diff --git a/src/codec/SkWebpCodec.cpp b/src/codec/SkWebpCodec.cpp
index e40c3f237792fa38454f72c1fb2d5f2e150ae672..77af8e5e8f6fbf642e6de9678b5753de6d5f64df 100644
--- a/src/codec/SkWebpCodec.cpp
+++ b/src/codec/SkWebpCodec.cpp
@@ -31,7 +31,7 @@
// Parse headers of RIFF container, and check for valid Webp (VP8) content.
// NOTE: This calls peek instead of read, since onGetPixels will need these
// bytes again.
-static bool webp_parse_header(SkStream* stream, int* width, int* height, SkEncodedInfo* info) {
+static bool webp_parse_header(SkStream* stream, SkImageInfo* info) {
unsigned char buffer[WEBP_VP8_HEADER_SIZE];
SkASSERT(WEBP_VP8_HEADER_SIZE <= SkCodec::MinBufferedBytesNeeded());
@@ -62,55 +62,22 @@
}
if (info) {
- SkEncodedInfo::Color color;
- SkEncodedInfo::Alpha alpha;
- switch (features.format) {
- case 0:
- // This indicates a "mixed" format. We would see this for
- // animated webps or for webps encoded in multiple fragments.
- // I believe that this is a rare case.
- // We could also guess kYUV here, but I think it makes more
- // sense to guess kBGRA which is likely closer to the final
- // output. Otherwise, we might end up converting
- // BGRA->YUVA->BGRA.
- color = SkEncodedInfo::kBGRA_Color;
- alpha = SkEncodedInfo::kUnpremul_Alpha;
- break;
- case 1:
- // This is the lossy format (YUV).
- if (SkToBool(features.has_alpha)) {
- color = SkEncodedInfo::kYUVA_Color;
- alpha = SkEncodedInfo::kUnpremul_Alpha;
- } else {
- color = SkEncodedInfo::kYUV_Color;
- alpha = SkEncodedInfo::kOpaque_Alpha;
- }
- break;
- case 2:
- // This is the lossless format (BGRA).
- // FIXME: Should we check the has_alpha flag here? It looks
- // like the image is encoded with an alpha channel
- // regardless of whether or not the alpha flag is set.
- color = SkEncodedInfo::kBGRA_Color;
- alpha = SkEncodedInfo::kUnpremul_Alpha;
- break;
- default:
- return false;
- }
-
- *width = features.width;
- *height = features.height;
- *info = SkEncodedInfo::Make(color, alpha, 8);
+ // FIXME: Is N32 the right type?
+ // Is unpremul the right type? Clients of SkCodec may assume it's the
+ // best type, when Skia currently cannot draw unpremul (and raster is faster
+ // with premul).
+ *info = SkImageInfo::Make(features.width, features.height, kN32_SkColorType,
+ SkToBool(features.has_alpha) ? kUnpremul_SkAlphaType
+ : kOpaque_SkAlphaType);
}
return true;
}
SkCodec* SkWebpCodec::NewFromStream(SkStream* stream) {
SkAutoTDelete<SkStream> streamDeleter(stream);
- int width, height;
- SkEncodedInfo info;
- if (webp_parse_header(stream, &width, &height, &info)) {
- return new SkWebpCodec(width, height, info, streamDeleter.release());
+ SkImageInfo info;
+ if (webp_parse_header(stream, &info)) {
+ return new SkWebpCodec(info, streamDeleter.release());
}
return nullptr;
}
@@ -285,7 +252,7 @@
}
}
-SkWebpCodec::SkWebpCodec(int width, int height, const SkEncodedInfo& info, SkStream* stream)
+SkWebpCodec::SkWebpCodec(const SkImageInfo& info, SkStream* stream)
// The spec says an unmarked image is sRGB, so we return that space here.
// TODO: Add support for parsing ICC profiles from webps.
- : INHERITED(width, height, info, stream, SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named)) {}
+ : INHERITED(info, stream, SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named)) {}
« no previous file with comments | « src/codec/SkWebpCodec.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698