| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2006, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2009, 2010 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 3 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
| 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 #include "bindings/core/v8/ScriptValue.h" | 31 #include "bindings/core/v8/ScriptValue.h" |
| 32 #include "bindings/core/v8/UnionTypesCore.h" | 32 #include "bindings/core/v8/UnionTypesCore.h" |
| 33 #include "core/CoreExport.h" | 33 #include "core/CoreExport.h" |
| 34 #include "core/dom/DOMTypedArray.h" | 34 #include "core/dom/DOMTypedArray.h" |
| 35 #include "core/dom/Document.h" | 35 #include "core/dom/Document.h" |
| 36 #include "core/dom/DocumentVisibilityObserver.h" | 36 #include "core/dom/DocumentVisibilityObserver.h" |
| 37 #include "core/fileapi/FileCallback.h" | 37 #include "core/fileapi/FileCallback.h" |
| 38 #include "core/html/HTMLElement.h" | 38 #include "core/html/HTMLElement.h" |
| 39 #include "core/html/canvas/CanvasImageSource.h" | 39 #include "core/html/canvas/CanvasImageSource.h" |
| 40 #include "core/imagebitmap/ImageBitmapSource.h" |
| 40 #include "platform/geometry/FloatRect.h" | 41 #include "platform/geometry/FloatRect.h" |
| 41 #include "platform/geometry/IntSize.h" | 42 #include "platform/geometry/IntSize.h" |
| 42 #include "platform/graphics/GraphicsTypes.h" | 43 #include "platform/graphics/GraphicsTypes.h" |
| 43 #include "platform/graphics/GraphicsTypes3D.h" | 44 #include "platform/graphics/GraphicsTypes3D.h" |
| 44 #include "platform/graphics/ImageBufferClient.h" | 45 #include "platform/graphics/ImageBufferClient.h" |
| 45 #include "platform/heap/Handle.h" | 46 #include "platform/heap/Handle.h" |
| 46 | 47 |
| 47 #define CanvasDefaultInterpolationQuality InterpolationLow | 48 #define CanvasDefaultInterpolationQuality InterpolationLow |
| 48 | 49 |
| 49 namespace blink { | 50 namespace blink { |
| 50 | 51 |
| 51 class AffineTransform; | 52 class AffineTransform; |
| 52 class CanvasContextCreationAttributes; | 53 class CanvasContextCreationAttributes; |
| 53 class CanvasRenderingContext; | 54 class CanvasRenderingContext; |
| 54 class CanvasRenderingContextFactory; | 55 class CanvasRenderingContextFactory; |
| 55 class GraphicsContext; | 56 class GraphicsContext; |
| 56 class HTMLCanvasElement; | 57 class HTMLCanvasElement; |
| 57 class Image; | 58 class Image; |
| 58 class ImageBuffer; | 59 class ImageBuffer; |
| 59 class ImageBufferSurface; | 60 class ImageBufferSurface; |
| 60 class ImageData; | 61 class ImageData; |
| 61 class IntSize; | 62 class IntSize; |
| 62 | 63 |
| 63 class CORE_EXPORT HTMLCanvasElement final : public HTMLElement, public DocumentV
isibilityObserver, public CanvasImageSource, public ImageBufferClient { | 64 class CORE_EXPORT HTMLCanvasElement final : public HTMLElement, public DocumentV
isibilityObserver, public CanvasImageSource, public ImageBufferClient, public Im
ageBitmapSource { |
| 64 DEFINE_WRAPPERTYPEINFO(); | 65 DEFINE_WRAPPERTYPEINFO(); |
| 65 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLCanvasElement); | 66 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLCanvasElement); |
| 66 public: | 67 public: |
| 67 DECLARE_NODE_FACTORY(HTMLCanvasElement); | 68 DECLARE_NODE_FACTORY(HTMLCanvasElement); |
| 68 ~HTMLCanvasElement() override; | 69 ~HTMLCanvasElement() override; |
| 69 | 70 |
| 70 // Attributes and functions exposed to script | 71 // Attributes and functions exposed to script |
| 71 int width() const { return size().width(); } | 72 int width() const { return size().width(); } |
| 72 int height() const { return size().height(); } | 73 int height() const { return size().height(); } |
| 73 | 74 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 bool isOpaque() const override; | 152 bool isOpaque() const override; |
| 152 | 153 |
| 153 // ImageBufferClient implementation | 154 // ImageBufferClient implementation |
| 154 void notifySurfaceInvalid() override; | 155 void notifySurfaceInvalid() override; |
| 155 bool isDirty() override { return !m_dirtyRect.isEmpty(); } | 156 bool isDirty() override { return !m_dirtyRect.isEmpty(); } |
| 156 void didFinalizeFrame() override; | 157 void didFinalizeFrame() override; |
| 157 void restoreCanvasMatrixClipStack(SkCanvas*) const override; | 158 void restoreCanvasMatrixClipStack(SkCanvas*) const override; |
| 158 | 159 |
| 159 void doDeferredPaintInvalidation(); | 160 void doDeferredPaintInvalidation(); |
| 160 | 161 |
| 162 // ImageBitmapSource implementation |
| 163 IntSize bitmapSourceSize() const override; |
| 164 ScriptPromise createImageBitmap(ScriptState*, EventTarget&, ImageBitmapSourc
e*, int sx, int sy, int sw, int sh, ExceptionState&) override; |
| 165 |
| 161 DECLARE_VIRTUAL_TRACE(); | 166 DECLARE_VIRTUAL_TRACE(); |
| 162 | 167 |
| 163 void createImageBufferUsingSurfaceForTesting(PassOwnPtr<ImageBufferSurface>)
; | 168 void createImageBufferUsingSurfaceForTesting(PassOwnPtr<ImageBufferSurface>)
; |
| 164 | 169 |
| 165 static void registerRenderingContextFactory(PassOwnPtr<CanvasRenderingContex
tFactory>); | 170 static void registerRenderingContextFactory(PassOwnPtr<CanvasRenderingContex
tFactory>); |
| 166 void updateExternallyAllocatedMemory() const; | 171 void updateExternallyAllocatedMemory() const; |
| 167 | 172 |
| 168 void styleDidChange(const ComputedStyle* oldStyle, const ComputedStyle& newS
tyle); | 173 void styleDidChange(const ComputedStyle* oldStyle, const ComputedStyle& newS
tyle); |
| 169 | 174 |
| 170 protected: | 175 protected: |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 mutable bool m_didFailToCreateImageBuffer; | 217 mutable bool m_didFailToCreateImageBuffer; |
| 213 bool m_imageBufferIsClear; | 218 bool m_imageBufferIsClear; |
| 214 OwnPtr<ImageBuffer> m_imageBuffer; | 219 OwnPtr<ImageBuffer> m_imageBuffer; |
| 215 | 220 |
| 216 mutable RefPtr<Image> m_copiedImage; // FIXME: This is temporary for platfor
ms that have to copy the image buffer to render (and for CSSCanvasValue). | 221 mutable RefPtr<Image> m_copiedImage; // FIXME: This is temporary for platfor
ms that have to copy the image buffer to render (and for CSSCanvasValue). |
| 217 }; | 222 }; |
| 218 | 223 |
| 219 } // namespace blink | 224 } // namespace blink |
| 220 | 225 |
| 221 #endif // HTMLCanvasElement_h | 226 #endif // HTMLCanvasElement_h |
| OLD | NEW |