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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 class CanvasObserver { | 57 class CanvasObserver { |
58 public: | 58 public: |
59 virtual ~CanvasObserver() { } | 59 virtual ~CanvasObserver() { } |
60 | 60 |
61 virtual void canvasChanged(HTMLCanvasElement*, const FloatRect& changedRect)
= 0; | 61 virtual void canvasChanged(HTMLCanvasElement*, const FloatRect& changedRect)
= 0; |
62 virtual void canvasResized(HTMLCanvasElement*) = 0; | 62 virtual void canvasResized(HTMLCanvasElement*) = 0; |
63 virtual void canvasDestroyed(HTMLCanvasElement*) = 0; | 63 virtual void canvasDestroyed(HTMLCanvasElement*) = 0; |
64 }; | 64 }; |
65 | 65 |
66 class HTMLCanvasElement FINAL : public HTMLElement, public DocumentVisibilityObs
erver, public CanvasImageSource, public ImageBufferClient { | 66 class HTMLCanvasElement FINAL : public HTMLElement, public DocumentVisibilityObs
erver, public CanvasImageSource, public ImageBufferClient { |
| 67 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(HTMLCanvasElement); |
67 public: | 68 public: |
68 static PassRefPtr<HTMLCanvasElement> create(Document&); | 69 static PassRefPtr<HTMLCanvasElement> create(Document&); |
69 virtual ~HTMLCanvasElement(); | 70 virtual ~HTMLCanvasElement(); |
70 | 71 |
71 void addObserver(CanvasObserver*); | 72 void addObserver(CanvasObserver*); |
72 void removeObserver(CanvasObserver*); | 73 void removeObserver(CanvasObserver*); |
73 | 74 |
74 // Attributes and functions exposed to script | 75 // Attributes and functions exposed to script |
75 int width() const { return size().width(); } | 76 int width() const { return size().width(); } |
76 int height() const { return size().height(); } | 77 int height() const { return size().height(); } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 virtual void didChangeVisibilityState(PageVisibilityState) OVERRIDE; | 139 virtual void didChangeVisibilityState(PageVisibilityState) OVERRIDE; |
139 | 140 |
140 // CanvasImageSource implementation | 141 // CanvasImageSource implementation |
141 virtual PassRefPtr<Image> getSourceImageForCanvas(SourceImageMode, SourceIma
geStatus*) const OVERRIDE; | 142 virtual PassRefPtr<Image> getSourceImageForCanvas(SourceImageMode, SourceIma
geStatus*) const OVERRIDE; |
142 virtual bool wouldTaintOrigin(SecurityOrigin*) const OVERRIDE; | 143 virtual bool wouldTaintOrigin(SecurityOrigin*) const OVERRIDE; |
143 virtual FloatSize sourceSize() const OVERRIDE; | 144 virtual FloatSize sourceSize() const OVERRIDE; |
144 | 145 |
145 // ImageBufferClient implementation | 146 // ImageBufferClient implementation |
146 virtual void notifySurfaceInvalid() OVERRIDE; | 147 virtual void notifySurfaceInvalid() OVERRIDE; |
147 | 148 |
| 149 virtual void trace(Visitor*) OVERRIDE; |
| 150 |
148 protected: | 151 protected: |
149 virtual void didMoveToNewDocument(Document& oldDocument) OVERRIDE; | 152 virtual void didMoveToNewDocument(Document& oldDocument) OVERRIDE; |
150 | 153 |
151 private: | 154 private: |
152 explicit HTMLCanvasElement(Document&); | 155 explicit HTMLCanvasElement(Document&); |
153 | 156 |
154 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERR
IDE; | 157 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERR
IDE; |
155 virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE; | 158 virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE; |
156 virtual bool areAuthorShadowsAllowed() const OVERRIDE { return false; } | 159 virtual bool areAuthorShadowsAllowed() const OVERRIDE { return false; } |
157 | 160 |
158 void reset(); | 161 void reset(); |
159 | 162 |
160 PassOwnPtr<ImageBufferSurface> createImageBufferSurface(const IntSize& devic
eSize, int* msaaSampleCount); | 163 PassOwnPtr<ImageBufferSurface> createImageBufferSurface(const IntSize& devic
eSize, int* msaaSampleCount); |
161 void createImageBuffer(); | 164 void createImageBuffer(); |
162 void createImageBufferInternal(); | 165 void createImageBufferInternal(); |
163 void clearImageBuffer(); | 166 void clearImageBuffer(); |
164 | 167 |
165 void setSurfaceSize(const IntSize&); | 168 void setSurfaceSize(const IntSize&); |
166 | 169 |
167 bool paintsIntoCanvasBuffer() const; | 170 bool paintsIntoCanvasBuffer() const; |
168 | 171 |
169 void updateExternallyAllocatedMemory() const; | 172 void updateExternallyAllocatedMemory() const; |
170 | 173 |
171 HashSet<CanvasObserver*> m_observers; | 174 HashSet<CanvasObserver*> m_observers; |
172 | 175 |
173 IntSize m_size; | 176 IntSize m_size; |
174 | 177 |
175 OwnPtr<CanvasRenderingContext> m_context; | 178 OwnPtrWillBeMember<CanvasRenderingContext> m_context; |
176 | 179 |
177 bool m_rendererIsCanvas; | 180 bool m_rendererIsCanvas; |
178 | 181 |
179 bool m_ignoreReset; | 182 bool m_ignoreReset; |
180 bool m_accelerationDisabled; | 183 bool m_accelerationDisabled; |
181 FloatRect m_dirtyRect; | 184 FloatRect m_dirtyRect; |
182 | 185 |
183 mutable intptr_t m_externallyAllocatedMemory; | 186 mutable intptr_t m_externallyAllocatedMemory; |
184 | 187 |
185 bool m_originClean; | 188 bool m_originClean; |
186 | 189 |
187 // It prevents HTMLCanvasElement::buffer() from continuously re-attempting t
o allocate an imageBuffer | 190 // It prevents HTMLCanvasElement::buffer() from continuously re-attempting t
o allocate an imageBuffer |
188 // after the first attempt failed. | 191 // after the first attempt failed. |
189 mutable bool m_didFailToCreateImageBuffer; | 192 mutable bool m_didFailToCreateImageBuffer; |
190 mutable bool m_didClearImageBuffer; | 193 mutable bool m_didClearImageBuffer; |
191 OwnPtr<ImageBuffer> m_imageBuffer; | 194 OwnPtr<ImageBuffer> m_imageBuffer; |
192 mutable OwnPtr<GraphicsContextStateSaver> m_contextStateSaver; | 195 mutable OwnPtr<GraphicsContextStateSaver> m_contextStateSaver; |
193 | 196 |
194 mutable RefPtr<Image> m_presentedImage; | 197 mutable RefPtr<Image> m_presentedImage; |
195 mutable RefPtr<Image> m_copiedImage; // FIXME: This is temporary for platfor
ms that have to copy the image buffer to render (and for CSSCanvasValue). | 198 mutable RefPtr<Image> m_copiedImage; // FIXME: This is temporary for platfor
ms that have to copy the image buffer to render (and for CSSCanvasValue). |
196 }; | 199 }; |
197 | 200 |
198 } //namespace | 201 } //namespace |
199 | 202 |
200 #endif | 203 #endif |
OLD | NEW |