| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkImageEncoder.h" | 8 #include "SkImageEncoder_argb.h" |
| 9 |
| 9 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
| 10 #include "SkColorPriv.h" | 11 #include "SkColorPriv.h" |
| 11 #include "SkStream.h" | 12 #include "SkStream.h" |
| 12 #include "SkTemplates.h" | 13 #include "SkTemplates.h" |
| 13 | 14 |
| 14 class SkARGBImageEncoder : public SkImageEncoder { | |
| 15 protected: | |
| 16 virtual bool onEncode(SkWStream* stream, const SkBitmap& bm, int quality) SK
_OVERRIDE; | |
| 17 | |
| 18 private: | |
| 19 typedef SkImageEncoder INHERITED; | |
| 20 }; | |
| 21 | 15 |
| 22 typedef void (*ScanlineImporter)(const uint8_t* in, uint8_t* argb, int width, | 16 typedef void (*ScanlineImporter)(const uint8_t* in, uint8_t* argb, int width, |
| 23 const SkPMColor* SK_RESTRICT ctable); | 17 const SkPMColor* SK_RESTRICT ctable); |
| 24 | 18 |
| 25 static void ARGB_8888_To_ARGB(const uint8_t* in, uint8_t* argb, int width, const
SkPMColor*) { | 19 static void ARGB_8888_To_ARGB(const uint8_t* in, uint8_t* argb, int width, const
SkPMColor*) { |
| 26 const uint32_t* SK_RESTRICT src = (const uint32_t*)in; | 20 const uint32_t* SK_RESTRICT src = (const uint32_t*)in; |
| 27 for (int i = 0; i < width; ++i) { | 21 for (int i = 0; i < width; ++i) { |
| 28 const uint32_t c = *src++; | 22 const uint32_t c = *src++; |
| 29 argb[0] = SkGetPackedA32(c); | 23 argb[0] = SkGetPackedA32(c); |
| 30 argb[1] = SkGetPackedR32(c); | 24 argb[1] = SkGetPackedR32(c); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 const int argbStride = bitmap.width() * 4; | 98 const int argbStride = bitmap.width() * 4; |
| 105 SkAutoTDeleteArray<uint8_t> ada(new uint8_t[argbStride]); | 99 SkAutoTDeleteArray<uint8_t> ada(new uint8_t[argbStride]); |
| 106 uint8_t* argb = ada.get(); | 100 uint8_t* argb = ada.get(); |
| 107 for (int y = 0; y < bitmap.height(); ++y) { | 101 for (int y = 0; y < bitmap.height(); ++y) { |
| 108 scanline_import(src + y * bitmap.rowBytes(), argb, bitmap.width(), color
s); | 102 scanline_import(src + y * bitmap.rowBytes(), argb, bitmap.width(), color
s); |
| 109 stream->write(argb, argbStride); | 103 stream->write(argb, argbStride); |
| 110 } | 104 } |
| 111 | 105 |
| 112 return true; | 106 return true; |
| 113 } | 107 } |
| 114 | |
| 115 | |
| 116 /////////////////////////////////////////////////////////////////////////////// | |
| 117 DEFINE_ENCODER_CREATOR(ARGBImageEncoder); | |
| 118 /////////////////////////////////////////////////////////////////////////////// | |
| OLD | NEW |