| 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 1358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1369 void CanvasRenderingContext2D::drawImage(CanvasImageSource* imageSource, | 1369 void CanvasRenderingContext2D::drawImage(CanvasImageSource* imageSource, |
| 1370 float sx, float sy, float sw, float sh, | 1370 float sx, float sy, float sw, float sh, |
| 1371 float dx, float dy, float dw, float dh, ExceptionState& exceptionState) | 1371 float dx, float dy, float dw, float dh, ExceptionState& exceptionState) |
| 1372 { | 1372 { |
| 1373 if (!drawingCanvas()) | 1373 if (!drawingCanvas()) |
| 1374 return; | 1374 return; |
| 1375 | 1375 |
| 1376 RefPtr<Image> image; | 1376 RefPtr<Image> image; |
| 1377 SourceImageStatus sourceImageStatus = InvalidSourceImageStatus; | 1377 SourceImageStatus sourceImageStatus = InvalidSourceImageStatus; |
| 1378 if (!imageSource->isVideoElement()) { | 1378 if (!imageSource->isVideoElement()) { |
| 1379 image = imageSource->getSourceImageForCanvas(&sourceImageStatus); | 1379 AccelerationHint hint = canvas()->buffer()->isAccelerated() ? PreferAcce
leration : PreferNoAcceleration; |
| 1380 image = imageSource->getSourceImageForCanvas(&sourceImageStatus, hint); |
| 1380 if (sourceImageStatus == UndecodableSourceImageStatus) | 1381 if (sourceImageStatus == UndecodableSourceImageStatus) |
| 1381 exceptionState.throwDOMException(InvalidStateError, "The HTMLImageEl
ement provided is in the 'broken' state."); | 1382 exceptionState.throwDOMException(InvalidStateError, "The HTMLImageEl
ement provided is in the 'broken' state."); |
| 1382 if (!image || !image->width() || !image->height()) | 1383 if (!image || !image->width() || !image->height()) |
| 1383 return; | 1384 return; |
| 1384 } else { | 1385 } else { |
| 1385 if (!static_cast<HTMLVideoElement*>(imageSource)->hasAvailableVideoFrame
()) | 1386 if (!static_cast<HTMLVideoElement*>(imageSource)->hasAvailableVideoFrame
()) |
| 1386 return; | 1387 return; |
| 1387 } | 1388 } |
| 1388 | 1389 |
| 1389 if (!std::isfinite(dx) || !std::isfinite(dy) || !std::isfinite(dw) || !std::
isfinite(dh) | 1390 if (!std::isfinite(dx) || !std::isfinite(dy) || !std::isfinite(dw) || !std::
isfinite(dh) |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1477 } | 1478 } |
| 1478 | 1479 |
| 1479 CanvasPattern* CanvasRenderingContext2D::createPattern(const CanvasImageSourceUn
ion& imageSource, const String& repetitionType, ExceptionState& exceptionState) | 1480 CanvasPattern* CanvasRenderingContext2D::createPattern(const CanvasImageSourceUn
ion& imageSource, const String& repetitionType, ExceptionState& exceptionState) |
| 1480 { | 1481 { |
| 1481 Pattern::RepeatMode repeatMode = CanvasPattern::parseRepetitionType(repetiti
onType, exceptionState); | 1482 Pattern::RepeatMode repeatMode = CanvasPattern::parseRepetitionType(repetiti
onType, exceptionState); |
| 1482 if (exceptionState.hadException()) | 1483 if (exceptionState.hadException()) |
| 1483 return nullptr; | 1484 return nullptr; |
| 1484 | 1485 |
| 1485 SourceImageStatus status; | 1486 SourceImageStatus status; |
| 1486 CanvasImageSource* imageSourceInternal = toImageSourceInternal(imageSource); | 1487 CanvasImageSource* imageSourceInternal = toImageSourceInternal(imageSource); |
| 1487 RefPtr<Image> imageForRendering = imageSourceInternal->getSourceImageForCanv
as(&status); | 1488 RefPtr<Image> imageForRendering = imageSourceInternal->getSourceImageForCanv
as(&status, PreferNoAcceleration); |
| 1488 | 1489 |
| 1489 switch (status) { | 1490 switch (status) { |
| 1490 case NormalSourceImageStatus: | 1491 case NormalSourceImageStatus: |
| 1491 break; | 1492 break; |
| 1492 case ZeroSizeCanvasSourceImageStatus: | 1493 case ZeroSizeCanvasSourceImageStatus: |
| 1493 exceptionState.throwDOMException(InvalidStateError, String::format("The
canvas %s is 0.", imageSourceInternal->elementSize().width() ? "height" : "width
")); | 1494 exceptionState.throwDOMException(InvalidStateError, String::format("The
canvas %s is 0.", imageSourceInternal->elementSize().width() ? "height" : "width
")); |
| 1494 return nullptr; | 1495 return nullptr; |
| 1495 case UndecodableSourceImageStatus: | 1496 case UndecodableSourceImageStatus: |
| 1496 exceptionState.throwDOMException(InvalidStateError, "Source image is in
the 'broken' state."); | 1497 exceptionState.throwDOMException(InvalidStateError, "Source image is in
the 'broken' state."); |
| 1497 return nullptr; | 1498 return nullptr; |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1767 void CanvasRenderingContext2D::schedulePruneLocalFontCacheIfNeeded() | 1768 void CanvasRenderingContext2D::schedulePruneLocalFontCacheIfNeeded() |
| 1768 { | 1769 { |
| 1769 if (m_pruneLocalFontCacheScheduled) | 1770 if (m_pruneLocalFontCacheScheduled) |
| 1770 return; | 1771 return; |
| 1771 m_pruneLocalFontCacheScheduled = true; | 1772 m_pruneLocalFontCacheScheduled = true; |
| 1772 Platform::current()->currentThread()->addTaskObserver(this); | 1773 Platform::current()->currentThread()->addTaskObserver(this); |
| 1773 } | 1774 } |
| 1774 | 1775 |
| 1775 void CanvasRenderingContext2D::didProcessTask() | 1776 void CanvasRenderingContext2D::didProcessTask() |
| 1776 { | 1777 { |
| 1778 // The rendering surface needs to be prepared now because it will be too lat
e |
| 1779 // to create a layer once we are in the paint invalidation phase. |
| 1780 canvas()->prepareSurfaceForPaintingIfNeeded(); |
| 1781 |
| 1777 pruneLocalFontCache(canvas()->document().canvasFontCache()->maxFonts()); | 1782 pruneLocalFontCache(canvas()->document().canvasFontCache()->maxFonts()); |
| 1778 m_pruneLocalFontCacheScheduled = false; | 1783 m_pruneLocalFontCacheScheduled = false; |
| 1779 Platform::current()->currentThread()->removeTaskObserver(this); | 1784 Platform::current()->currentThread()->removeTaskObserver(this); |
| 1780 } | 1785 } |
| 1781 | 1786 |
| 1782 void CanvasRenderingContext2D::pruneLocalFontCache(size_t targetSize) | 1787 void CanvasRenderingContext2D::pruneLocalFontCache(size_t targetSize) |
| 1783 { | 1788 { |
| 1784 if (targetSize == 0) { | 1789 if (targetSize == 0) { |
| 1785 // Short cut: LRU does not matter when evicting everything | 1790 // Short cut: LRU does not matter when evicting everything |
| 1786 m_fontLRUList.clear(); | 1791 m_fontLRUList.clear(); |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2319 if (imageType == CanvasRenderingContext2DState::NonOpaqueImage) | 2324 if (imageType == CanvasRenderingContext2DState::NonOpaqueImage) |
| 2320 return; | 2325 return; |
| 2321 if (alpha < 0xFF) | 2326 if (alpha < 0xFF) |
| 2322 return; | 2327 return; |
| 2323 } | 2328 } |
| 2324 | 2329 |
| 2325 canvas()->buffer()->willOverwriteCanvas(); | 2330 canvas()->buffer()->willOverwriteCanvas(); |
| 2326 } | 2331 } |
| 2327 | 2332 |
| 2328 } // namespace blink | 2333 } // namespace blink |
| OLD | NEW |