| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 case ImageOperations::RESIZE_LANCZOS3: | 153 case ImageOperations::RESIZE_LANCZOS3: |
| 154 return EvalLanczos(3, pos); | 154 return EvalLanczos(3, pos); |
| 155 default: | 155 default: |
| 156 NOTREACHED(); | 156 NOTREACHED(); |
| 157 return 0; | 157 return 0; |
| 158 } | 158 } |
| 159 } | 159 } |
| 160 | 160 |
| 161 ImageOperations::ResizeMethod method_; | 161 ImageOperations::ResizeMethod method_; |
| 162 | 162 |
| 163 // Size of the filter support on one side only in the destination space. | |
| 164 // See GetFilterSupport. | |
| 165 float x_filter_support_; | |
| 166 float y_filter_support_; | |
| 167 | |
| 168 // Subset of scaled destination bitmap to compute. | |
| 169 SkIRect out_bounds_; | |
| 170 | |
| 171 ConvolutionFilter1D x_filter_; | 163 ConvolutionFilter1D x_filter_; |
| 172 ConvolutionFilter1D y_filter_; | 164 ConvolutionFilter1D y_filter_; |
| 173 | 165 |
| 174 DISALLOW_COPY_AND_ASSIGN(ResizeFilter); | 166 DISALLOW_COPY_AND_ASSIGN(ResizeFilter); |
| 175 }; | 167 }; |
| 176 | 168 |
| 177 ResizeFilter::ResizeFilter(ImageOperations::ResizeMethod method, | 169 ResizeFilter::ResizeFilter(ImageOperations::ResizeMethod method, |
| 178 int src_full_width, int src_full_height, | 170 int src_full_width, |
| 179 int dest_width, int dest_height, | 171 int src_full_height, |
| 172 int dest_width, |
| 173 int dest_height, |
| 180 const SkIRect& dest_subset) | 174 const SkIRect& dest_subset) |
| 181 : method_(method), | 175 : method_(method) { |
| 182 out_bounds_(dest_subset) { | |
| 183 // method_ will only ever refer to an "algorithm method". | 176 // method_ will only ever refer to an "algorithm method". |
| 184 SkASSERT((ImageOperations::RESIZE_FIRST_ALGORITHM_METHOD <= method) && | 177 SkASSERT((ImageOperations::RESIZE_FIRST_ALGORITHM_METHOD <= method) && |
| 185 (method <= ImageOperations::RESIZE_LAST_ALGORITHM_METHOD)); | 178 (method <= ImageOperations::RESIZE_LAST_ALGORITHM_METHOD)); |
| 186 | 179 |
| 187 float scale_x = static_cast<float>(dest_width) / | 180 float scale_x = static_cast<float>(dest_width) / |
| 188 static_cast<float>(src_full_width); | 181 static_cast<float>(src_full_width); |
| 189 float scale_y = static_cast<float>(dest_height) / | 182 float scale_y = static_cast<float>(dest_height) / |
| 190 static_cast<float>(src_full_height); | 183 static_cast<float>(src_full_height); |
| 191 | 184 |
| 192 ComputeFilters(src_full_width, dest_subset.fLeft, dest_subset.width(), | 185 ComputeFilters(src_full_width, dest_subset.fLeft, dest_subset.width(), |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 SkBitmap ImageOperations::Resize(const SkBitmap& source, | 396 SkBitmap ImageOperations::Resize(const SkBitmap& source, |
| 404 ResizeMethod method, | 397 ResizeMethod method, |
| 405 int dest_width, int dest_height, | 398 int dest_width, int dest_height, |
| 406 SkBitmap::Allocator* allocator) { | 399 SkBitmap::Allocator* allocator) { |
| 407 SkIRect dest_subset = { 0, 0, dest_width, dest_height }; | 400 SkIRect dest_subset = { 0, 0, dest_width, dest_height }; |
| 408 return Resize(source, method, dest_width, dest_height, dest_subset, | 401 return Resize(source, method, dest_width, dest_height, dest_subset, |
| 409 allocator); | 402 allocator); |
| 410 } | 403 } |
| 411 | 404 |
| 412 } // namespace skia | 405 } // namespace skia |
| OLD | NEW |