| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #define _USE_MATH_DEFINES | 5 #define _USE_MATH_DEFINES |
| 6 #include <algorithm> | 6 #include <algorithm> |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "skia/ext/image_operations.h" | 10 #include "skia/ext/image_operations.h" |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 if (source.width() < 1 || source.height() < 1 || | 488 if (source.width() < 1 || source.height() < 1 || |
| 489 dest_width < 1 || dest_height < 1) | 489 dest_width < 1 || dest_height < 1) |
| 490 return SkBitmap(); | 490 return SkBitmap(); |
| 491 | 491 |
| 492 method = ResizeMethodToAlgorithmMethod(method); | 492 method = ResizeMethodToAlgorithmMethod(method); |
| 493 // Check that we deal with an "algorithm methods" from this point onward. | 493 // Check that we deal with an "algorithm methods" from this point onward. |
| 494 SkASSERT((ImageOperations::RESIZE_FIRST_ALGORITHM_METHOD <= method) && | 494 SkASSERT((ImageOperations::RESIZE_FIRST_ALGORITHM_METHOD <= method) && |
| 495 (method <= ImageOperations::RESIZE_LAST_ALGORITHM_METHOD)); | 495 (method <= ImageOperations::RESIZE_LAST_ALGORITHM_METHOD)); |
| 496 | 496 |
| 497 SkAutoLockPixels locker(source); | 497 SkAutoLockPixels locker(source); |
| 498 if (!source.readyToDraw() || source.config() != SkBitmap::kARGB_8888_Config) | 498 if (!source.readyToDraw() || source.colorType() != kN32_SkColorType) |
| 499 return SkBitmap(); | 499 return SkBitmap(); |
| 500 | 500 |
| 501 ResizeFilter filter(method, source.width(), source.height(), | 501 ResizeFilter filter(method, source.width(), source.height(), |
| 502 dest_width, dest_height, dest_subset); | 502 dest_width, dest_height, dest_subset); |
| 503 | 503 |
| 504 // Get a source bitmap encompassing this touched area. We construct the | 504 // Get a source bitmap encompassing this touched area. We construct the |
| 505 // offsets and row strides such that it looks like a new bitmap, while | 505 // offsets and row strides such that it looks like a new bitmap, while |
| 506 // referring to the old data. | 506 // referring to the old data. |
| 507 const uint8* source_subset = | 507 const uint8* source_subset = |
| 508 reinterpret_cast<const uint8*>(source.getPixels()); | 508 reinterpret_cast<const uint8*>(source.getPixels()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 530 SkBitmap ImageOperations::Resize(const SkBitmap& source, | 530 SkBitmap ImageOperations::Resize(const SkBitmap& source, |
| 531 ResizeMethod method, | 531 ResizeMethod method, |
| 532 int dest_width, int dest_height, | 532 int dest_width, int dest_height, |
| 533 SkBitmap::Allocator* allocator) { | 533 SkBitmap::Allocator* allocator) { |
| 534 SkIRect dest_subset = { 0, 0, dest_width, dest_height }; | 534 SkIRect dest_subset = { 0, 0, dest_width, dest_height }; |
| 535 return Resize(source, method, dest_width, dest_height, dest_subset, | 535 return Resize(source, method, dest_width, dest_height, dest_subset, |
| 536 allocator); | 536 allocator); |
| 537 } | 537 } |
| 538 | 538 |
| 539 } // namespace skia | 539 } // namespace skia |
| OLD | NEW |