| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 The Android Open Source Project | 2 * Copyright 2012 The Android Open Source Project |
| 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 "SkMatrixConvolutionImageFilter.h" | 8 #include "SkMatrixConvolutionImageFilter.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 // FIXME: This should be refactored to SkImageFilterUtils for | 231 // FIXME: This should be refactored to SkImageFilterUtils for |
| 232 // use by other filters. For now, we assume the input is always | 232 // use by other filters. For now, we assume the input is always |
| 233 // premultiplied and unpremultiply it | 233 // premultiplied and unpremultiply it |
| 234 static SkBitmap unpremultiplyBitmap(const SkBitmap& src) | 234 static SkBitmap unpremultiplyBitmap(const SkBitmap& src) |
| 235 { | 235 { |
| 236 SkAutoLockPixels alp(src); | 236 SkAutoLockPixels alp(src); |
| 237 if (!src.getPixels()) { | 237 if (!src.getPixels()) { |
| 238 return SkBitmap(); | 238 return SkBitmap(); |
| 239 } | 239 } |
| 240 SkBitmap result; | 240 SkBitmap result; |
| 241 result.setConfig(src.config(), src.width(), src.height()); | 241 if (!result.allocPixels(src.info())) { |
| 242 result.allocPixels(); | |
| 243 if (!result.getPixels()) { | |
| 244 return SkBitmap(); | 242 return SkBitmap(); |
| 245 } | 243 } |
| 246 for (int y = 0; y < src.height(); ++y) { | 244 for (int y = 0; y < src.height(); ++y) { |
| 247 const uint32_t* srcRow = src.getAddr32(0, y); | 245 const uint32_t* srcRow = src.getAddr32(0, y); |
| 248 uint32_t* dstRow = result.getAddr32(0, y); | 246 uint32_t* dstRow = result.getAddr32(0, y); |
| 249 for (int x = 0; x < src.width(); ++x) { | 247 for (int x = 0; x < src.width(); ++x) { |
| 250 dstRow[x] = SkUnPreMultiply::PMColorToColor(srcRow[x]); | 248 dstRow[x] = SkUnPreMultiply::PMColorToColor(srcRow[x]); |
| 251 } | 249 } |
| 252 } | 250 } |
| 253 return result; | 251 return result; |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 fBias, | 677 fBias, |
| 680 fKernelOffset, | 678 fKernelOffset, |
| 681 fTileMode, | 679 fTileMode, |
| 682 fConvolveAlpha); | 680 fConvolveAlpha); |
| 683 return true; | 681 return true; |
| 684 } | 682 } |
| 685 | 683 |
| 686 /////////////////////////////////////////////////////////////////////////////// | 684 /////////////////////////////////////////////////////////////////////////////// |
| 687 | 685 |
| 688 #endif | 686 #endif |
| OLD | NEW |