OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
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 * | 8 * |
9 * Redistribution and use in source and binary forms, with or without | 9 * Redistribution and use in source and binary forms, with or without |
10 * modification, are permitted provided that the following conditions | 10 * modification, are permitted provided that the following conditions |
(...skipping 1614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1625 return 0; | 1625 return 0; |
1626 } | 1626 } |
1627 | 1627 |
1628 FloatSize unscaledSize(fabs(sw), fabs(sh)); | 1628 FloatSize unscaledSize(fabs(sw), fabs(sh)); |
1629 IntSize scaledSize = canvas()->convertLogicalToDevice(unscaledSize); | 1629 IntSize scaledSize = canvas()->convertLogicalToDevice(unscaledSize); |
1630 if (scaledSize.width() < 1) | 1630 if (scaledSize.width() < 1) |
1631 scaledSize.setWidth(1); | 1631 scaledSize.setWidth(1); |
1632 if (scaledSize.height() < 1) | 1632 if (scaledSize.height() < 1) |
1633 scaledSize.setHeight(1); | 1633 scaledSize.setHeight(1); |
1634 | 1634 |
| 1635 float area = 4.0f * scaledSize.width() * scaledSize.height(); |
| 1636 if (area > static_cast<float>(std::numeric_limits<int>::max())) |
| 1637 return 0; |
| 1638 |
1635 return createEmptyImageData(scaledSize); | 1639 return createEmptyImageData(scaledSize); |
1636 } | 1640 } |
1637 | 1641 |
1638 PassRefPtr<ImageData> CanvasRenderingContext2D::getImageData(float sx, float sy,
float sw, float sh, ExceptionCode& ec) const | 1642 PassRefPtr<ImageData> CanvasRenderingContext2D::getImageData(float sx, float sy,
float sw, float sh, ExceptionCode& ec) const |
1639 { | 1643 { |
1640 if (!canvas()->originClean()) { | 1644 if (!canvas()->originClean()) { |
1641 ec = SECURITY_ERR; | 1645 ec = SECURITY_ERR; |
1642 return 0; | 1646 return 0; |
1643 } | 1647 } |
1644 if (!sw || !sh) { | 1648 if (!sw || !sh) { |
(...skipping 16 matching lines...) Expand all Loading... |
1661 | 1665 |
1662 FloatRect unscaledRect(sx, sy, sw, sh); | 1666 FloatRect unscaledRect(sx, sy, sw, sh); |
1663 IntRect scaledRect = canvas()->convertLogicalToDevice(unscaledRect); | 1667 IntRect scaledRect = canvas()->convertLogicalToDevice(unscaledRect); |
1664 if (scaledRect.width() < 1) | 1668 if (scaledRect.width() < 1) |
1665 scaledRect.setWidth(1); | 1669 scaledRect.setWidth(1); |
1666 if (scaledRect.height() < 1) | 1670 if (scaledRect.height() < 1) |
1667 scaledRect.setHeight(1); | 1671 scaledRect.setHeight(1); |
1668 ImageBuffer* buffer = canvas()->buffer(); | 1672 ImageBuffer* buffer = canvas()->buffer(); |
1669 if (!buffer) | 1673 if (!buffer) |
1670 return createEmptyImageData(scaledRect.size()); | 1674 return createEmptyImageData(scaledRect.size()); |
1671 return ImageData::create(scaledRect.size(), buffer->getUnmultipliedImageData
(scaledRect)); | 1675 |
| 1676 RefPtr<ByteArray> byteArray = buffer->getUnmultipliedImageData(scaledRect); |
| 1677 if (!byteArray) |
| 1678 return 0; |
| 1679 |
| 1680 return ImageData::create(scaledRect.size(), byteArray.release()); |
1672 } | 1681 } |
1673 | 1682 |
1674 void CanvasRenderingContext2D::putImageData(ImageData* data, float dx, float dy,
ExceptionCode& ec) | 1683 void CanvasRenderingContext2D::putImageData(ImageData* data, float dx, float dy,
ExceptionCode& ec) |
1675 { | 1684 { |
1676 if (!data) { | 1685 if (!data) { |
1677 ec = TYPE_MISMATCH_ERR; | 1686 ec = TYPE_MISMATCH_ERR; |
1678 return; | 1687 return; |
1679 } | 1688 } |
1680 putImageData(data, dx, dy, 0, 0, data->width(), data->height(), ec); | 1689 putImageData(data, dx, dy, 0, 0, data->width(), data->height(), ec); |
1681 } | 1690 } |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1968 } | 1977 } |
1969 | 1978 |
1970 #if ENABLE(ACCELERATED_2D_CANVAS) && USE(ACCELERATED_COMPOSITING) | 1979 #if ENABLE(ACCELERATED_2D_CANVAS) && USE(ACCELERATED_COMPOSITING) |
1971 PlatformLayer* CanvasRenderingContext2D::platformLayer() const | 1980 PlatformLayer* CanvasRenderingContext2D::platformLayer() const |
1972 { | 1981 { |
1973 return m_drawingBuffer ? m_drawingBuffer->platformLayer() : 0; | 1982 return m_drawingBuffer ? m_drawingBuffer->platformLayer() : 0; |
1974 } | 1983 } |
1975 #endif | 1984 #endif |
1976 | 1985 |
1977 } // namespace WebCore | 1986 } // namespace WebCore |
OLD | NEW |