| 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 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 // Ensure that the ResizeMethod enumeration is sound. | 473 // Ensure that the ResizeMethod enumeration is sound. |
| 474 SkASSERT(((RESIZE_FIRST_QUALITY_METHOD <= method) && | 474 SkASSERT(((RESIZE_FIRST_QUALITY_METHOD <= method) && |
| 475 (method <= RESIZE_LAST_QUALITY_METHOD)) || | 475 (method <= RESIZE_LAST_QUALITY_METHOD)) || |
| 476 ((RESIZE_FIRST_ALGORITHM_METHOD <= method) && | 476 ((RESIZE_FIRST_ALGORITHM_METHOD <= method) && |
| 477 (method <= RESIZE_LAST_ALGORITHM_METHOD))); | 477 (method <= RESIZE_LAST_ALGORITHM_METHOD))); |
| 478 | 478 |
| 479 // Time how long this takes to see if it's a problem for users. | 479 // Time how long this takes to see if it's a problem for users. |
| 480 base::TimeTicks resize_start = base::TimeTicks::Now(); | 480 base::TimeTicks resize_start = base::TimeTicks::Now(); |
| 481 | 481 |
| 482 SkIRect dest = { 0, 0, dest_width, dest_height }; | 482 SkIRect dest = { 0, 0, dest_width, dest_height }; |
| 483 DCHECK(dest.contains(dest_subset)) << | 483 DCHECK(dest.contains(dest_subset)) |
| 484 "The supplied subset does not fall within the destination image."; | 484 << "The supplied subset does not fall within the destination image: " |
| 485 << dest_width << "x" << dest_height << " does not contain " |
| 486 << dest.width() << "x" << dest.height() |
| 487 << "+" << dest.x() << "+" << dest.y(); |
| 485 | 488 |
| 486 // If the size of source or destination is 0, i.e. 0x0, 0xN or Nx0, just | 489 // If the size of source or destination is 0, i.e. 0x0, 0xN or Nx0, just |
| 487 // return empty. | 490 // return empty. |
| 488 if (source.width() < 1 || source.height() < 1 || | 491 if (source.width() < 1 || source.height() < 1 || |
| 489 dest_width < 1 || dest_height < 1) | 492 dest_width < 1 || dest_height < 1) |
| 490 return SkBitmap(); | 493 return SkBitmap(); |
| 491 | 494 |
| 492 method = ResizeMethodToAlgorithmMethod(method); | 495 method = ResizeMethodToAlgorithmMethod(method); |
| 493 // Check that we deal with an "algorithm methods" from this point onward. | 496 // Check that we deal with an "algorithm methods" from this point onward. |
| 494 SkASSERT((ImageOperations::RESIZE_FIRST_ALGORITHM_METHOD <= method) && | 497 SkASSERT((ImageOperations::RESIZE_FIRST_ALGORITHM_METHOD <= method) && |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 SkBitmap ImageOperations::Resize(const SkBitmap& source, | 534 SkBitmap ImageOperations::Resize(const SkBitmap& source, |
| 532 ResizeMethod method, | 535 ResizeMethod method, |
| 533 int dest_width, int dest_height, | 536 int dest_width, int dest_height, |
| 534 SkBitmap::Allocator* allocator) { | 537 SkBitmap::Allocator* allocator) { |
| 535 SkIRect dest_subset = { 0, 0, dest_width, dest_height }; | 538 SkIRect dest_subset = { 0, 0, dest_width, dest_height }; |
| 536 return Resize(source, method, dest_width, dest_height, dest_subset, | 539 return Resize(source, method, dest_width, dest_height, dest_subset, |
| 537 allocator); | 540 allocator); |
| 538 } | 541 } |
| 539 | 542 |
| 540 } // namespace skia | 543 } // namespace skia |
| OLD | NEW |