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

Unified Diff: src/codec/SkWebpCodec.cpp

Issue 1277213002: Support more swizzles to 565 in SkCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update new 565 swizzling functions for scaling Created 5 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
Index: src/codec/SkWebpCodec.cpp
diff --git a/src/codec/SkWebpCodec.cpp b/src/codec/SkWebpCodec.cpp
index 624ff74fa0af86e24bc1aa6fa0a38938d21b3232..1f69b4f712b8a7402b15a745ca62d625ba26777b 100644
--- a/src/codec/SkWebpCodec.cpp
+++ b/src/codec/SkWebpCodec.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "SkCodecPriv.h"
#include "SkWebpCodec.h"
#include "SkTemplates.h"
@@ -81,29 +82,27 @@ SkCodec* SkWebpCodec::NewFromStream(SkStream* stream) {
return NULL;
}
-static bool conversion_possible(const SkImageInfo& dst, const SkImageInfo& src) {
+// This version is slightly different from SkCodecPriv's version of conversion_possible. It
+// supports both byte orders for 8888.
+static bool webp_conversion_possible(const SkImageInfo& dst, const SkImageInfo& src) {
if (dst.profileType() != src.profileType()) {
return false;
}
+
+ if (!valid_alpha(dst.alphaType(), src.alphaType())) {
+ return false;
+ }
+
switch (dst.colorType()) {
// Both byte orders are supported.
case kBGRA_8888_SkColorType:
case kRGBA_8888_SkColorType:
- break;
+ return true;
case kRGB_565_SkColorType:
- if (src.alphaType() == kOpaque_SkAlphaType
- && dst.alphaType() == kOpaque_SkAlphaType)
- {
- return true;
- }
+ return src.alphaType() == kOpaque_SkAlphaType;
default:
return false;
}
- if (dst.alphaType() == src.alphaType()) {
- return true;
- }
- return kPremul_SkAlphaType == dst.alphaType() &&
- kUnpremul_SkAlphaType == src.alphaType();
}
SkISize SkWebpCodec::onGetScaledDimensions(float desiredScale) const {
@@ -157,7 +156,7 @@ SkCodec::Result SkWebpCodec::onGetPixels(const SkImageInfo& dstInfo, void* dst,
return kCouldNotRewind;
}
- if (!conversion_possible(dstInfo, this->getInfo())) {
+ if (!webp_conversion_possible(dstInfo, this->getInfo())) {
return kInvalidConversion;
}
« src/codec/SkSwizzler.cpp ('K') | « src/codec/SkSwizzler.cpp ('k') | tests/CodexTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698