OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010, The Android Open Source Project | 2 * Copyright 2010, The Android Open Source Project |
3 * | 3 * |
4 * Licensed under the Apache License, Version 2.0 (the "License"); | 4 * Licensed under the Apache License, Version 2.0 (the "License"); |
5 * you may not use this file except in compliance with the License. | 5 * you may not use this file except in compliance with the License. |
6 * You may obtain a copy of the License at | 6 * You may obtain a copy of the License at |
7 * | 7 * |
8 * http://www.apache.org/licenses/LICENSE-2.0 | 8 * http://www.apache.org/licenses/LICENSE-2.0 |
9 * | 9 * |
10 * Unless required by applicable law or agreed to in writing, software | 10 * Unless required by applicable law or agreed to in writing, software |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 static bool return_false(const SkBitmap& bm, const char msg[]) { | 166 static bool return_false(const SkBitmap& bm, const char msg[]) { |
167 SkDEBUGF(("libwebp error %s [%d %d]", msg, bm.width(), bm.height())); | 167 SkDEBUGF(("libwebp error %s [%d %d]", msg, bm.width(), bm.height())); |
168 return false; // must always return false | 168 return false; // must always return false |
169 } | 169 } |
170 | 170 |
171 static WEBP_CSP_MODE webp_decode_mode(const SkBitmap* decodedBitmap, bool premul
tiply) { | 171 static WEBP_CSP_MODE webp_decode_mode(const SkBitmap* decodedBitmap, bool premul
tiply) { |
172 WEBP_CSP_MODE mode = MODE_LAST; | 172 WEBP_CSP_MODE mode = MODE_LAST; |
173 SkBitmap::Config config = decodedBitmap->config(); | 173 SkBitmap::Config config = decodedBitmap->config(); |
174 | 174 |
175 if (config == SkBitmap::kARGB_8888_Config) { | 175 if (config == SkBitmap::kARGB_8888_Config) { |
176 mode = premultiply ? MODE_rgbA : MODE_RGBA; | 176 #if SK_PMCOLOR_BYTE_ORDER(B,G,R,A) |
| 177 mode = premultiply ? MODE_bgrA : MODE_BGRA; |
| 178 #elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A) |
| 179 mode = premultiply ? MODE_rgbA : MODE_RGBA; |
| 180 #else |
| 181 #error "Skia uses BGRA or RGBA byte order" |
| 182 #endif |
177 } else if (config == SkBitmap::kARGB_4444_Config) { | 183 } else if (config == SkBitmap::kARGB_4444_Config) { |
178 mode = premultiply ? MODE_rgbA_4444 : MODE_RGBA_4444; | 184 mode = premultiply ? MODE_rgbA_4444 : MODE_RGBA_4444; |
179 } else if (config == SkBitmap::kRGB_565_Config) { | 185 } else if (config == SkBitmap::kRGB_565_Config) { |
180 mode = MODE_RGB_565; | 186 mode = MODE_RGB_565; |
181 } | 187 } |
182 SkASSERT(MODE_LAST != mode); | 188 SkASSERT(MODE_LAST != mode); |
183 return mode; | 189 return mode; |
184 } | 190 } |
185 | 191 |
186 // Incremental WebP image decoding. Reads input buffer of 64K size iteratively | 192 // Incremental WebP image decoding. Reads input buffer of 64K size iteratively |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 return SkImageDecoder::kUnknown_Format; | 596 return SkImageDecoder::kUnknown_Format; |
591 } | 597 } |
592 | 598 |
593 static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) { | 599 static SkImageEncoder* sk_libwebp_efactory(SkImageEncoder::Type t) { |
594 return (SkImageEncoder::kWEBP_Type == t) ? SkNEW(SkWEBPImageEncoder) : NUL
L; | 600 return (SkImageEncoder::kWEBP_Type == t) ? SkNEW(SkWEBPImageEncoder) : NUL
L; |
595 } | 601 } |
596 | 602 |
597 static SkImageDecoder_DecodeReg gDReg(sk_libwebp_dfactory); | 603 static SkImageDecoder_DecodeReg gDReg(sk_libwebp_dfactory); |
598 static SkImageDecoder_FormatReg gFormatReg(get_format_webp); | 604 static SkImageDecoder_FormatReg gFormatReg(get_format_webp); |
599 static SkImageEncoder_EncodeReg gEReg(sk_libwebp_efactory); | 605 static SkImageEncoder_EncodeReg gEReg(sk_libwebp_efactory); |
OLD | NEW |