Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp

Issue 2791043002: Draw recorded content directly into the containing PaintCanvas, when possible. (Closed)
Patch Set: none Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 RespectImageOrientationEnum shouldRespectImageOrientation, 404 RespectImageOrientationEnum shouldRespectImageOrientation,
405 ImageClampingMode clampMode) { 405 ImageClampingMode clampMode) {
406 if (!m_page) 406 if (!m_page)
407 return; 407 return;
408 408
409 drawInternal(canvas, flags, dstRect, srcRect, shouldRespectImageOrientation, 409 drawInternal(canvas, flags, dstRect, srcRect, shouldRespectImageOrientation,
410 clampMode, KURL()); 410 clampMode, KURL());
411 } 411 }
412 412
413 sk_sp<PaintRecord> SVGImage::paintRecordForCurrentFrame(const FloatRect& bounds, 413 sk_sp<PaintRecord> SVGImage::paintRecordForCurrentFrame(const FloatRect& bounds,
414 const KURL& url) { 414 const KURL& url,
415 PaintCanvas* canvas) {
415 DCHECK(m_page); 416 DCHECK(m_page);
416 FrameView* view = toLocalFrame(m_page->mainFrame())->view(); 417 FrameView* view = toLocalFrame(m_page->mainFrame())->view();
417 view->resize(containerSize()); 418 view->resize(containerSize());
418 419
419 // Always call processUrlFragment, even if the url is empty, because 420 // Always call processUrlFragment, even if the url is empty, because
420 // there may have been a previous url/fragment that needs to be reset. 421 // there may have been a previous url/fragment that needs to be reset.
421 view->processUrlFragment(url); 422 view->processUrlFragment(url);
422 423
423 // If the image was reset, we need to rewind the timeline back to 0. This 424 // If the image was reset, we need to rewind the timeline back to 0. This
424 // needs to be done before painting, or else we wouldn't get the correct 425 // needs to be done before painting, or else we wouldn't get the correct
425 // reset semantics (we'd paint the "last" frame rather than the one at 426 // reset semantics (we'd paint the "last" frame rather than the one at
426 // time=0.) The reason we do this here and not in resetAnimation() is to 427 // time=0.) The reason we do this here and not in resetAnimation() is to
427 // avoid setting timers from the latter. 428 // avoid setting timers from the latter.
428 flushPendingTimelineRewind(); 429 flushPendingTimelineRewind();
429 430
430 IntRect intBounds(enclosingIntRect(bounds)); 431 IntRect intBounds(enclosingIntRect(bounds));
431 PaintRecordBuilder builder(intBounds, nullptr, nullptr, 432 PaintRecordBuilder builder(intBounds, nullptr, nullptr,
432 m_paintController.get()); 433 m_paintController.get());
433 434
434 view->updateAllLifecyclePhasesExceptPaint(); 435 view->updateAllLifecyclePhasesExceptPaint();
435 view->paint(builder.context(), CullRect(intBounds)); 436 view->paint(builder.context(), CullRect(intBounds));
436 DCHECK(!view->needsLayout()); 437 DCHECK(!view->needsLayout());
437 438
439 if (canvas) {
440 builder.endRecording(*canvas);
441 return nullptr;
442 }
438 return builder.endRecording(); 443 return builder.endRecording();
439 } 444 }
440 445
441 void SVGImage::drawInternal(PaintCanvas* canvas, 446 void SVGImage::drawInternal(PaintCanvas* canvas,
442 const PaintFlags& flags, 447 const PaintFlags& flags,
443 const FloatRect& dstRect, 448 const FloatRect& dstRect,
444 const FloatRect& srcRect, 449 const FloatRect& srcRect,
445 RespectImageOrientationEnum, 450 RespectImageOrientationEnum,
446 ImageClampingMode, 451 ImageClampingMode,
447 const KURL& url) { 452 const KURL& url) {
(...skipping 11 matching lines...) Expand all
459 FloatSize topLeftOffset(srcRect.location().x() * scale.width(), 464 FloatSize topLeftOffset(srcRect.location().x() * scale.width(),
460 srcRect.location().y() * scale.height()); 465 srcRect.location().y() * scale.height());
461 FloatPoint destOffset = dstRect.location() - topLeftOffset; 466 FloatPoint destOffset = dstRect.location() - topLeftOffset;
462 AffineTransform transform = 467 AffineTransform transform =
463 AffineTransform::translation(destOffset.x(), destOffset.y()); 468 AffineTransform::translation(destOffset.x(), destOffset.y());
464 transform.scale(scale.width(), scale.height()); 469 transform.scale(scale.width(), scale.height());
465 470
466 canvas->save(); 471 canvas->save();
467 canvas->clipRect(enclosingIntRect(dstRect)); 472 canvas->clipRect(enclosingIntRect(dstRect));
468 canvas->concat(affineTransformToSkMatrix(transform)); 473 canvas->concat(affineTransformToSkMatrix(transform));
469 canvas->PlaybackPaintRecord(paintRecordForCurrentFrame(srcRect, url)); 474 paintRecordForCurrentFrame(srcRect, url, canvas);
470 canvas->restore(); 475 canvas->restore();
471 } 476 }
472 477
473 // Start any (SMIL) animations if needed. This will restart or continue 478 // Start any (SMIL) animations if needed. This will restart or continue
474 // animations if preceded by calls to resetAnimation or stopAnimation 479 // animations if preceded by calls to resetAnimation or stopAnimation
475 // respectively. 480 // respectively.
476 startAnimation(); 481 startAnimation();
477 } 482 }
478 483
479 LayoutReplaced* SVGImage::embeddedReplacedContent() const { 484 LayoutReplaced* SVGImage::embeddedReplacedContent() const {
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 } 690 }
686 691
687 return m_page ? SizeAvailable : SizeUnavailable; 692 return m_page ? SizeAvailable : SizeUnavailable;
688 } 693 }
689 694
690 String SVGImage::filenameExtension() const { 695 String SVGImage::filenameExtension() const {
691 return "svg"; 696 return "svg";
692 } 697 }
693 698
694 } // namespace blink 699 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698