| 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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 if (!ctx.ctm().invert(&localInverse)) { | 336 if (!ctx.ctm().invert(&localInverse)) { |
| 337 return false; | 337 return false; |
| 338 } | 338 } |
| 339 | 339 |
| 340 SkAutoLockPixels alp(src); | 340 SkAutoLockPixels alp(src); |
| 341 SkASSERT(src.getPixels()); | 341 SkASSERT(src.getPixels()); |
| 342 if (!src.getPixels() || src.width() <= 0 || src.height() <= 0) { | 342 if (!src.getPixels() || src.width() <= 0 || src.height() <= 0) { |
| 343 return false; | 343 return false; |
| 344 } | 344 } |
| 345 | 345 |
| 346 if (!dst->allocPixels(src.info())) { | 346 if (!dst->tryAllocPixels(src.info())) { |
| 347 return false; | 347 return false; |
| 348 } | 348 } |
| 349 | 349 |
| 350 U8CPU innerThreshold = (U8CPU)(fInnerThreshold * 0xFF); | 350 U8CPU innerThreshold = (U8CPU)(fInnerThreshold * 0xFF); |
| 351 U8CPU outerThreshold = (U8CPU)(fOuterThreshold * 0xFF); | 351 U8CPU outerThreshold = (U8CPU)(fOuterThreshold * 0xFF); |
| 352 SkColor* sptr = src.getAddr32(0, 0); | 352 SkColor* sptr = src.getAddr32(0, 0); |
| 353 SkColor* dptr = dst->getAddr32(0, 0); | 353 SkColor* dptr = dst->getAddr32(0, 0); |
| 354 int width = src.width(), height = src.height(); | 354 int width = src.width(), height = src.height(); |
| 355 for (int y = 0; y < height; ++y) { | 355 for (int y = 0; y < height; ++y) { |
| 356 for (int x = 0; x < width; ++x) { | 356 for (int x = 0; x < width; ++x) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 377 (U8CPU)(SkColorGetG(source) *
scale), | 377 (U8CPU)(SkColorGetG(source) *
scale), |
| 378 (U8CPU)(SkColorGetB(source) *
scale)); | 378 (U8CPU)(SkColorGetB(source) *
scale)); |
| 379 } | 379 } |
| 380 } | 380 } |
| 381 dptr[y * dst->width() + x] = output_color; | 381 dptr[y * dst->width() + x] = output_color; |
| 382 } | 382 } |
| 383 } | 383 } |
| 384 | 384 |
| 385 return true; | 385 return true; |
| 386 } | 386 } |
| OLD | NEW |