| OLD | NEW |
| 1 #include "DMWriteTask.h" | 1 #include "DMWriteTask.h" |
| 2 | 2 |
| 3 #include "DMUtil.h" | 3 #include "DMUtil.h" |
| 4 #include "SkCommandLineFlags.h" | 4 #include "SkCommandLineFlags.h" |
| 5 #include "SkImageDecoder.h" | 5 #include "SkImageDecoder.h" |
| 6 #include "SkImageEncoder.h" | 6 #include "SkImageEncoder.h" |
| 7 #include "SkString.h" | 7 #include "SkString.h" |
| 8 #include "SkUnPreMultiply.h" | 8 #include "SkUnPreMultiply.h" |
| 9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
| 10 | 10 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 } | 130 } |
| 131 SkASSERT(expected.config() == bitmap.config()); | 131 SkASSERT(expected.config() == bitmap.config()); |
| 132 | 132 |
| 133 // Manually unpremultiply 8888 bitmaps to match expected. | 133 // Manually unpremultiply 8888 bitmaps to match expected. |
| 134 // Their pixels are shared, concurrently even, so we must copy them. | 134 // Their pixels are shared, concurrently even, so we must copy them. |
| 135 if (info.fColorType == kPMColor_SkColorType) { | 135 if (info.fColorType == kPMColor_SkColorType) { |
| 136 SkBitmap unpremul; | 136 SkBitmap unpremul; |
| 137 unpremul.setConfig(info); | 137 unpremul.setConfig(info); |
| 138 unpremul.allocPixels(); | 138 unpremul.allocPixels(); |
| 139 | 139 |
| 140 // Unpremultiply without changing native byte order. | |
| 141 SkAutoLockPixels lockSrc(bitmap), lockDst(unpremul); | 140 SkAutoLockPixels lockSrc(bitmap), lockDst(unpremul); |
| 142 const SkPMColor* src = (SkPMColor*)bitmap.getPixels(); | 141 const SkPMColor* src = (SkPMColor*)bitmap.getPixels(); |
| 143 uint32_t* dst = (uint32_t*)unpremul.getPixels(); | 142 uint32_t* dst = (uint32_t*)unpremul.getPixels(); |
| 144 for (size_t i = 0; i < bitmap.getSize()/4; i++) { | 143 for (size_t i = 0; i < bitmap.getSize()/4; i++) { |
| 145 const U8CPU a = SkGetPackedA32(src[i]); | 144 dst[i] = SkUnPreMultiply::UnPreMultiplyPreservingByteOrder(src[i]); |
| 146 const SkUnPreMultiply::Scale s = SkUnPreMultiply::GetScale(a); | |
| 147 dst[i] = SkPackARGB32NoCheck(a, | |
| 148 SkUnPreMultiply::ApplyScale(s, SkGetPac
kedR32(src[i])), | |
| 149 SkUnPreMultiply::ApplyScale(s, SkGetPac
kedG32(src[i])), | |
| 150 SkUnPreMultiply::ApplyScale(s, SkGetPac
kedB32(src[i]))); | |
| 151 } | 145 } |
| 152 bitmap.swap(unpremul); | 146 bitmap.swap(unpremul); |
| 153 } | 147 } |
| 154 | 148 |
| 155 return BitmapsEqual(expected, bitmap); | 149 return BitmapsEqual(expected, bitmap); |
| 156 } | 150 } |
| 157 | 151 |
| 158 } // namespace DM | 152 } // namespace DM |
| OLD | NEW |