OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" |
11 | 11 |
12 // TODO(pkasting): skia/ext should not depend on base/! | 12 // TODO(pkasting): skia/ext should not depend on base/! |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
15 #include "base/stack_container.h" | 15 #include "base/stack_container.h" |
16 #include "base/time.h" | 16 #include "base/time.h" |
17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
18 #include "skia/ext/convolver.h" | 18 #include "skia/ext/convolver.h" |
| 19 #include "third_party/skia/include/core/SkColorPriv.h" |
19 #include "third_party/skia/include/core/SkBitmap.h" | 20 #include "third_party/skia/include/core/SkBitmap.h" |
20 #include "third_party/skia/include/core/SkRect.h" | 21 #include "third_party/skia/include/core/SkRect.h" |
21 #include "third_party/skia/include/core/SkFontHost.h" | 22 #include "third_party/skia/include/core/SkFontHost.h" |
22 #include "third_party/skia/include/core/SkColorPriv.h" | |
23 | 23 |
24 namespace skia { | 24 namespace skia { |
25 | 25 |
26 namespace { | 26 namespace { |
27 | 27 |
28 // Returns the ceiling/floor as an integer. | 28 // Returns the ceiling/floor as an integer. |
29 inline int CeilInt(float val) { | 29 inline int CeilInt(float val) { |
30 return static_cast<int>(ceil(val)); | 30 return static_cast<int>(ceil(val)); |
31 } | 31 } |
32 inline int FloorInt(float val) { | 32 inline int FloorInt(float val) { |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 // arbitrarily add this to the center of the filter array (this won't always | 309 // arbitrarily add this to the center of the filter array (this won't always |
310 // be the center of the filter function since it could get clipped on the | 310 // be the center of the filter function since it could get clipped on the |
311 // edges, but it doesn't matter enough to worry about that case). | 311 // edges, but it doesn't matter enough to worry about that case). |
312 int16 leftovers = output->FloatToFixed(1.0f) - fixed_sum; | 312 int16 leftovers = output->FloatToFixed(1.0f) - fixed_sum; |
313 fixed_filter_values[fixed_filter_values->size() / 2] += leftovers; | 313 fixed_filter_values[fixed_filter_values->size() / 2] += leftovers; |
314 | 314 |
315 // Now it's ready to go. | 315 // Now it's ready to go. |
316 output->AddFilter(src_begin, &fixed_filter_values[0], | 316 output->AddFilter(src_begin, &fixed_filter_values[0], |
317 static_cast<int>(fixed_filter_values->size())); | 317 static_cast<int>(fixed_filter_values->size())); |
318 } | 318 } |
| 319 |
| 320 output->PaddingForSIMD(8); |
319 } | 321 } |
320 | 322 |
321 ImageOperations::ResizeMethod ResizeMethodToAlgorithmMethod( | 323 ImageOperations::ResizeMethod ResizeMethodToAlgorithmMethod( |
322 ImageOperations::ResizeMethod method) { | 324 ImageOperations::ResizeMethod method) { |
323 // Convert any "Quality Method" into an "Algorithm Method" | 325 // Convert any "Quality Method" into an "Algorithm Method" |
324 if (method >= ImageOperations::RESIZE_FIRST_ALGORITHM_METHOD && | 326 if (method >= ImageOperations::RESIZE_FIRST_ALGORITHM_METHOD && |
325 method <= ImageOperations::RESIZE_LAST_ALGORITHM_METHOD) { | 327 method <= ImageOperations::RESIZE_LAST_ALGORITHM_METHOD) { |
326 return method; | 328 return method; |
327 } | 329 } |
328 // The call to ImageOperationsGtv::Resize() above took care of | 330 // The call to ImageOperationsGtv::Resize() above took care of |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 | 524 |
523 // static | 525 // static |
524 SkBitmap ImageOperations::Resize(const SkBitmap& source, | 526 SkBitmap ImageOperations::Resize(const SkBitmap& source, |
525 ResizeMethod method, | 527 ResizeMethod method, |
526 int dest_width, int dest_height) { | 528 int dest_width, int dest_height) { |
527 SkIRect dest_subset = { 0, 0, dest_width, dest_height }; | 529 SkIRect dest_subset = { 0, 0, dest_width, dest_height }; |
528 return Resize(source, method, dest_width, dest_height, dest_subset); | 530 return Resize(source, method, dest_width, dest_height, dest_subset); |
529 } | 531 } |
530 | 532 |
531 } // namespace skia | 533 } // namespace skia |
OLD | NEW |