| OLD | NEW |
| 1 #include "SkBitmapScaler.h" | 1 #include "SkBitmapScaler.h" |
| 2 #include "SkBitmapFilter.h" | 2 #include "SkBitmapFilter.h" |
| 3 #include "SkRect.h" | 3 #include "SkRect.h" |
| 4 #include "SkTArray.h" | 4 #include "SkTArray.h" |
| 5 #include "SkErrorInternals.h" | 5 #include "SkErrorInternals.h" |
| 6 #include "SkConvolver.h" | 6 #include "SkConvolver.h" |
| 7 | 7 |
| 8 // SkResizeFilter --------------------------------------------------------------
-- | 8 // SkResizeFilter --------------------------------------------------------------
-- |
| 9 | 9 |
| 10 // Encapsulates computation and storage of the filters required for one complete | 10 // Encapsulates computation and storage of the filters required for one complete |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 } | 82 } |
| 83 | 83 |
| 84 | 84 |
| 85 float scaleX = static_cast<float>(destWidth) / | 85 float scaleX = static_cast<float>(destWidth) / |
| 86 static_cast<float>(srcFullWidth); | 86 static_cast<float>(srcFullWidth); |
| 87 float scaleY = static_cast<float>(destHeight) / | 87 float scaleY = static_cast<float>(destHeight) / |
| 88 static_cast<float>(srcFullHeight); | 88 static_cast<float>(srcFullHeight); |
| 89 | 89 |
| 90 this->computeFilters(srcFullWidth, destSubset.fLeft, destSubset.width(), | 90 this->computeFilters(srcFullWidth, destSubset.fLeft, destSubset.width(), |
| 91 scaleX, &fXFilter, convolveProcs); | 91 scaleX, &fXFilter, convolveProcs); |
| 92 this->computeFilters(srcFullHeight, destSubset.fTop, destSubset.height(), | 92 if (srcFullWidth == srcFullHeight && |
| 93 scaleY, &fYFilter, convolveProcs); | 93 destSubset.fLeft == destSubset.fTop && |
| 94 destSubset.width() == destSubset.height()&& |
| 95 scaleX == scaleY) { |
| 96 fYFilter = fXFilter; |
| 97 } else { |
| 98 this->computeFilters(srcFullHeight, destSubset.fTop, destSubset.height()
, |
| 99 scaleY, &fYFilter, convolveProcs); |
| 100 } |
| 94 } | 101 } |
| 95 | 102 |
| 96 // TODO(egouriou): Take advantage of periods in the convolution. | 103 // TODO(egouriou): Take advantage of periods in the convolution. |
| 97 // Practical resizing filters are periodic outside of the border area. | 104 // Practical resizing filters are periodic outside of the border area. |
| 98 // For Lanczos, a scaling by a (reduced) factor of p/q (q pixels in the | 105 // For Lanczos, a scaling by a (reduced) factor of p/q (q pixels in the |
| 99 // source become p pixels in the destination) will have a period of p. | 106 // source become p pixels in the destination) will have a period of p. |
| 100 // A nice consequence is a period of 1 when downscaling by an integral | 107 // A nice consequence is a period of 1 when downscaling by an integral |
| 101 // factor. Downscaling from typical display resolutions is also bound | 108 // factor. Downscaling from typical display resolutions is also bound |
| 102 // to produce interesting periods as those are chosen to have multiple | 109 // to produce interesting periods as those are chosen to have multiple |
| 103 // small factors. | 110 // small factors. |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 bool SkBitmapScaler::Resize(SkBitmap* resultPtr, | 321 bool SkBitmapScaler::Resize(SkBitmap* resultPtr, |
| 315 const SkBitmap& source, | 322 const SkBitmap& source, |
| 316 ResizeMethod method, | 323 ResizeMethod method, |
| 317 int destWidth, int destHeight, | 324 int destWidth, int destHeight, |
| 318 const SkConvolutionProcs& convolveProcs, | 325 const SkConvolutionProcs& convolveProcs, |
| 319 SkBitmap::Allocator* allocator) { | 326 SkBitmap::Allocator* allocator) { |
| 320 SkIRect destSubset = { 0, 0, destWidth, destHeight }; | 327 SkIRect destSubset = { 0, 0, destWidth, destHeight }; |
| 321 return Resize(resultPtr, source, method, destWidth, destHeight, destSubset, | 328 return Resize(resultPtr, source, method, destWidth, destHeight, destSubset, |
| 322 convolveProcs, allocator); | 329 convolveProcs, allocator); |
| 323 } | 330 } |
| OLD | NEW |