| 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 "SkAlphaThresholdFilter.h" | 8 #include "SkAlphaThresholdFilter.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkReadBuffer.h" | 10 #include "SkReadBuffer.h" |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 if (!ctx.ctm().invert(&localInverse)) { | 316 if (!ctx.ctm().invert(&localInverse)) { |
| 317 return false; | 317 return false; |
| 318 } | 318 } |
| 319 | 319 |
| 320 SkAutoLockPixels alp(src); | 320 SkAutoLockPixels alp(src); |
| 321 SkASSERT(src.getPixels()); | 321 SkASSERT(src.getPixels()); |
| 322 if (!src.getPixels() || src.width() <= 0 || src.height() <= 0) { | 322 if (!src.getPixels() || src.width() <= 0 || src.height() <= 0) { |
| 323 return false; | 323 return false; |
| 324 } | 324 } |
| 325 | 325 |
| 326 dst->setConfig(src.config(), src.width(), src.height()); | 326 if (!dst->allocPixels(src.info())) { |
| 327 if (!dst->allocPixels()) { | |
| 328 return false; | 327 return false; |
| 329 } | 328 } |
| 330 | 329 |
| 331 U8CPU innerThreshold = (U8CPU)(fInnerThreshold * 0xFF); | 330 U8CPU innerThreshold = (U8CPU)(fInnerThreshold * 0xFF); |
| 332 U8CPU outerThreshold = (U8CPU)(fOuterThreshold * 0xFF); | 331 U8CPU outerThreshold = (U8CPU)(fOuterThreshold * 0xFF); |
| 333 SkColor* sptr = src.getAddr32(0, 0); | 332 SkColor* sptr = src.getAddr32(0, 0); |
| 334 SkColor* dptr = dst->getAddr32(0, 0); | 333 SkColor* dptr = dst->getAddr32(0, 0); |
| 335 int width = src.width(), height = src.height(); | 334 int width = src.width(), height = src.height(); |
| 336 for (int y = 0; y < height; ++y) { | 335 for (int y = 0; y < height; ++y) { |
| 337 for (int x = 0; x < width; ++x) { | 336 for (int x = 0; x < width; ++x) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 358 (U8CPU)(SkColorGetG(source) *
scale), | 357 (U8CPU)(SkColorGetG(source) *
scale), |
| 359 (U8CPU)(SkColorGetB(source) *
scale)); | 358 (U8CPU)(SkColorGetB(source) *
scale)); |
| 360 } | 359 } |
| 361 } | 360 } |
| 362 dptr[y * dst->width() + x] = output_color; | 361 dptr[y * dst->width() + x] = output_color; |
| 363 } | 362 } |
| 364 } | 363 } |
| 365 | 364 |
| 366 return true; | 365 return true; |
| 367 } | 366 } |
| OLD | NEW |