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

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

Issue 104023007: Refactoring ImageBuffer to decouple it from Canvas2DLayerBridge (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase mayhem Created 7 years 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
« no previous file with comments | « Source/core/frame/ImageBitmap.cpp ('k') | Source/core/html/HTMLCanvasElement.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 27 matching lines...) Expand all
38 namespace WebCore { 38 namespace WebCore {
39 39
40 class CanvasContextAttributes; 40 class CanvasContextAttributes;
41 class CanvasRenderingContext; 41 class CanvasRenderingContext;
42 class GraphicsContext; 42 class GraphicsContext;
43 class GraphicsContextStateSaver; 43 class GraphicsContextStateSaver;
44 class HTMLCanvasElement; 44 class HTMLCanvasElement;
45 class Image; 45 class Image;
46 class ImageData; 46 class ImageData;
47 class ImageBuffer; 47 class ImageBuffer;
48 class ImageBufferSurface;
48 class IntSize; 49 class IntSize;
49 50
50 class CanvasObserver { 51 class CanvasObserver {
51 public: 52 public:
52 virtual ~CanvasObserver() { } 53 virtual ~CanvasObserver() { }
53 54
54 virtual void canvasChanged(HTMLCanvasElement*, const FloatRect& changedRect) = 0; 55 virtual void canvasChanged(HTMLCanvasElement*, const FloatRect& changedRect) = 0;
55 virtual void canvasResized(HTMLCanvasElement*) = 0; 56 virtual void canvasResized(HTMLCanvasElement*) = 0;
56 virtual void canvasDestroyed(HTMLCanvasElement*) = 0; 57 virtual void canvasDestroyed(HTMLCanvasElement*) = 0;
57 }; 58 };
(...skipping 12 matching lines...) Expand all
70 71
71 const IntSize& size() const { return m_size; } 72 const IntSize& size() const { return m_size; }
72 73
73 void setWidth(int); 74 void setWidth(int);
74 void setHeight(int); 75 void setHeight(int);
75 void setAccelerationDisabled(bool accelerationDisabled) { m_accelerationDisa bled = accelerationDisabled; } 76 void setAccelerationDisabled(bool accelerationDisabled) { m_accelerationDisa bled = accelerationDisabled; }
76 bool accelerationDisabled() const { return m_accelerationDisabled; } 77 bool accelerationDisabled() const { return m_accelerationDisabled; }
77 78
78 void setSize(const IntSize& newSize) 79 void setSize(const IntSize& newSize)
79 { 80 {
80 if (newSize == size() && m_deviceScaleFactor == 1) 81 if (newSize == size())
81 return; 82 return;
82 m_ignoreReset = true; 83 m_ignoreReset = true;
83 setWidth(newSize.width()); 84 setWidth(newSize.width());
84 setHeight(newSize.height()); 85 setHeight(newSize.height());
85 m_ignoreReset = false; 86 m_ignoreReset = false;
86 reset(); 87 reset();
87 } 88 }
88 89
89 CanvasRenderingContext* getContext(const String&, CanvasContextAttributes* a ttributes = 0); 90 CanvasRenderingContext* getContext(const String&, CanvasContextAttributes* a ttributes = 0);
90 91
(...skipping 24 matching lines...) Expand all
115 bool originClean() const { return m_originClean; } 116 bool originClean() const { return m_originClean; }
116 117
117 AffineTransform baseTransform() const; 118 AffineTransform baseTransform() const;
118 119
119 bool is3D() const; 120 bool is3D() const;
120 121
121 bool hasImageBuffer() const { return m_imageBuffer.get(); } 122 bool hasImageBuffer() const { return m_imageBuffer.get(); }
122 123
123 bool shouldAccelerate(const IntSize&) const; 124 bool shouldAccelerate(const IntSize&) const;
124 125
125 float deviceScaleFactor() const { return m_deviceScaleFactor; }
126
127 InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE; 126 InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE;
128 127
129 private: 128 private:
130 explicit HTMLCanvasElement(Document&); 129 explicit HTMLCanvasElement(Document&);
131 130
132 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERR IDE; 131 virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERR IDE;
133 virtual RenderObject* createRenderer(RenderStyle*); 132 virtual RenderObject* createRenderer(RenderStyle*);
134 virtual bool areAuthorShadowsAllowed() const OVERRIDE { return false; } 133 virtual bool areAuthorShadowsAllowed() const OVERRIDE { return false; }
135 134
136 void reset(); 135 void reset();
137 136
137 PassOwnPtr<ImageBufferSurface> createImageBufferSurface(const IntSize& devic eSize, int* msaaSampleCount);
138 void createImageBuffer(); 138 void createImageBuffer();
139 void clearImageBuffer(); 139 void clearImageBuffer();
140 140
141 void setSurfaceSize(const IntSize&); 141 void setSurfaceSize(const IntSize&);
142 IntSize convertLogicalToDevice(const IntSize&) const;
143 142
144 bool paintsIntoCanvasBuffer() const; 143 bool paintsIntoCanvasBuffer() const;
145 144
146 void setExternallyAllocatedMemory(intptr_t); 145 void setExternallyAllocatedMemory(intptr_t);
147 146
148 HashSet<CanvasObserver*> m_observers; 147 HashSet<CanvasObserver*> m_observers;
149 148
150 IntSize m_size; 149 IntSize m_size;
151 150
152 OwnPtr<CanvasRenderingContext> m_context; 151 OwnPtr<CanvasRenderingContext> m_context;
153 152
154 bool m_rendererIsCanvas; 153 bool m_rendererIsCanvas;
155 154
156 bool m_ignoreReset; 155 bool m_ignoreReset;
157 bool m_accelerationDisabled; 156 bool m_accelerationDisabled;
158 FloatRect m_dirtyRect; 157 FloatRect m_dirtyRect;
159 158
160 intptr_t m_externallyAllocatedMemory; 159 intptr_t m_externallyAllocatedMemory;
161 160
162 float m_deviceScaleFactor; // FIXME: This is always 1 and should probable be deleted
163 bool m_originClean; 161 bool m_originClean;
164 162
165 // It prevents HTMLCanvasElement::buffer() from continuously re-attempting t o allocate an imageBuffer 163 // It prevents HTMLCanvasElement::buffer() from continuously re-attempting t o allocate an imageBuffer
166 // after the first attempt failed. 164 // after the first attempt failed.
167 mutable bool m_didFailToCreateImageBuffer; 165 mutable bool m_didFailToCreateImageBuffer;
168 mutable bool m_didClearImageBuffer; 166 mutable bool m_didClearImageBuffer;
169 OwnPtr<ImageBuffer> m_imageBuffer; 167 OwnPtr<ImageBuffer> m_imageBuffer;
170 mutable OwnPtr<GraphicsContextStateSaver> m_contextStateSaver; 168 mutable OwnPtr<GraphicsContextStateSaver> m_contextStateSaver;
171 169
172 mutable RefPtr<Image> m_presentedImage; 170 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). 171 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 }; 172 };
175 173
176 DEFINE_NODE_TYPE_CASTS(HTMLCanvasElement, hasTagName(HTMLNames::canvasTag)); 174 DEFINE_NODE_TYPE_CASTS(HTMLCanvasElement, hasTagName(HTMLNames::canvasTag));
177 175
178 } //namespace 176 } //namespace
179 177
180 #endif 178 #endif
OLDNEW
« no previous file with comments | « Source/core/frame/ImageBitmap.cpp ('k') | Source/core/html/HTMLCanvasElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698