| 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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 | 280 |
| 281 // Get a source bitmap encompassing this touched area. We construct the | 281 // Get a source bitmap encompassing this touched area. We construct the |
| 282 // offsets and row strides such that it looks like a new bitmap, while | 282 // offsets and row strides such that it looks like a new bitmap, while |
| 283 // referring to the old data. | 283 // referring to the old data. |
| 284 const unsigned char* sourceSubset = | 284 const unsigned char* sourceSubset = |
| 285 reinterpret_cast<const unsigned char*>(source.getPixels()); | 285 reinterpret_cast<const unsigned char*>(source.getPixels()); |
| 286 | 286 |
| 287 // Convolve into the result. | 287 // Convolve into the result. |
| 288 SkBitmap result; | 288 SkBitmap result; |
| 289 result.setConfig(SkBitmap::kARGB_8888_Config, | 289 result.setConfig(SkBitmap::kARGB_8888_Config, |
| 290 destSubset.width(), destSubset.height()); | 290 destSubset.width(), destSubset.height(), 0, |
| 291 source.alphaType()); |
| 291 result.allocPixels(allocator, NULL); | 292 result.allocPixels(allocator, NULL); |
| 292 if (!result.readyToDraw()) { | 293 if (!result.readyToDraw()) { |
| 293 return false; | 294 return false; |
| 294 } | 295 } |
| 295 | 296 |
| 296 BGRAConvolve2D(sourceSubset, static_cast<int>(source.rowBytes()), | 297 BGRAConvolve2D(sourceSubset, static_cast<int>(source.rowBytes()), |
| 297 !source.isOpaque(), filter.xFilter(), filter.yFilter(), | 298 !source.isOpaque(), filter.xFilter(), filter.yFilter(), |
| 298 static_cast<int>(result.rowBytes()), | 299 static_cast<int>(result.rowBytes()), |
| 299 static_cast<unsigned char*>(result.getPixels()), | 300 static_cast<unsigned char*>(result.getPixels()), |
| 300 convolveProcs, true); | 301 convolveProcs, true); |
| 301 | 302 |
| 302 // Preserve the "opaque" flag for use as an optimization later. | |
| 303 result.setIsOpaque(source.isOpaque()); | |
| 304 *resultPtr = result; | 303 *resultPtr = result; |
| 305 return true; | 304 return true; |
| 306 } | 305 } |
| 307 | 306 |
| 308 // static | 307 // static |
| 309 bool SkBitmapScaler::Resize(SkBitmap* resultPtr, | 308 bool SkBitmapScaler::Resize(SkBitmap* resultPtr, |
| 310 const SkBitmap& source, | 309 const SkBitmap& source, |
| 311 ResizeMethod method, | 310 ResizeMethod method, |
| 312 int destWidth, int destHeight, | 311 int destWidth, int destHeight, |
| 313 const SkConvolutionProcs& convolveProcs, | 312 const SkConvolutionProcs& convolveProcs, |
| 314 SkBitmap::Allocator* allocator) { | 313 SkBitmap::Allocator* allocator) { |
| 315 SkIRect destSubset = { 0, 0, destWidth, destHeight }; | 314 SkIRect destSubset = { 0, 0, destWidth, destHeight }; |
| 316 return Resize(resultPtr, source, method, destWidth, destHeight, destSubset, | 315 return Resize(resultPtr, source, method, destWidth, destHeight, destSubset, |
| 317 convolveProcs, allocator); | 316 convolveProcs, allocator); |
| 318 } | 317 } |
| OLD | NEW |