| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Eric Seidel <eric@webkit.org> | 2 * Copyright (C) 2006 Eric Seidel <eric@webkit.org> |
| 3 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. | 3 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. |
| 4 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 4 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 paint.setXfermodeMode(compositeOp); | 297 paint.setXfermodeMode(compositeOp); |
| 298 paint.setColorFilter(sk_ref_sp(context.colorFilter())); | 298 paint.setColorFilter(sk_ref_sp(context.colorFilter())); |
| 299 context.drawRect(dstRect, paint); | 299 context.drawRect(dstRect, paint); |
| 300 } | 300 } |
| 301 | 301 |
| 302 PassRefPtr<SkImage> SVGImage::imageForCurrentFrameForContainer(const KURL& url,
const FloatSize& containerSize) | 302 PassRefPtr<SkImage> SVGImage::imageForCurrentFrameForContainer(const KURL& url,
const FloatSize& containerSize) |
| 303 { | 303 { |
| 304 if (!m_page) | 304 if (!m_page) |
| 305 return nullptr; | 305 return nullptr; |
| 306 | 306 |
| 307 const FloatRect containerRect(FloatPoint(), containerSize); |
| 308 |
| 307 SkPictureRecorder recorder; | 309 SkPictureRecorder recorder; |
| 308 SkCanvas* canvas = recorder.beginRecording(width(), height()); | 310 SkCanvas* canvas = recorder.beginRecording(containerRect); |
| 309 drawForContainer(canvas, SkPaint(), containerSize, 1, rect(), rect(), url); | 311 drawForContainer(canvas, SkPaint(), containerSize, 1, containerRect, contain
erRect, url); |
| 310 | 312 |
| 313 const IntSize imageSize = roundedIntSize(containerSize); |
| 314 const SkMatrix residualScale = SkMatrix::MakeScale( |
| 315 static_cast<float>(imageSize.width()) / containerSize.width(), |
| 316 static_cast<float>(imageSize.height()) / containerSize.height()); |
| 311 return fromSkSp(SkImage::MakeFromPicture(recorder.finishRecordingAsPicture()
, | 317 return fromSkSp(SkImage::MakeFromPicture(recorder.finishRecordingAsPicture()
, |
| 312 SkISize::Make(width(), height()), nullptr, nullptr)); | 318 SkISize::Make(imageSize.width(), imageSize.height()), &residualScale, nu
llptr)); |
| 313 } | 319 } |
| 314 | 320 |
| 315 static bool drawNeedsLayer(const SkPaint& paint) | 321 static bool drawNeedsLayer(const SkPaint& paint) |
| 316 { | 322 { |
| 317 if (SkColorGetA(paint.getColor()) < 255) | 323 if (SkColorGetA(paint.getColor()) < 255) |
| 318 return true; | 324 return true; |
| 319 | 325 |
| 320 SkXfermode::Mode xfermode; | 326 SkXfermode::Mode xfermode; |
| 321 if (SkXfermode::AsMode(paint.getXfermode(), &xfermode)) { | 327 if (SkXfermode::AsMode(paint.getXfermode(), &xfermode)) { |
| 322 if (xfermode != SkXfermode::kSrcOver_Mode) | 328 if (xfermode != SkXfermode::kSrcOver_Mode) |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 | 567 |
| 562 return m_page ? SizeAvailable : SizeUnavailable; | 568 return m_page ? SizeAvailable : SizeUnavailable; |
| 563 } | 569 } |
| 564 | 570 |
| 565 String SVGImage::filenameExtension() const | 571 String SVGImage::filenameExtension() const |
| 566 { | 572 { |
| 567 return "svg"; | 573 return "svg"; |
| 568 } | 574 } |
| 569 | 575 |
| 570 } // namespace blink | 576 } // namespace blink |
| OLD | NEW |