| 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 1854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1865 | 1865 |
| 1866 IntSize size = expandedIntSize(logicalSize); | 1866 IntSize size = expandedIntSize(logicalSize); |
| 1867 if (size.width() < 1) | 1867 if (size.width() < 1) |
| 1868 size.setWidth(1); | 1868 size.setWidth(1); |
| 1869 if (size.height() < 1) | 1869 if (size.height() < 1) |
| 1870 size.setHeight(1); | 1870 size.setHeight(1); |
| 1871 | 1871 |
| 1872 return createEmptyImageData(size); | 1872 return createEmptyImageData(size); |
| 1873 } | 1873 } |
| 1874 | 1874 |
| 1875 PassRefPtr<ImageData> CanvasRenderingContext2D::webkitGetImageDataHD(float sx, f
loat sy, float sw, float sh, ExceptionState& exceptionState) const |
| 1876 { |
| 1877 return getImageData(sx, sy, sw, sh, exceptionState); |
| 1878 } |
| 1879 |
| 1875 PassRefPtr<ImageData> CanvasRenderingContext2D::getImageData(float sx, float sy,
float sw, float sh, ExceptionState& exceptionState) const | 1880 PassRefPtr<ImageData> CanvasRenderingContext2D::getImageData(float sx, float sy,
float sw, float sh, ExceptionState& exceptionState) const |
| 1876 { | 1881 { |
| 1877 return getImageData(ImageBuffer::LogicalCoordinateSystem, sx, sy, sw, sh, ex
ceptionState); | |
| 1878 } | |
| 1879 | |
| 1880 PassRefPtr<ImageData> CanvasRenderingContext2D::webkitGetImageDataHD(float sx, f
loat sy, float sw, float sh, ExceptionState& exceptionState) const | |
| 1881 { | |
| 1882 return getImageData(ImageBuffer::BackingStoreCoordinateSystem, sx, sy, sw, s
h, exceptionState); | |
| 1883 } | |
| 1884 | |
| 1885 PassRefPtr<ImageData> CanvasRenderingContext2D::getImageData(ImageBuffer::Coordi
nateSystem coordinateSystem, float sx, float sy, float sw, float sh, ExceptionSt
ate& exceptionState) const | |
| 1886 { | |
| 1887 if (!canvas()->originClean()) { | 1882 if (!canvas()->originClean()) { |
| 1888 exceptionState.throwSecurityError("The canvas has been tainted by cross-
origin data."); | 1883 exceptionState.throwSecurityError("The canvas has been tainted by cross-
origin data."); |
| 1889 return 0; | 1884 return 0; |
| 1890 } | 1885 } |
| 1891 | 1886 |
| 1892 if (!sw || !sh) { | 1887 if (!sw || !sh) { |
| 1893 exceptionState.throwUninformativeAndGenericDOMException(IndexSizeError); | 1888 exceptionState.throwUninformativeAndGenericDOMException(IndexSizeError); |
| 1894 return 0; | 1889 return 0; |
| 1895 } | 1890 } |
| 1896 if (!std::isfinite(sx) || !std::isfinite(sy) || !std::isfinite(sw) || !std::
isfinite(sh)) { | 1891 if (!std::isfinite(sx) || !std::isfinite(sy) || !std::isfinite(sw) || !std::
isfinite(sh)) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1913 if (logicalRect.height() < 1) | 1908 if (logicalRect.height() < 1) |
| 1914 logicalRect.setHeight(1); | 1909 logicalRect.setHeight(1); |
| 1915 if (!logicalRect.isExpressibleAsIntRect()) | 1910 if (!logicalRect.isExpressibleAsIntRect()) |
| 1916 return 0; | 1911 return 0; |
| 1917 | 1912 |
| 1918 IntRect imageDataRect = enclosingIntRect(logicalRect); | 1913 IntRect imageDataRect = enclosingIntRect(logicalRect); |
| 1919 ImageBuffer* buffer = canvas()->buffer(); | 1914 ImageBuffer* buffer = canvas()->buffer(); |
| 1920 if (!buffer) | 1915 if (!buffer) |
| 1921 return createEmptyImageData(imageDataRect.size()); | 1916 return createEmptyImageData(imageDataRect.size()); |
| 1922 | 1917 |
| 1923 RefPtr<Uint8ClampedArray> byteArray = buffer->getUnmultipliedImageData(image
DataRect, coordinateSystem); | 1918 RefPtr<Uint8ClampedArray> byteArray = buffer->getUnmultipliedImageData(image
DataRect); |
| 1924 if (!byteArray) | 1919 if (!byteArray) |
| 1925 return 0; | 1920 return 0; |
| 1926 | 1921 |
| 1927 return ImageData::create(imageDataRect.size(), byteArray.release()); | 1922 return ImageData::create(imageDataRect.size(), byteArray.release()); |
| 1928 } | 1923 } |
| 1929 | 1924 |
| 1930 void CanvasRenderingContext2D::putImageData(ImageData* data, float dx, float dy,
ExceptionState& exceptionState) | 1925 void CanvasRenderingContext2D::putImageData(ImageData* data, float dx, float dy,
ExceptionState& exceptionState) |
| 1931 { | 1926 { |
| 1932 if (!data) { | 1927 if (!data) { |
| 1933 exceptionState.throwUninformativeAndGenericDOMException(TypeMismatchErro
r); | 1928 exceptionState.throwUninformativeAndGenericDOMException(TypeMismatchErro
r); |
| 1934 return; | 1929 return; |
| 1935 } | 1930 } |
| 1936 putImageData(data, dx, dy, 0, 0, data->width(), data->height(), exceptionSta
te); | 1931 putImageData(data, dx, dy, 0, 0, data->width(), data->height(), exceptionSta
te); |
| 1937 } | 1932 } |
| 1938 | 1933 |
| 1939 void CanvasRenderingContext2D::webkitPutImageDataHD(ImageData* data, float dx, f
loat dy, ExceptionState& exceptionState) | |
| 1940 { | |
| 1941 if (!data) { | |
| 1942 exceptionState.throwUninformativeAndGenericDOMException(TypeMismatchErro
r); | |
| 1943 return; | |
| 1944 } | |
| 1945 webkitPutImageDataHD(data, dx, dy, 0, 0, data->width(), data->height(), exce
ptionState); | |
| 1946 } | |
| 1947 | |
| 1948 void CanvasRenderingContext2D::putImageData(ImageData* data, float dx, float dy,
float dirtyX, float dirtyY, | 1934 void CanvasRenderingContext2D::putImageData(ImageData* data, float dx, float dy,
float dirtyX, float dirtyY, |
| 1949 float dirtyWidth, float dirtyHeight, ExceptionState& exceptionState) | 1935 float dirtyWidth, float dirtyHeight, ExceptionState& exceptionState) |
| 1950 { | 1936 { |
| 1951 putImageData(data, ImageBuffer::LogicalCoordinateSystem, dx, dy, dirtyX, dir
tyY, dirtyWidth, dirtyHeight, exceptionState); | |
| 1952 } | |
| 1953 | |
| 1954 void CanvasRenderingContext2D::webkitPutImageDataHD(ImageData* data, float dx, f
loat dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight, Except
ionState& exceptionState) | |
| 1955 { | |
| 1956 putImageData(data, ImageBuffer::BackingStoreCoordinateSystem, dx, dy, dirtyX
, dirtyY, dirtyWidth, dirtyHeight, exceptionState); | |
| 1957 } | |
| 1958 | |
| 1959 void CanvasRenderingContext2D::putImageData(ImageData* data, ImageBuffer::Coordi
nateSystem coordinateSystem, float dx, float dy, float dirtyX, float dirtyY, | |
| 1960 float dirtyWidth, float dirtyHeight, ExceptionState& exceptionState) | |
| 1961 { | |
| 1962 if (!data) { | 1937 if (!data) { |
| 1963 exceptionState.throwUninformativeAndGenericDOMException(TypeMismatchErro
r); | 1938 exceptionState.throwUninformativeAndGenericDOMException(TypeMismatchErro
r); |
| 1964 return; | 1939 return; |
| 1965 } | 1940 } |
| 1966 if (!std::isfinite(dx) || !std::isfinite(dy) || !std::isfinite(dirtyX) || !s
td::isfinite(dirtyY) || !std::isfinite(dirtyWidth) || !std::isfinite(dirtyHeight
)) { | 1941 if (!std::isfinite(dx) || !std::isfinite(dy) || !std::isfinite(dirtyX) || !s
td::isfinite(dirtyY) || !std::isfinite(dirtyWidth) || !std::isfinite(dirtyHeight
)) { |
| 1967 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedErro
r); | 1942 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedErro
r); |
| 1968 return; | 1943 return; |
| 1969 } | 1944 } |
| 1970 | 1945 |
| 1971 ImageBuffer* buffer = canvas()->buffer(); | 1946 ImageBuffer* buffer = canvas()->buffer(); |
| 1972 if (!buffer) | 1947 if (!buffer) |
| 1973 return; | 1948 return; |
| 1974 | 1949 |
| 1975 if (dirtyWidth < 0) { | 1950 if (dirtyWidth < 0) { |
| 1976 dirtyX += dirtyWidth; | 1951 dirtyX += dirtyWidth; |
| 1977 dirtyWidth = -dirtyWidth; | 1952 dirtyWidth = -dirtyWidth; |
| 1978 } | 1953 } |
| 1979 | 1954 |
| 1980 if (dirtyHeight < 0) { | 1955 if (dirtyHeight < 0) { |
| 1981 dirtyY += dirtyHeight; | 1956 dirtyY += dirtyHeight; |
| 1982 dirtyHeight = -dirtyHeight; | 1957 dirtyHeight = -dirtyHeight; |
| 1983 } | 1958 } |
| 1984 | 1959 |
| 1985 FloatRect clipRect(dirtyX, dirtyY, dirtyWidth, dirtyHeight); | 1960 FloatRect clipRect(dirtyX, dirtyY, dirtyWidth, dirtyHeight); |
| 1986 clipRect.intersect(IntRect(0, 0, data->width(), data->height())); | 1961 clipRect.intersect(IntRect(0, 0, data->width(), data->height())); |
| 1987 IntSize destOffset(static_cast<int>(dx), static_cast<int>(dy)); | 1962 IntSize destOffset(static_cast<int>(dx), static_cast<int>(dy)); |
| 1988 IntRect destRect = enclosingIntRect(clipRect); | 1963 IntRect destRect = enclosingIntRect(clipRect); |
| 1989 destRect.move(destOffset); | 1964 destRect.move(destOffset); |
| 1990 destRect.intersect(IntRect(IntPoint(), coordinateSystem == ImageBuffer::Logi
calCoordinateSystem ? buffer->logicalSize() : buffer->internalSize())); | 1965 destRect.intersect(IntRect(IntPoint(), buffer->size())); |
| 1991 if (destRect.isEmpty()) | 1966 if (destRect.isEmpty()) |
| 1992 return; | 1967 return; |
| 1993 IntRect sourceRect(destRect); | 1968 IntRect sourceRect(destRect); |
| 1994 sourceRect.move(-destOffset); | 1969 sourceRect.move(-destOffset); |
| 1995 | 1970 |
| 1996 buffer->putByteArray(Unmultiplied, data->data(), IntSize(data->width(), data
->height()), sourceRect, IntPoint(destOffset), coordinateSystem); | 1971 buffer->putByteArray(Unmultiplied, data->data(), IntSize(data->width(), data
->height()), sourceRect, IntPoint(destOffset)); |
| 1997 | 1972 |
| 1998 if (coordinateSystem == ImageBuffer::BackingStoreCoordinateSystem) { | |
| 1999 FloatRect dirtyRect = destRect; | |
| 2000 dirtyRect.scale(1 / canvas()->deviceScaleFactor()); | |
| 2001 destRect = enclosingIntRect(dirtyRect); | |
| 2002 } | |
| 2003 didDraw(destRect); | 1973 didDraw(destRect); |
| 2004 } | 1974 } |
| 2005 | 1975 |
| 2006 String CanvasRenderingContext2D::font() const | 1976 String CanvasRenderingContext2D::font() const |
| 2007 { | 1977 { |
| 2008 if (!state().m_realizedFont) | 1978 if (!state().m_realizedFont) |
| 2009 return defaultFont; | 1979 return defaultFont; |
| 2010 | 1980 |
| 2011 StringBuilder serializedFont; | 1981 StringBuilder serializedFont; |
| 2012 const FontDescription& fontDescription = state().m_font.fontDescription(); | 1982 const FontDescription& fontDescription = state().m_font.fontDescription(); |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2430 const int focusRingWidth = 5; | 2400 const int focusRingWidth = 5; |
| 2431 const int focusRingOutline = 0; | 2401 const int focusRingOutline = 0; |
| 2432 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor); | 2402 c->drawFocusRing(path, focusRingWidth, focusRingOutline, focusRingColor); |
| 2433 | 2403 |
| 2434 c->restore(); | 2404 c->restore(); |
| 2435 | 2405 |
| 2436 didDraw(dirtyRect); | 2406 didDraw(dirtyRect); |
| 2437 } | 2407 } |
| 2438 | 2408 |
| 2439 } // namespace WebCore | 2409 } // namespace WebCore |
| OLD | NEW |