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

Unified Diff: src/codec/SkCodecPriv.h

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/SkCodecPriv.h
diff --git a/src/codec/SkCodecPriv.h b/src/codec/SkCodecPriv.h
index 2596787b9b7aadcf44819e23849467b137c48cc7..450457f630137c98b854be9f2ad8ad963f8c71d0 100644
--- a/src/codec/SkCodecPriv.h
+++ b/src/codec/SkCodecPriv.h
@@ -53,6 +53,35 @@ static inline bool valid_alpha(SkAlphaType dstAlpha, SkAlphaType srcAlpha) {
}
/*
+ * Most of our codecs support the same conversions:
+ * - profileType must be the same
+ * - opaque only to opaque (and 565 only if opaque)
+ * - premul to unpremul and vice versa
+ * - always support N32
+ * - otherwise match the src color type
+ */
+static bool conversion_possible(const SkImageInfo& dst, const SkImageInfo& src) {
+ if (dst.profileType() != src.profileType()) {
+ return false;
+ }
+
+ // Ensure the alpha type is valid
+ if (!valid_alpha(dst.alphaType(), src.alphaType())) {
+ return false;
+ }
+
+ // Check for supported color types
+ switch (dst.colorType()) {
+ case kN32_SkColorType:
+ return true;
+ case kRGB_565_SkColorType:
+ return src.alphaType() == kOpaque_SkAlphaType;
+ default:
+ return dst.colorType() == src.colorType();
+ }
+}
+
+/*
* If there is a color table, get a pointer to the colors, otherwise return NULL
*/
static const SkPMColor* get_color_ptr(SkColorTable* colorTable) {
« no previous file with comments | « src/codec/SkCodec.cpp ('k') | src/codec/SkCodec_libgif.cpp » ('j') | src/codec/SkSwizzler.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698