| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 #endif | 66 #endif |
| 67 | 67 |
| 68 DEFINE_INLINE_VIRTUAL_TRACE() { } | 68 DEFINE_INLINE_VIRTUAL_TRACE() { } |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 class CORE_EXPORT HTMLCanvasElement final : public HTMLElement, public DocumentV
isibilityObserver, public CanvasImageSource, public ImageBufferClient { | 71 class CORE_EXPORT HTMLCanvasElement final : public HTMLElement, public DocumentV
isibilityObserver, public CanvasImageSource, public ImageBufferClient { |
| 72 DEFINE_WRAPPERTYPEINFO(); | 72 DEFINE_WRAPPERTYPEINFO(); |
| 73 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLCanvasElement); | 73 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLCanvasElement); |
| 74 public: | 74 public: |
| 75 DECLARE_NODE_FACTORY(HTMLCanvasElement); | 75 DECLARE_NODE_FACTORY(HTMLCanvasElement); |
| 76 virtual ~HTMLCanvasElement(); | 76 ~HTMLCanvasElement() override; |
| 77 | 77 |
| 78 void addObserver(CanvasObserver*); | 78 void addObserver(CanvasObserver*); |
| 79 void removeObserver(CanvasObserver*); | 79 void removeObserver(CanvasObserver*); |
| 80 | 80 |
| 81 // Attributes and functions exposed to script | 81 // Attributes and functions exposed to script |
| 82 int width() const { return size().width(); } | 82 int width() const { return size().width(); } |
| 83 int height() const { return size().height(); } | 83 int height() const { return size().height(); } |
| 84 | 84 |
| 85 const IntSize& size() const { return m_size; } | 85 const IntSize& size() const { return m_size; } |
| 86 | 86 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 | 134 |
| 135 bool is3D() const; | 135 bool is3D() const; |
| 136 | 136 |
| 137 bool hasImageBuffer() const { return m_imageBuffer; } | 137 bool hasImageBuffer() const { return m_imageBuffer; } |
| 138 void discardImageBuffer(); | 138 void discardImageBuffer(); |
| 139 | 139 |
| 140 bool shouldAccelerate(const IntSize&) const; | 140 bool shouldAccelerate(const IntSize&) const; |
| 141 | 141 |
| 142 bool shouldBeDirectComposited() const; | 142 bool shouldBeDirectComposited() const; |
| 143 | 143 |
| 144 virtual const AtomicString imageSourceURL() const override; | 144 const AtomicString imageSourceURL() const override; |
| 145 | 145 |
| 146 virtual InsertionNotificationRequest insertedInto(ContainerNode*) override; | 146 InsertionNotificationRequest insertedInto(ContainerNode*) override; |
| 147 | 147 |
| 148 // DocumentVisibilityObserver implementation | 148 // DocumentVisibilityObserver implementation |
| 149 virtual void didChangeVisibilityState(PageVisibilityState) override; | 149 void didChangeVisibilityState(PageVisibilityState) override; |
| 150 | 150 |
| 151 // CanvasImageSource implementation | 151 // CanvasImageSource implementation |
| 152 virtual PassRefPtr<Image> getSourceImageForCanvas(SourceImageMode, SourceIma
geStatus*) const override; | 152 PassRefPtr<Image> getSourceImageForCanvas(SourceImageMode, SourceImageStatus
*) const override; |
| 153 virtual bool wouldTaintOrigin(SecurityOrigin*) const override; | 153 bool wouldTaintOrigin(SecurityOrigin*) const override; |
| 154 virtual FloatSize elementSize() const override; | 154 FloatSize elementSize() const override; |
| 155 virtual bool isCanvasElement() const override { return true; } | 155 bool isCanvasElement() const override { return true; } |
| 156 virtual bool isOpaque() const override; | 156 bool isOpaque() const override; |
| 157 | 157 |
| 158 // ImageBufferClient implementation | 158 // ImageBufferClient implementation |
| 159 virtual void notifySurfaceInvalid() override; | 159 void notifySurfaceInvalid() override; |
| 160 virtual bool isDirty() override { return !m_dirtyRect.isEmpty(); } | 160 bool isDirty() override { return !m_dirtyRect.isEmpty(); } |
| 161 virtual void didFinalizeFrame() override; | 161 void didFinalizeFrame() override; |
| 162 virtual void restoreCanvasMatrixClipStack() override; | 162 void restoreCanvasMatrixClipStack() override; |
| 163 | 163 |
| 164 void doDeferredPaintInvalidation(); | 164 void doDeferredPaintInvalidation(); |
| 165 | 165 |
| 166 DECLARE_VIRTUAL_TRACE(); | 166 DECLARE_VIRTUAL_TRACE(); |
| 167 | 167 |
| 168 void createImageBufferUsingSurfaceForTesting(PassOwnPtr<ImageBufferSurface>)
; | 168 void createImageBufferUsingSurfaceForTesting(PassOwnPtr<ImageBufferSurface>)
; |
| 169 | 169 |
| 170 static void registerRenderingContextFactory(PassOwnPtr<CanvasRenderingContex
tFactory>); | 170 static void registerRenderingContextFactory(PassOwnPtr<CanvasRenderingContex
tFactory>); |
| 171 | 171 |
| 172 protected: | 172 protected: |
| 173 virtual void didMoveToNewDocument(Document& oldDocument) override; | 173 void didMoveToNewDocument(Document& oldDocument) override; |
| 174 | 174 |
| 175 private: | 175 private: |
| 176 explicit HTMLCanvasElement(Document&); | 176 explicit HTMLCanvasElement(Document&); |
| 177 | 177 |
| 178 using ContextFactoryVector = Vector<OwnPtr<CanvasRenderingContextFactory>>; | 178 using ContextFactoryVector = Vector<OwnPtr<CanvasRenderingContextFactory>>; |
| 179 static ContextFactoryVector& renderingContextFactories(); | 179 static ContextFactoryVector& renderingContextFactories(); |
| 180 static CanvasRenderingContextFactory* getRenderingContextFactory(int); | 180 static CanvasRenderingContextFactory* getRenderingContextFactory(int); |
| 181 | 181 |
| 182 virtual void parseAttribute(const QualifiedName&, const AtomicString&) overr
ide; | 182 void parseAttribute(const QualifiedName&, const AtomicString&) override; |
| 183 virtual LayoutObject* createLayoutObject(const ComputedStyle&) override; | 183 LayoutObject* createLayoutObject(const ComputedStyle&) override; |
| 184 virtual void didRecalcStyle(StyleRecalcChange) override; | 184 void didRecalcStyle(StyleRecalcChange) override; |
| 185 virtual bool areAuthorShadowsAllowed() const override { return false; } | 185 bool areAuthorShadowsAllowed() const override { return false; } |
| 186 | 186 |
| 187 void reset(); | 187 void reset(); |
| 188 | 188 |
| 189 PassOwnPtr<ImageBufferSurface> createImageBufferSurface(const IntSize& devic
eSize, int* msaaSampleCount); | 189 PassOwnPtr<ImageBufferSurface> createImageBufferSurface(const IntSize& devic
eSize, int* msaaSampleCount); |
| 190 void createImageBuffer(); | 190 void createImageBuffer(); |
| 191 void createImageBufferInternal(PassOwnPtr<ImageBufferSurface> externalSurfac
e); | 191 void createImageBufferInternal(PassOwnPtr<ImageBufferSurface> externalSurfac
e); |
| 192 bool shouldUseDisplayList(const IntSize& deviceSize); | 192 bool shouldUseDisplayList(const IntSize& deviceSize); |
| 193 | 193 |
| 194 void setSurfaceSize(const IntSize&); | 194 void setSurfaceSize(const IntSize&); |
| 195 | 195 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 218 mutable bool m_didFailToCreateImageBuffer; | 218 mutable bool m_didFailToCreateImageBuffer; |
| 219 bool m_imageBufferIsClear; | 219 bool m_imageBufferIsClear; |
| 220 OwnPtr<ImageBuffer> m_imageBuffer; | 220 OwnPtr<ImageBuffer> m_imageBuffer; |
| 221 | 221 |
| 222 mutable RefPtr<Image> m_copiedImage; // FIXME: This is temporary for platfor
ms that have to copy the image buffer to render (and for CSSCanvasValue). | 222 mutable RefPtr<Image> m_copiedImage; // FIXME: This is temporary for platfor
ms that have to copy the image buffer to render (and for CSSCanvasValue). |
| 223 }; | 223 }; |
| 224 | 224 |
| 225 } // namespace blink | 225 } // namespace blink |
| 226 | 226 |
| 227 #endif // HTMLCanvasElement_h | 227 #endif // HTMLCanvasElement_h |
| OLD | NEW |