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 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 // return empty. | 353 // return empty. |
354 if (source.width() < 1 || source.height() < 1 || | 354 if (source.width() < 1 || source.height() < 1 || |
355 dest_width < 1 || dest_height < 1) | 355 dest_width < 1 || dest_height < 1) |
356 return SkBitmap(); | 356 return SkBitmap(); |
357 | 357 |
358 method = ResizeMethodToAlgorithmMethod(method); | 358 method = ResizeMethodToAlgorithmMethod(method); |
359 // Check that we deal with an "algorithm methods" from this point onward. | 359 // Check that we deal with an "algorithm methods" from this point onward. |
360 SkASSERT((ImageOperations::RESIZE_FIRST_ALGORITHM_METHOD <= method) && | 360 SkASSERT((ImageOperations::RESIZE_FIRST_ALGORITHM_METHOD <= method) && |
361 (method <= ImageOperations::RESIZE_LAST_ALGORITHM_METHOD)); | 361 (method <= ImageOperations::RESIZE_LAST_ALGORITHM_METHOD)); |
362 | 362 |
363 SkAutoLockPixels locker(source); | |
364 if (!source.readyToDraw() || source.colorType() != kN32_SkColorType) | 363 if (!source.readyToDraw() || source.colorType() != kN32_SkColorType) |
365 return SkBitmap(); | 364 return SkBitmap(); |
366 | 365 |
367 ResizeFilter filter(method, source.width(), source.height(), | 366 ResizeFilter filter(method, source.width(), source.height(), |
368 dest_width, dest_height, dest_subset); | 367 dest_width, dest_height, dest_subset); |
369 | 368 |
370 // Get a source bitmap encompassing this touched area. We construct the | 369 // Get a source bitmap encompassing this touched area. We construct the |
371 // offsets and row strides such that it looks like a new bitmap, while | 370 // offsets and row strides such that it looks like a new bitmap, while |
372 // referring to the old data. | 371 // referring to the old data. |
373 const uint8_t* source_subset = | 372 const uint8_t* source_subset = |
(...skipping 22 matching lines...) Expand all Loading... |
396 SkBitmap ImageOperations::Resize(const SkBitmap& source, | 395 SkBitmap ImageOperations::Resize(const SkBitmap& source, |
397 ResizeMethod method, | 396 ResizeMethod method, |
398 int dest_width, int dest_height, | 397 int dest_width, int dest_height, |
399 SkBitmap::Allocator* allocator) { | 398 SkBitmap::Allocator* allocator) { |
400 SkIRect dest_subset = { 0, 0, dest_width, dest_height }; | 399 SkIRect dest_subset = { 0, 0, dest_width, dest_height }; |
401 return Resize(source, method, dest_width, dest_height, dest_subset, | 400 return Resize(source, method, dest_width, dest_height, dest_subset, |
402 allocator); | 401 allocator); |
403 } | 402 } |
404 | 403 |
405 } // namespace skia | 404 } // namespace skia |
OLD | NEW |