| 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 17 matching lines...) Expand all Loading... |
| 28 #ifndef HTMLCanvasElement_h | 28 #ifndef HTMLCanvasElement_h |
| 29 #define HTMLCanvasElement_h | 29 #define HTMLCanvasElement_h |
| 30 | 30 |
| 31 #include "core/html/HTMLElement.h" | 31 #include "core/html/HTMLElement.h" |
| 32 #include "core/html/canvas/CanvasImageSource.h" | 32 #include "core/html/canvas/CanvasImageSource.h" |
| 33 #include "heap/Handle.h" | 33 #include "heap/Handle.h" |
| 34 #include "platform/geometry/FloatRect.h" | 34 #include "platform/geometry/FloatRect.h" |
| 35 #include "platform/geometry/IntSize.h" | 35 #include "platform/geometry/IntSize.h" |
| 36 #include "platform/graphics/Canvas2DLayerBridge.h" | 36 #include "platform/graphics/Canvas2DLayerBridge.h" |
| 37 #include "platform/graphics/GraphicsTypes.h" | 37 #include "platform/graphics/GraphicsTypes.h" |
| 38 #include "platform/graphics/ImageBufferClient.h" |
| 38 #include "wtf/Forward.h" | 39 #include "wtf/Forward.h" |
| 39 | 40 |
| 40 #define CanvasDefaultInterpolationQuality InterpolationLow | 41 #define CanvasDefaultInterpolationQuality InterpolationLow |
| 41 | 42 |
| 42 namespace WebCore { | 43 namespace WebCore { |
| 43 | 44 |
| 44 class AffineTransform; | 45 class AffineTransform; |
| 45 class CanvasContextAttributes; | 46 class CanvasContextAttributes; |
| 46 class CanvasRenderingContext; | 47 class CanvasRenderingContext; |
| 47 class GraphicsContext; | 48 class GraphicsContext; |
| 48 class GraphicsContextStateSaver; | 49 class GraphicsContextStateSaver; |
| 49 class HTMLCanvasElement; | 50 class HTMLCanvasElement; |
| 50 class Image; | 51 class Image; |
| 51 class ImageData; | 52 class ImageData; |
| 52 class ImageBuffer; | 53 class ImageBuffer; |
| 53 class ImageBufferSurface; | 54 class ImageBufferSurface; |
| 54 class IntSize; | 55 class IntSize; |
| 55 | 56 |
| 56 class CanvasObserver { | 57 class CanvasObserver { |
| 57 public: | 58 public: |
| 58 virtual ~CanvasObserver() { } | 59 virtual ~CanvasObserver() { } |
| 59 | 60 |
| 60 virtual void canvasChanged(HTMLCanvasElement*, const FloatRect& changedRect)
= 0; | 61 virtual void canvasChanged(HTMLCanvasElement*, const FloatRect& changedRect)
= 0; |
| 61 virtual void canvasResized(HTMLCanvasElement*) = 0; | 62 virtual void canvasResized(HTMLCanvasElement*) = 0; |
| 62 virtual void canvasDestroyed(HTMLCanvasElement*) = 0; | 63 virtual void canvasDestroyed(HTMLCanvasElement*) = 0; |
| 63 }; | 64 }; |
| 64 | 65 |
| 65 class HTMLCanvasElement FINAL : public HTMLElement, public DocumentVisibilityObs
erver, public CanvasImageSource { | 66 class HTMLCanvasElement FINAL : public HTMLElement, public DocumentVisibilityObs
erver, public CanvasImageSource, public ImageBufferClient { |
| 66 public: | 67 public: |
| 67 static PassRefPtr<HTMLCanvasElement> create(Document&); | 68 static PassRefPtr<HTMLCanvasElement> create(Document&); |
| 68 virtual ~HTMLCanvasElement(); | 69 virtual ~HTMLCanvasElement(); |
| 69 | 70 |
| 70 void addObserver(CanvasObserver*); | 71 void addObserver(CanvasObserver*); |
| 71 void removeObserver(CanvasObserver*); | 72 void removeObserver(CanvasObserver*); |
| 72 | 73 |
| 73 // Attributes and functions exposed to script | 74 // Attributes and functions exposed to script |
| 74 int width() const { return size().width(); } | 75 int width() const { return size().width(); } |
| 75 int height() const { return size().height(); } | 76 int height() const { return size().height(); } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 void clearPresentationCopy(); | 119 void clearPresentationCopy(); |
| 119 | 120 |
| 120 SecurityOrigin* securityOrigin() const; | 121 SecurityOrigin* securityOrigin() const; |
| 121 bool originClean() const { return m_originClean; } | 122 bool originClean() const { return m_originClean; } |
| 122 void setOriginTainted() { m_originClean = false; } | 123 void setOriginTainted() { m_originClean = false; } |
| 123 | 124 |
| 124 AffineTransform baseTransform() const; | 125 AffineTransform baseTransform() const; |
| 125 | 126 |
| 126 bool is3D() const; | 127 bool is3D() const; |
| 127 | 128 |
| 128 bool hasImageBuffer() const { return m_imageBuffer.get(); } | 129 bool hasImageBuffer() const { return m_imageBuffer; } |
| 130 bool hasValidImageBuffer() const; |
| 131 void discardImageBuffer(); |
| 129 | 132 |
| 130 bool shouldAccelerate(const IntSize&) const; | 133 bool shouldAccelerate(const IntSize&) const; |
| 131 | 134 |
| 132 virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE; | 135 virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE; |
| 133 | 136 |
| 134 // DocumentVisibilityObserver implementation | 137 // DocumentVisibilityObserver implementation |
| 135 virtual void didChangeVisibilityState(PageVisibilityState) OVERRIDE; | 138 virtual void didChangeVisibilityState(PageVisibilityState) OVERRIDE; |
| 136 | 139 |
| 137 // CanvasImageSource implementation | 140 // CanvasImageSource implementation |
| 138 virtual PassRefPtr<Image> getSourceImageForCanvas(SourceImageMode, SourceIma
geStatus*) const OVERRIDE; | 141 virtual PassRefPtr<Image> getSourceImageForCanvas(SourceImageMode, SourceIma
geStatus*) const OVERRIDE; |
| 139 virtual bool wouldTaintOrigin(SecurityOrigin*) const OVERRIDE; | 142 virtual bool wouldTaintOrigin(SecurityOrigin*) const OVERRIDE; |
| 140 virtual FloatSize sourceSize() const OVERRIDE; | 143 virtual FloatSize sourceSize() const OVERRIDE; |
| 141 | 144 |
| 145 // ImageBufferClient implementation |
| 146 virtual void notifySurfaceInvalid() OVERRIDE; |
| 147 |
| 142 protected: | 148 protected: |
| 143 virtual void didMoveToNewDocument(Document& oldDocument) OVERRIDE; | 149 virtual void didMoveToNewDocument(Document& oldDocument) OVERRIDE; |
| 144 | 150 |
| 145 private: | 151 private: |
| 146 explicit HTMLCanvasElement(Document&); | 152 explicit HTMLCanvasElement(Document&); |
| 147 | 153 |
| 148 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERR
IDE; | 154 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERR
IDE; |
| 149 virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE; | 155 virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE; |
| 150 virtual bool areAuthorShadowsAllowed() const OVERRIDE { return false; } | 156 virtual bool areAuthorShadowsAllowed() const OVERRIDE { return false; } |
| 151 | 157 |
| 152 void reset(); | 158 void reset(); |
| 153 | 159 |
| 154 PassOwnPtr<ImageBufferSurface> createImageBufferSurface(const IntSize& devic
eSize, int* msaaSampleCount); | 160 PassOwnPtr<ImageBufferSurface> createImageBufferSurface(const IntSize& devic
eSize, int* msaaSampleCount); |
| 155 void createImageBuffer(); | 161 void createImageBuffer(); |
| 162 void createImageBufferInternal(); |
| 156 void clearImageBuffer(); | 163 void clearImageBuffer(); |
| 157 void discardImageBuffer(); | |
| 158 | 164 |
| 159 void setSurfaceSize(const IntSize&); | 165 void setSurfaceSize(const IntSize&); |
| 160 | 166 |
| 161 bool paintsIntoCanvasBuffer() const; | 167 bool paintsIntoCanvasBuffer() const; |
| 162 | 168 |
| 163 void updateExternallyAllocatedMemory() const; | 169 void updateExternallyAllocatedMemory() const; |
| 164 | 170 |
| 165 HashSet<CanvasObserver*> m_observers; | 171 HashSet<CanvasObserver*> m_observers; |
| 166 | 172 |
| 167 IntSize m_size; | 173 IntSize m_size; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 185 OwnPtr<ImageBuffer> m_imageBuffer; | 191 OwnPtr<ImageBuffer> m_imageBuffer; |
| 186 mutable OwnPtr<GraphicsContextStateSaver> m_contextStateSaver; | 192 mutable OwnPtr<GraphicsContextStateSaver> m_contextStateSaver; |
| 187 | 193 |
| 188 mutable RefPtr<Image> m_presentedImage; | 194 mutable RefPtr<Image> m_presentedImage; |
| 189 mutable RefPtr<Image> m_copiedImage; // FIXME: This is temporary for platfor
ms that have to copy the image buffer to render (and for CSSCanvasValue). | 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). |
| 190 }; | 196 }; |
| 191 | 197 |
| 192 } //namespace | 198 } //namespace |
| 193 | 199 |
| 194 #endif | 200 #endif |
| OLD | NEW |