OLD | NEW |
1 // Copyright (c) 2008, Google Inc. | 1 // Copyright (c) 2008, Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
(...skipping 15 matching lines...) Expand all Loading... |
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | 29 |
30 #include "config.h" | 30 #include "config.h" |
31 | 31 |
32 #include "AffineTransform.h" | 32 #include "AffineTransform.h" |
33 #include "BitmapImage.h" | 33 #include "BitmapImage.h" |
34 #include "BitmapImageSingleFrameSkia.h" | 34 #include "BitmapImageSingleFrameSkia.h" |
35 #include "ChromiumBridge.h" | 35 #include "ChromiumBridge.h" |
| 36 #include "FloatConversion.h" |
36 #include "FloatRect.h" | 37 #include "FloatRect.h" |
37 #include "GraphicsContext.h" | 38 #include "GraphicsContext.h" |
38 #include "Logging.h" | 39 #include "Logging.h" |
39 #include "NativeImageSkia.h" | 40 #include "NativeImageSkia.h" |
40 #include "NotImplemented.h" | 41 #include "NotImplemented.h" |
41 #include "PlatformContextSkia.h" | 42 #include "PlatformContextSkia.h" |
42 #include "PlatformString.h" | 43 #include "PlatformString.h" |
43 #include "SkiaUtils.h" | 44 #include "SkiaUtils.h" |
44 #include "SkShader.h" | 45 #include "SkShader.h" |
45 | 46 |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 } else { | 365 } else { |
365 // No need to do nice resampling. | 366 // No need to do nice resampling. |
366 shader = SkShader::CreateBitmapShader( | 367 shader = SkShader::CreateBitmapShader( |
367 src_subset, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode); | 368 src_subset, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode); |
368 } | 369 } |
369 | 370 |
370 // We also need to translate it such that the origin of the pattern is the | 371 // We also need to translate it such that the origin of the pattern is the |
371 // origin of the destination rect, which is what WebKit expects. Skia uses | 372 // origin of the destination rect, which is what WebKit expects. Skia uses |
372 // the coordinate system origin as the base for the patter. If WebKit wants | 373 // the coordinate system origin as the base for the patter. If WebKit wants |
373 // a shifted image, it will shift it from there using the patternTransform. | 374 // a shifted image, it will shift it from there using the patternTransform. |
374 matrix.postTranslate(SkFloatToScalar(phase.x()), | 375 float adjustedX = phase.x() + floatSrcRect.x() * |
375 SkFloatToScalar(phase.y())); | 376 narrowPrecisionToFloat(patternTransform.a()); |
| 377 float adjustedY = phase.y() + floatSrcRect.y() * |
| 378 narrowPrecisionToFloat(patternTransform.d()); |
| 379 matrix.postTranslate(SkFloatToScalar(adjustedX), |
| 380 SkFloatToScalar(adjustedY)); |
376 shader->setLocalMatrix(matrix); | 381 shader->setLocalMatrix(matrix); |
377 | 382 |
378 SkPaint paint; | 383 SkPaint paint; |
379 paint.setShader(shader)->unref(); | 384 paint.setShader(shader)->unref(); |
380 paint.setPorterDuffXfermode(WebCoreCompositeToSkiaComposite(compositeOp)); | 385 paint.setPorterDuffXfermode(WebCoreCompositeToSkiaComposite(compositeOp)); |
381 paint.setFilterBitmap(resampling == RESAMPLE_LINEAR); | 386 paint.setFilterBitmap(resampling == RESAMPLE_LINEAR); |
382 | 387 |
383 context->platformContext()->paintSkPaint(destRect, paint); | 388 context->platformContext()->paintSkPaint(destRect, paint); |
384 } | 389 } |
385 | 390 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 PassRefPtr<BitmapImageSingleFrameSkia> BitmapImageSingleFrameSkia::create( | 452 PassRefPtr<BitmapImageSingleFrameSkia> BitmapImageSingleFrameSkia::create( |
448 const SkBitmap& bitmap) | 453 const SkBitmap& bitmap) |
449 { | 454 { |
450 RefPtr<BitmapImageSingleFrameSkia> image(new BitmapImageSingleFrameSkia()); | 455 RefPtr<BitmapImageSingleFrameSkia> image(new BitmapImageSingleFrameSkia()); |
451 if (!bitmap.copyTo(&image->m_nativeImage, bitmap.config())) | 456 if (!bitmap.copyTo(&image->m_nativeImage, bitmap.config())) |
452 return 0; | 457 return 0; |
453 return image.release(); | 458 return image.release(); |
454 } | 459 } |
455 | 460 |
456 } // namespace WebCore | 461 } // namespace WebCore |
OLD | NEW |