| 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 AccelerationHint hint = canvas()->buffer()->isAccelerated() ? PreferAcce
leration : PreferNoAcceleration; | 1379 image = imageSource->getSourceImageForCanvas(&sourceImageStatus); |
| 1380 image = imageSource->getSourceImageForCanvas(&sourceImageStatus, hint); | |
| 1381 if (sourceImageStatus == UndecodableSourceImageStatus) | 1380 if (sourceImageStatus == UndecodableSourceImageStatus) |
| 1382 exceptionState.throwDOMException(InvalidStateError, "The HTMLImageEl
ement provided is in the 'broken' state."); | 1381 exceptionState.throwDOMException(InvalidStateError, "The HTMLImageEl
ement provided is in the 'broken' state."); |
| 1383 if (!image || !image->width() || !image->height()) | 1382 if (!image || !image->width() || !image->height()) |
| 1384 return; | 1383 return; |
| 1385 } else { | 1384 } else { |
| 1386 if (!static_cast<HTMLVideoElement*>(imageSource)->hasAvailableVideoFrame
()) | 1385 if (!static_cast<HTMLVideoElement*>(imageSource)->hasAvailableVideoFrame
()) |
| 1387 return; | 1386 return; |
| 1388 } | 1387 } |
| 1389 | 1388 |
| 1390 if (!std::isfinite(dx) || !std::isfinite(dy) || !std::isfinite(dw) || !std::
isfinite(dh) | 1389 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... |
| 1478 } | 1477 } |
| 1479 | 1478 |
| 1480 CanvasPattern* CanvasRenderingContext2D::createPattern(const CanvasImageSourceUn
ion& imageSource, const String& repetitionType, ExceptionState& exceptionState) | 1479 CanvasPattern* CanvasRenderingContext2D::createPattern(const CanvasImageSourceUn
ion& imageSource, const String& repetitionType, ExceptionState& exceptionState) |
| 1481 { | 1480 { |
| 1482 Pattern::RepeatMode repeatMode = CanvasPattern::parseRepetitionType(repetiti
onType, exceptionState); | 1481 Pattern::RepeatMode repeatMode = CanvasPattern::parseRepetitionType(repetiti
onType, exceptionState); |
| 1483 if (exceptionState.hadException()) | 1482 if (exceptionState.hadException()) |
| 1484 return nullptr; | 1483 return nullptr; |
| 1485 | 1484 |
| 1486 SourceImageStatus status; | 1485 SourceImageStatus status; |
| 1487 CanvasImageSource* imageSourceInternal = toImageSourceInternal(imageSource); | 1486 CanvasImageSource* imageSourceInternal = toImageSourceInternal(imageSource); |
| 1488 RefPtr<Image> imageForRendering = imageSourceInternal->getSourceImageForCanv
as(&status, PreferNoAcceleration); | 1487 RefPtr<Image> imageForRendering = imageSourceInternal->getSourceImageForCanv
as(&status); |
| 1489 | 1488 |
| 1490 switch (status) { | 1489 switch (status) { |
| 1491 case NormalSourceImageStatus: | 1490 case NormalSourceImageStatus: |
| 1492 break; | 1491 break; |
| 1493 case ZeroSizeCanvasSourceImageStatus: | 1492 case ZeroSizeCanvasSourceImageStatus: |
| 1494 exceptionState.throwDOMException(InvalidStateError, String::format("The
canvas %s is 0.", imageSourceInternal->elementSize().width() ? "height" : "width
")); | 1493 exceptionState.throwDOMException(InvalidStateError, String::format("The
canvas %s is 0.", imageSourceInternal->elementSize().width() ? "height" : "width
")); |
| 1495 return nullptr; | 1494 return nullptr; |
| 1496 case UndecodableSourceImageStatus: | 1495 case UndecodableSourceImageStatus: |
| 1497 exceptionState.throwDOMException(InvalidStateError, "Source image is in
the 'broken' state."); | 1496 exceptionState.throwDOMException(InvalidStateError, "Source image is in
the 'broken' state."); |
| 1498 return nullptr; | 1497 return nullptr; |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1768 void CanvasRenderingContext2D::schedulePruneLocalFontCacheIfNeeded() | 1767 void CanvasRenderingContext2D::schedulePruneLocalFontCacheIfNeeded() |
| 1769 { | 1768 { |
| 1770 if (m_pruneLocalFontCacheScheduled) | 1769 if (m_pruneLocalFontCacheScheduled) |
| 1771 return; | 1770 return; |
| 1772 m_pruneLocalFontCacheScheduled = true; | 1771 m_pruneLocalFontCacheScheduled = true; |
| 1773 Platform::current()->currentThread()->addTaskObserver(this); | 1772 Platform::current()->currentThread()->addTaskObserver(this); |
| 1774 } | 1773 } |
| 1775 | 1774 |
| 1776 void CanvasRenderingContext2D::didProcessTask() | 1775 void CanvasRenderingContext2D::didProcessTask() |
| 1777 { | 1776 { |
| 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 | |
| 1782 pruneLocalFontCache(canvas()->document().canvasFontCache()->maxFonts()); | 1777 pruneLocalFontCache(canvas()->document().canvasFontCache()->maxFonts()); |
| 1783 m_pruneLocalFontCacheScheduled = false; | 1778 m_pruneLocalFontCacheScheduled = false; |
| 1784 Platform::current()->currentThread()->removeTaskObserver(this); | 1779 Platform::current()->currentThread()->removeTaskObserver(this); |
| 1785 } | 1780 } |
| 1786 | 1781 |
| 1787 void CanvasRenderingContext2D::pruneLocalFontCache(size_t targetSize) | 1782 void CanvasRenderingContext2D::pruneLocalFontCache(size_t targetSize) |
| 1788 { | 1783 { |
| 1789 if (targetSize == 0) { | 1784 if (targetSize == 0) { |
| 1790 // Short cut: LRU does not matter when evicting everything | 1785 // Short cut: LRU does not matter when evicting everything |
| 1791 m_fontLRUList.clear(); | 1786 m_fontLRUList.clear(); |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1996 case RightTextAlign: | 1991 case RightTextAlign: |
| 1997 location.setX(location.x() - width); | 1992 location.setX(location.x() - width); |
| 1998 break; | 1993 break; |
| 1999 default: | 1994 default: |
| 2000 break; | 1995 break; |
| 2001 } | 1996 } |
| 2002 | 1997 |
| 2003 // The slop built in to this mask rect matches the heuristic used in FontCGW
in.cpp for GDI text. | 1998 // The slop built in to this mask rect matches the heuristic used in FontCGW
in.cpp for GDI text. |
| 2004 TextRunPaintInfo textRunPaintInfo(textRun); | 1999 TextRunPaintInfo textRunPaintInfo(textRun); |
| 2005 textRunPaintInfo.bounds = FloatRect(location.x() - fontMetrics.height() / 2, | 2000 textRunPaintInfo.bounds = FloatRect(location.x() - fontMetrics.height() / 2, |
| 2006 location.y() - fontMetrics.ascent() - fontMetrics.lineGap(), | 2001 location.y() - fontMetrics.ascent() - fo
ntMetrics.lineGap(), |
| 2007 width + fontMetrics.height(), | 2002 width + fontMetrics.height(), |
| 2008 fontMetrics.lineSpacing()); | 2003 fontMetrics.lineSpacing()); |
| 2009 if (paintType == CanvasRenderingContext2DState::StrokePaintType) | 2004 if (paintType == CanvasRenderingContext2DState::StrokePaintType) |
| 2010 inflateStrokeRect(textRunPaintInfo.bounds); | 2005 inflateStrokeRect(textRunPaintInfo.bounds); |
| 2011 | 2006 |
| 2012 CanvasRenderingContext2DAutoRestoreSkCanvas stateRestorer(this); | 2007 CanvasRenderingContext2DAutoRestoreSkCanvas stateRestorer(this); |
| 2013 if (useMaxWidth) { | 2008 if (useMaxWidth) { |
| 2014 drawingCanvas()->save(); | 2009 drawingCanvas()->save(); |
| 2015 drawingCanvas()->translate(location.x(), location.y()); | 2010 drawingCanvas()->translate(location.x(), location.y()); |
| 2016 // We draw when fontWidth is 0 so compositing operations (eg, a "copy" o
p) still work. | 2011 // We draw when fontWidth is 0 so compositing operations (eg, a "copy" o
p) still work. |
| 2017 drawingCanvas()->scale((fontWidth > 0 ? (width / fontWidth) : 0), 1); | 2012 drawingCanvas()->scale((fontWidth > 0 ? (width / fontWidth) : 0), 1); |
| 2018 location = FloatPoint(); | 2013 location = FloatPoint(); |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2324 if (imageType == CanvasRenderingContext2DState::NonOpaqueImage) | 2319 if (imageType == CanvasRenderingContext2DState::NonOpaqueImage) |
| 2325 return; | 2320 return; |
| 2326 if (alpha < 0xFF) | 2321 if (alpha < 0xFF) |
| 2327 return; | 2322 return; |
| 2328 } | 2323 } |
| 2329 | 2324 |
| 2330 canvas()->buffer()->willOverwriteCanvas(); | 2325 canvas()->buffer()->willOverwriteCanvas(); |
| 2331 } | 2326 } |
| 2332 | 2327 |
| 2333 } // namespace blink | 2328 } // namespace blink |
| OLD | NEW |