| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 #include "platform/graphics/paint/CullRect.h" | 55 #include "platform/graphics/paint/CullRect.h" |
| 56 #include "platform/graphics/paint/DrawingRecorder.h" | 56 #include "platform/graphics/paint/DrawingRecorder.h" |
| 57 #include "platform/graphics/paint/SkPictureBuilder.h" | 57 #include "platform/graphics/paint/SkPictureBuilder.h" |
| 58 #include "platform/tracing/TraceEvent.h" | 58 #include "platform/tracing/TraceEvent.h" |
| 59 #include "third_party/skia/include/core/SkPicture.h" | 59 #include "third_party/skia/include/core/SkPicture.h" |
| 60 #include "wtf/PassRefPtr.h" | 60 #include "wtf/PassRefPtr.h" |
| 61 | 61 |
| 62 namespace blink { | 62 namespace blink { |
| 63 | 63 |
| 64 SVGImage::SVGImage(ImageObserver* observer) | 64 SVGImage::SVGImage(ImageObserver* observer) |
| 65 : Image(observer), m_hasPendingTimelineRewind(false) {} | 65 : Image(observer), |
| 66 m_paintController(PaintController::create()), |
| 67 m_hasPendingTimelineRewind(false) {} |
| 66 | 68 |
| 67 SVGImage::~SVGImage() { | 69 SVGImage::~SVGImage() { |
| 68 if (m_page) { | 70 if (m_page) { |
| 69 // Store m_page in a local variable, clearing m_page, so that | 71 // Store m_page in a local variable, clearing m_page, so that |
| 70 // SVGImageChromeClient knows we're destructed. | 72 // SVGImageChromeClient knows we're destructed. |
| 71 Page* currentPage = m_page.release(); | 73 Page* currentPage = m_page.release(); |
| 72 // Break both the loader and view references to the frame | 74 // Break both the loader and view references to the frame |
| 73 currentPage->willBeDestroyed(); | 75 currentPage->willBeDestroyed(); |
| 74 } | 76 } |
| 75 | 77 |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 // Always call processUrlFragment, even if the url is empty, because | 364 // Always call processUrlFragment, even if the url is empty, because |
| 363 // there may have been a previous url/fragment that needs to be reset. | 365 // there may have been a previous url/fragment that needs to be reset. |
| 364 view->processUrlFragment(url); | 366 view->processUrlFragment(url); |
| 365 | 367 |
| 366 // If the image was reset, we need to rewind the timeline back to 0. This | 368 // If the image was reset, we need to rewind the timeline back to 0. This |
| 367 // needs to be done before painting, or else we wouldn't get the correct | 369 // needs to be done before painting, or else we wouldn't get the correct |
| 368 // reset semantics (we'd paint the "last" frame rather than the one at | 370 // reset semantics (we'd paint the "last" frame rather than the one at |
| 369 // time=0.) The reason we do this here and not in resetAnimation() is to | 371 // time=0.) The reason we do this here and not in resetAnimation() is to |
| 370 // avoid setting timers from the latter. | 372 // avoid setting timers from the latter. |
| 371 flushPendingTimelineRewind(); | 373 flushPendingTimelineRewind(); |
| 372 | 374 SkPictureBuilder imagePicture(dstRect, nullptr, nullptr, |
| 373 SkPictureBuilder imagePicture(dstRect); | 375 m_paintController.get()); |
| 374 { | 376 { |
| 375 ClipRecorder clipRecorder(imagePicture.context(), imagePicture, | 377 ClipRecorder clipRecorder(imagePicture.context(), imagePicture, |
| 376 DisplayItem::kClipNodeImage, | 378 DisplayItem::kClipNodeImage, |
| 377 enclosingIntRect(dstRect)); | 379 enclosingIntRect(dstRect)); |
| 378 | 380 |
| 379 // We can only draw the entire frame, clipped to the rect we want. So | 381 // We can only draw the entire frame, clipped to the rect we want. So |
| 380 // compute where the top left of the image would be if we were drawing | 382 // compute where the top left of the image would be if we were drawing |
| 381 // without clipping, and translate accordingly. | 383 // without clipping, and translate accordingly. |
| 382 FloatSize scale(dstRect.width() / srcRect.width(), | 384 FloatSize scale(dstRect.width() / srcRect.width(), |
| 383 dstRect.height() / srcRect.height()); | 385 dstRect.height() / srcRect.height()); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 } | 617 } |
| 616 | 618 |
| 617 return m_page ? SizeAvailable : SizeUnavailable; | 619 return m_page ? SizeAvailable : SizeUnavailable; |
| 618 } | 620 } |
| 619 | 621 |
| 620 String SVGImage::filenameExtension() const { | 622 String SVGImage::filenameExtension() const { |
| 621 return "svg"; | 623 return "svg"; |
| 622 } | 624 } |
| 623 | 625 |
| 624 } // namespace blink | 626 } // namespace blink |
| OLD | NEW |