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