OLD | NEW |
---|---|
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 1546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1557 FloatRect dirtyRect; | 1557 FloatRect dirtyRect; |
1558 if (computeDirtyRect(dstRect, clipBounds, &dirtyRect)) { | 1558 if (computeDirtyRect(dstRect, clipBounds, &dirtyRect)) { |
1559 if (!imageSource->isVideoElement()) { | 1559 if (!imageSource->isVideoElement()) { |
1560 c->drawImage(image.get(), dstRect, srcRect, op, blendMode); | 1560 c->drawImage(image.get(), dstRect, srcRect, op, blendMode); |
1561 } else { | 1561 } else { |
1562 drawVideo(static_cast<HTMLVideoElement*>(imageSource), srcRect, dstRect); | 1562 drawVideo(static_cast<HTMLVideoElement*>(imageSource), srcRect, dstRect); |
1563 } | 1563 } |
1564 didDraw(dirtyRect); | 1564 didDraw(dirtyRect); |
1565 } | 1565 } |
1566 } | 1566 } |
1567 validateStateStack(); | |
dshwang
2014/10/14 19:00:28
I move it to here, because drawVideo is used as fo
| |
1567 | 1568 |
1568 if (sourceImageStatus == ExternalSourceImageStatus && isAccelerated() && can vas()->buffer()) | 1569 if (sourceImageStatus == ExternalSourceImageStatus && isAccelerated() && can vas()->buffer()) |
1569 canvas()->buffer()->flush(); | 1570 canvas()->buffer()->flush(); |
1570 | 1571 |
1571 if (canvas()->originClean() && wouldTaintOrigin(imageSource)) | 1572 if (canvas()->originClean() && wouldTaintOrigin(imageSource)) |
1572 canvas()->setOriginTainted(); | 1573 canvas()->setOriginTainted(); |
1573 } | 1574 } |
1574 | 1575 |
1575 void CanvasRenderingContext2D::drawVideo(HTMLVideoElement* video, FloatRect srcR ect, FloatRect dstRect) | 1576 void CanvasRenderingContext2D::drawVideo(HTMLVideoElement* video, FloatRect srcR ect, FloatRect dstRect) |
1576 { | 1577 { |
1577 GraphicsContext* c = drawingContext(); | 1578 GraphicsContext* c = drawingContext(); |
1578 GraphicsContextStateSaver stateSaver(*c); | 1579 GraphicsContextStateSaver stateSaver(*c); |
1579 c->clip(dstRect); | 1580 c->clip(dstRect); |
1580 c->translate(dstRect.x(), dstRect.y()); | 1581 c->translate(dstRect.x(), dstRect.y()); |
1581 c->scale(dstRect.width() / srcRect.width(), dstRect.height() / srcRect.heigh t()); | 1582 c->scale(dstRect.width() / srcRect.width(), dstRect.height() / srcRect.heigh t()); |
1582 c->translate(-srcRect.x(), -srcRect.y()); | 1583 c->translate(-srcRect.x(), -srcRect.y()); |
1583 video->paintCurrentFrameInContext(c, IntRect(IntPoint(), IntSize(video->vide oWidth(), video->videoHeight()))); | 1584 video->paintCurrentFrameInContext(c, IntRect(IntPoint(), IntSize(video->vide oWidth(), video->videoHeight()))); |
1584 stateSaver.restore(); | 1585 stateSaver.restore(); |
1585 validateStateStack(); | |
Justin Novosad
2014/10/14 17:50:25
why are you removing this?
| |
1586 } | 1586 } |
1587 | 1587 |
1588 void CanvasRenderingContext2D::drawImageFromRect(HTMLImageElement* image, | 1588 void CanvasRenderingContext2D::drawImageFromRect(HTMLImageElement* image, |
1589 float sx, float sy, float sw, float sh, | 1589 float sx, float sy, float sw, float sh, |
1590 float dx, float dy, float dw, float dh, | 1590 float dx, float dy, float dw, float dh, |
1591 const String& compositeOperation) | 1591 const String& compositeOperation) |
1592 { | 1592 { |
1593 if (!image) | 1593 if (!image) |
1594 return; | 1594 return; |
1595 CompositeOperator op; | 1595 CompositeOperator op; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1640 context->fillPath(path); | 1640 context->fillPath(path); |
1641 } | 1641 } |
1642 | 1642 |
1643 template<class T> void CanvasRenderingContext2D::fullCanvasCompositedFill(const T& area) | 1643 template<class T> void CanvasRenderingContext2D::fullCanvasCompositedFill(const T& area) |
1644 { | 1644 { |
1645 ASSERT(isFullCanvasCompositeMode(state().m_globalComposite)); | 1645 ASSERT(isFullCanvasCompositeMode(state().m_globalComposite)); |
1646 | 1646 |
1647 GraphicsContext* c = drawingContext(); | 1647 GraphicsContext* c = drawingContext(); |
1648 ASSERT(c); | 1648 ASSERT(c); |
1649 c->beginLayer(1, state().m_globalComposite); | 1649 c->beginLayer(1, state().m_globalComposite); |
1650 CompositeOperator previousOperator = c->compositeOperation(); | |
1651 c->setCompositeOperation(CompositeSourceOver); | 1650 c->setCompositeOperation(CompositeSourceOver); |
1652 fillPrimitive(area, c); | 1651 fillPrimitive(area, c); |
1653 c->setCompositeOperation(previousOperator); | |
1654 c->endLayer(); | 1652 c->endLayer(); |
1655 } | 1653 } |
1656 | 1654 |
1657 static void strokePrimitive(const FloatRect& rect, GraphicsContext* context) | 1655 static void strokePrimitive(const FloatRect& rect, GraphicsContext* context) |
1658 { | 1656 { |
1659 context->strokeRect(rect); | 1657 context->strokeRect(rect); |
1660 } | 1658 } |
1661 | 1659 |
1662 static void strokePrimitive(const Path& path, GraphicsContext* context) | 1660 static void strokePrimitive(const Path& path, GraphicsContext* context) |
1663 { | 1661 { |
1664 context->strokePath(path); | 1662 context->strokePath(path); |
1665 } | 1663 } |
1666 | 1664 |
1667 template<class T> void CanvasRenderingContext2D::fullCanvasCompositedStroke(cons t T& area) | 1665 template<class T> void CanvasRenderingContext2D::fullCanvasCompositedStroke(cons t T& area) |
1668 { | 1666 { |
1669 ASSERT(isFullCanvasCompositeMode(state().m_globalComposite)); | 1667 ASSERT(isFullCanvasCompositeMode(state().m_globalComposite)); |
1670 | 1668 |
1671 GraphicsContext* c = drawingContext(); | 1669 GraphicsContext* c = drawingContext(); |
1672 ASSERT(c); | 1670 ASSERT(c); |
1673 c->beginLayer(1, state().m_globalComposite); | 1671 c->beginLayer(1, state().m_globalComposite); |
1674 CompositeOperator previousOperator = c->compositeOperation(); | |
1675 c->setCompositeOperation(CompositeSourceOver); | 1672 c->setCompositeOperation(CompositeSourceOver); |
1676 strokePrimitive(area, c); | 1673 strokePrimitive(area, c); |
1677 c->setCompositeOperation(previousOperator); | |
1678 c->endLayer(); | 1674 c->endLayer(); |
1679 } | 1675 } |
1680 | 1676 |
1681 PassRefPtrWillBeRawPtr<CanvasGradient> CanvasRenderingContext2D::createLinearGra dient(float x0, float y0, float x1, float y1) | 1677 PassRefPtrWillBeRawPtr<CanvasGradient> CanvasRenderingContext2D::createLinearGra dient(float x0, float y0, float x1, float y1) |
1682 { | 1678 { |
1683 RefPtrWillBeRawPtr<CanvasGradient> gradient = CanvasGradient::create(FloatPo int(x0, y0), FloatPoint(x1, y1)); | 1679 RefPtrWillBeRawPtr<CanvasGradient> gradient = CanvasGradient::create(FloatPo int(x0, y0), FloatPoint(x1, y1)); |
1684 return gradient.release(); | 1680 return gradient.release(); |
1685 } | 1681 } |
1686 | 1682 |
1687 PassRefPtrWillBeRawPtr<CanvasGradient> CanvasRenderingContext2D::createRadialGra dient(float x0, float y0, float r0, float x1, float y1, float r1, ExceptionState & exceptionState) | 1683 PassRefPtrWillBeRawPtr<CanvasGradient> CanvasRenderingContext2D::createRadialGra dient(float x0, float y0, float r0, float x1, float y1, float r1, ExceptionState & exceptionState) |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2229 location = FloatPoint(); | 2225 location = FloatPoint(); |
2230 } | 2226 } |
2231 | 2227 |
2232 FloatRect clipBounds; | 2228 FloatRect clipBounds; |
2233 if (!c->getTransformedClipBounds(&clipBounds)) { | 2229 if (!c->getTransformedClipBounds(&clipBounds)) { |
2234 return; | 2230 return; |
2235 } | 2231 } |
2236 | 2232 |
2237 if (isFullCanvasCompositeMode(state().m_globalComposite)) { | 2233 if (isFullCanvasCompositeMode(state().m_globalComposite)) { |
2238 c->beginLayer(1, state().m_globalComposite); | 2234 c->beginLayer(1, state().m_globalComposite); |
2239 CompositeOperator previousOperator = c->compositeOperation(); | |
2240 c->setCompositeOperation(CompositeSourceOver); | 2235 c->setCompositeOperation(CompositeSourceOver); |
2241 c->drawBidiText(font, textRunPaintInfo, location, Font::UseFallbackIfFon tNotReady); | 2236 c->drawBidiText(font, textRunPaintInfo, location, Font::UseFallbackIfFon tNotReady); |
2242 c->setCompositeOperation(previousOperator); | |
2243 c->endLayer(); | 2237 c->endLayer(); |
2244 didDraw(clipBounds); | 2238 didDraw(clipBounds); |
2245 } else if (state().m_globalComposite == CompositeCopy) { | 2239 } else if (state().m_globalComposite == CompositeCopy) { |
2246 clearCanvas(); | 2240 clearCanvas(); |
2247 c->drawBidiText(font, textRunPaintInfo, location, Font::UseFallbackIfFon tNotReady); | 2241 c->drawBidiText(font, textRunPaintInfo, location, Font::UseFallbackIfFon tNotReady); |
2248 didDraw(clipBounds); | 2242 didDraw(clipBounds); |
2249 } else { | 2243 } else { |
2250 FloatRect dirtyRect; | 2244 FloatRect dirtyRect; |
2251 if (computeDirtyRect(textRunPaintInfo.bounds, clipBounds, &dirtyRect)) { | 2245 if (computeDirtyRect(textRunPaintInfo.bounds, clipBounds, &dirtyRect)) { |
2252 c->drawBidiText(font, textRunPaintInfo, location, Font::UseFallbackI fFontNotReady); | 2246 c->drawBidiText(font, textRunPaintInfo, location, Font::UseFallbackI fFontNotReady); |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2463 | 2457 |
2464 unsigned CanvasRenderingContext2D::hitRegionsCount() const | 2458 unsigned CanvasRenderingContext2D::hitRegionsCount() const |
2465 { | 2459 { |
2466 if (m_hitRegionManager) | 2460 if (m_hitRegionManager) |
2467 return m_hitRegionManager->getHitRegionsCount(); | 2461 return m_hitRegionManager->getHitRegionsCount(); |
2468 | 2462 |
2469 return 0; | 2463 return 0; |
2470 } | 2464 } |
2471 | 2465 |
2472 } // namespace blink | 2466 } // namespace blink |
OLD | NEW |