Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: Source/core/html/HTMLCanvasElement.h

Issue 117703004: Free temporary GPU and memory resources held by inactive or hidden 2D canvases (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Response to review comments by senorblanco Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 13 matching lines...) Expand all
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
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 "platform/geometry/FloatRect.h" 32 #include "platform/geometry/FloatRect.h"
33 #include "platform/geometry/IntSize.h" 33 #include "platform/geometry/IntSize.h"
34 #include "platform/graphics/Canvas2DLayerBridge.h"
34 #include "wtf/Forward.h" 35 #include "wtf/Forward.h"
35 36
36 #define DefaultInterpolationQuality InterpolationMedium 37 #define DefaultInterpolationQuality InterpolationMedium
37 38
38 namespace WebCore { 39 namespace WebCore {
39 40
40 class AffineTransform; 41 class AffineTransform;
41 class CanvasContextAttributes; 42 class CanvasContextAttributes;
42 class CanvasRenderingContext; 43 class CanvasRenderingContext;
43 class GraphicsContext; 44 class GraphicsContext;
44 class GraphicsContextStateSaver; 45 class GraphicsContextStateSaver;
45 class HTMLCanvasElement; 46 class HTMLCanvasElement;
46 class Image; 47 class Image;
47 class ImageData; 48 class ImageData;
48 class ImageBuffer; 49 class ImageBuffer;
49 class ImageBufferSurface; 50 class ImageBufferSurface;
50 class IntSize; 51 class IntSize;
51 52
52 class CanvasObserver { 53 class CanvasObserver {
53 public: 54 public:
54 virtual ~CanvasObserver() { } 55 virtual ~CanvasObserver() { }
55 56
56 virtual void canvasChanged(HTMLCanvasElement*, const FloatRect& changedRect) = 0; 57 virtual void canvasChanged(HTMLCanvasElement*, const FloatRect& changedRect) = 0;
57 virtual void canvasResized(HTMLCanvasElement*) = 0; 58 virtual void canvasResized(HTMLCanvasElement*) = 0;
58 virtual void canvasDestroyed(HTMLCanvasElement*) = 0; 59 virtual void canvasDestroyed(HTMLCanvasElement*) = 0;
59 }; 60 };
60 61
61 class HTMLCanvasElement FINAL : public HTMLElement { 62 class HTMLCanvasElement FINAL : public HTMLElement, public DocumentVisibilityObs erver {
62 public: 63 public:
63 static PassRefPtr<HTMLCanvasElement> create(Document&); 64 static PassRefPtr<HTMLCanvasElement> create(Document&);
64 virtual ~HTMLCanvasElement(); 65 virtual ~HTMLCanvasElement();
65 66
66 void addObserver(CanvasObserver*); 67 void addObserver(CanvasObserver*);
67 void removeObserver(CanvasObserver*); 68 void removeObserver(CanvasObserver*);
68 69
69 // Attributes and functions exposed to script 70 // Attributes and functions exposed to script
70 int width() const { return size().width(); } 71 int width() const { return size().width(); }
71 int height() const { return size().height(); } 72 int height() const { return size().height(); }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 AffineTransform baseTransform() const; 121 AffineTransform baseTransform() const;
121 122
122 bool is3D() const; 123 bool is3D() const;
123 124
124 bool hasImageBuffer() const { return m_imageBuffer.get(); } 125 bool hasImageBuffer() const { return m_imageBuffer.get(); }
125 126
126 bool shouldAccelerate(const IntSize&) const; 127 bool shouldAccelerate(const IntSize&) const;
127 128
128 virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE; 129 virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE;
129 130
131 // DocumentVisibilityObserver implementation
132 virtual void didChangeVisibilityState(PageVisibilityState) OVERRIDE;
133
134 protected:
135 virtual void didMoveToNewDocument(Document& oldDocument) OVERRIDE;
136
130 private: 137 private:
131 explicit HTMLCanvasElement(Document&); 138 explicit HTMLCanvasElement(Document&);
132 139
133 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERR IDE; 140 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERR IDE;
134 virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE; 141 virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE;
135 virtual bool areAuthorShadowsAllowed() const OVERRIDE { return false; } 142 virtual bool areAuthorShadowsAllowed() const OVERRIDE { return false; }
136 143
137 void reset(); 144 void reset();
138 145
139 PassOwnPtr<ImageBufferSurface> createImageBufferSurface(const IntSize& devic eSize, int* msaaSampleCount); 146 PassOwnPtr<ImageBufferSurface> createImageBufferSurface(const IntSize& devic eSize, int* msaaSampleCount);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 178
172 mutable RefPtr<Image> m_presentedImage; 179 mutable RefPtr<Image> m_presentedImage;
173 mutable RefPtr<Image> m_copiedImage; // FIXME: This is temporary for platfor ms that have to copy the image buffer to render (and for CSSCanvasValue). 180 mutable RefPtr<Image> m_copiedImage; // FIXME: This is temporary for platfor ms that have to copy the image buffer to render (and for CSSCanvasValue).
174 }; 181 };
175 182
176 DEFINE_NODE_TYPE_CASTS(HTMLCanvasElement, hasTagName(HTMLNames::canvasTag)); 183 DEFINE_NODE_TYPE_CASTS(HTMLCanvasElement, hasTagName(HTMLNames::canvasTag));
177 184
178 } //namespace 185 } //namespace
179 186
180 #endif 187 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698