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

Side by Side Diff: Source/core/html/canvas/CanvasRenderingContext2D.cpp

Issue 388253004: Drawing an animated image to a canvas now behave as expected (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 5 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
« no previous file with comments | « no previous file | Source/platform/graphics/BitmapImage.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> 4 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> 5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> 6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org>
7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. 7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved.
8 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved. 8 * Copyright (C) 2012, 2013 Intel Corporation. All rights reserved.
9 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 9 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
10 * 10 *
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 #include "core/html/TextMetrics.h" 54 #include "core/html/TextMetrics.h"
55 #include "core/html/canvas/CanvasGradient.h" 55 #include "core/html/canvas/CanvasGradient.h"
56 #include "core/html/canvas/CanvasPattern.h" 56 #include "core/html/canvas/CanvasPattern.h"
57 #include "core/html/canvas/CanvasStyle.h" 57 #include "core/html/canvas/CanvasStyle.h"
58 #include "core/html/canvas/Path2D.h" 58 #include "core/html/canvas/Path2D.h"
59 #include "core/rendering/RenderImage.h" 59 #include "core/rendering/RenderImage.h"
60 #include "core/rendering/RenderLayer.h" 60 #include "core/rendering/RenderLayer.h"
61 #include "core/rendering/RenderTheme.h" 61 #include "core/rendering/RenderTheme.h"
62 #include "platform/fonts/FontCache.h" 62 #include "platform/fonts/FontCache.h"
63 #include "platform/geometry/FloatQuad.h" 63 #include "platform/geometry/FloatQuad.h"
64 #include "platform/graphics/BitmapImage.h"
64 #include "platform/graphics/DrawLooperBuilder.h" 65 #include "platform/graphics/DrawLooperBuilder.h"
65 #include "platform/graphics/GraphicsContextStateSaver.h" 66 #include "platform/graphics/GraphicsContextStateSaver.h"
66 #include "platform/text/TextRun.h" 67 #include "platform/text/TextRun.h"
67 #include "wtf/CheckedArithmetic.h" 68 #include "wtf/CheckedArithmetic.h"
68 #include "wtf/MathExtras.h" 69 #include "wtf/MathExtras.h"
69 #include "wtf/OwnPtr.h" 70 #include "wtf/OwnPtr.h"
70 #include "wtf/Uint8ClampedArray.h" 71 #include "wtf/Uint8ClampedArray.h"
71 #include "wtf/text/StringBuilder.h" 72 #include "wtf/text/StringBuilder.h"
72 73
73 namespace WebCore { 74 namespace WebCore {
(...skipping 1427 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 FloatRect srcRect = normalizeRect(FloatRect(sx, sy, sw, sh)); 1502 FloatRect srcRect = normalizeRect(FloatRect(sx, sy, sw, sh));
1502 FloatRect dstRect = normalizeRect(FloatRect(dx, dy, dw, dh)); 1503 FloatRect dstRect = normalizeRect(FloatRect(dx, dy, dw, dh));
1503 1504
1504 clipRectsToImageRect(FloatRect(FloatPoint(), imageSource->sourceSize()), &sr cRect, &dstRect); 1505 clipRectsToImageRect(FloatRect(FloatPoint(), imageSource->sourceSize()), &sr cRect, &dstRect);
1505 1506
1506 imageSource->adjustDrawRects(&srcRect, &dstRect); 1507 imageSource->adjustDrawRects(&srcRect, &dstRect);
1507 1508
1508 if (srcRect.isEmpty()) 1509 if (srcRect.isEmpty())
1509 return; 1510 return;
1510 1511
1512 if (image->isBitmapImage() && image->maybeAnimated())
1513 image = BitmapImage::create(static_cast<BitmapImage*>(image.get())->fram eAtIndex(0));
Justin Novosad 2014/07/16 19:36:02 Would be cleaner to put this logic inside BitmapIm
Rémi Piotaix 2014/07/17 17:38:20 Done.
1514
1511 FloatRect dirtyRect = clipBounds; 1515 FloatRect dirtyRect = clipBounds;
1512 if (imageSource->isVideoElement()) { 1516 if (imageSource->isVideoElement()) {
1513 drawVideo(static_cast<HTMLVideoElement*>(imageSource), srcRect, dstRect) ; 1517 drawVideo(static_cast<HTMLVideoElement*>(imageSource), srcRect, dstRect) ;
1514 computeDirtyRect(dstRect, clipBounds, &dirtyRect); 1518 computeDirtyRect(dstRect, clipBounds, &dirtyRect);
1515 } else { 1519 } else {
1516 if (rectContainsTransformedRect(dstRect, clipBounds)) { 1520 if (rectContainsTransformedRect(dstRect, clipBounds)) {
1517 c->drawImage(image.get(), dstRect, srcRect, op, blendMode); 1521 c->drawImage(image.get(), dstRect, srcRect, op, blendMode);
1518 } else if (isFullCanvasCompositeMode(op)) { 1522 } else if (isFullCanvasCompositeMode(op)) {
1519 fullCanvasCompositedDrawImage(image.get(), dstRect, srcRect, op); 1523 fullCanvasCompositedDrawImage(image.get(), dstRect, srcRect, op);
1520 } else if (op == CompositeCopy) { 1524 } else if (op == CompositeCopy) {
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after
2446 2450
2447 unsigned CanvasRenderingContext2D::hitRegionsCount() const 2451 unsigned CanvasRenderingContext2D::hitRegionsCount() const
2448 { 2452 {
2449 if (m_hitRegionManager) 2453 if (m_hitRegionManager)
2450 return m_hitRegionManager->getHitRegionsCount(); 2454 return m_hitRegionManager->getHitRegionsCount();
2451 2455
2452 return 0; 2456 return 0;
2453 } 2457 }
2454 2458
2455 } // namespace WebCore 2459 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | Source/platform/graphics/BitmapImage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698