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

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

Issue 255563004: Implement "Save image as" for canvas (blink side). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 7 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
« no previous file with comments | « no previous file | 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 m_ignoreReset = true; 90 m_ignoreReset = true;
91 setWidth(newSize.width()); 91 setWidth(newSize.width());
92 setHeight(newSize.height()); 92 setHeight(newSize.height());
93 m_ignoreReset = false; 93 m_ignoreReset = false;
94 reset(); 94 reset();
95 } 95 }
96 96
97 CanvasRenderingContext* getContext(const String&, CanvasContextAttributes* a ttributes = 0); 97 CanvasRenderingContext* getContext(const String&, CanvasContextAttributes* a ttributes = 0);
98 98
99 static String toEncodingMimeType(const String& mimeType); 99 static String toEncodingMimeType(const String& mimeType);
100 String toDataURL(const String& mimeType, const double* quality, ExceptionSta te&); 100 String toDataURL(const String& mimeType, const double* quality, ExceptionSta te&) const;
101 String toDataURL(const String& mimeType, ExceptionState& exceptionState) { r eturn toDataURL(mimeType, 0, exceptionState); } 101 String toDataURL(const String& mimeType, ExceptionState& exceptionState) con st { return toDataURL(mimeType, 0, exceptionState); }
102 102
103 // Used for rendering 103 // Used for rendering
104 void didDraw(const FloatRect&); 104 void didDraw(const FloatRect&);
105 void notifyObserversCanvasChanged(const FloatRect&); 105 void notifyObserversCanvasChanged(const FloatRect&);
106 106
107 void paint(GraphicsContext*, const LayoutRect&); 107 void paint(GraphicsContext*, const LayoutRect&);
108 108
109 GraphicsContext* drawingContext() const; 109 GraphicsContext* drawingContext() const;
110 GraphicsContext* existingDrawingContext() const; 110 GraphicsContext* existingDrawingContext() const;
111 111
112 CanvasRenderingContext* renderingContext() const { return m_context.get(); } 112 CanvasRenderingContext* renderingContext() const { return m_context.get(); }
113 113
114 void ensureUnacceleratedImageBuffer(); 114 void ensureUnacceleratedImageBuffer();
115 ImageBuffer* buffer() const; 115 ImageBuffer* buffer() const;
116 Image* copiedImage() const; 116 Image* copiedImage() const;
117 void clearCopiedImage(); 117 void clearCopiedImage();
118 PassRefPtrWillBeRawPtr<ImageData> getImageData(); 118 PassRefPtrWillBeRawPtr<ImageData> getImageData() const;
119 void makePresentationCopy(); 119 void makePresentationCopy();
120 void clearPresentationCopy(); 120 void clearPresentationCopy();
121 121
122 SecurityOrigin* securityOrigin() const; 122 SecurityOrigin* securityOrigin() const;
123 bool originClean() const { return m_originClean; } 123 bool originClean() const { return m_originClean; }
124 void setOriginTainted() { m_originClean = false; } 124 void setOriginTainted() { m_originClean = false; }
125 125
126 AffineTransform baseTransform() const; 126 AffineTransform baseTransform() const;
127 127
128 bool is3D() const; 128 bool is3D() const;
129 129
130 bool hasImageBuffer() const { return m_imageBuffer; } 130 bool hasImageBuffer() const { return m_imageBuffer; }
131 bool hasValidImageBuffer() const; 131 bool hasValidImageBuffer() const;
132 void discardImageBuffer(); 132 void discardImageBuffer();
133 133
134 bool shouldAccelerate(const IntSize&) const; 134 bool shouldAccelerate(const IntSize&) const;
135 135
136 virtual const AtomicString imageSourceURL() const OVERRIDE;
137
136 virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE; 138 virtual InsertionNotificationRequest insertedInto(ContainerNode*) OVERRIDE;
137 139
138 // DocumentVisibilityObserver implementation 140 // DocumentVisibilityObserver implementation
139 virtual void didChangeVisibilityState(PageVisibilityState) OVERRIDE; 141 virtual void didChangeVisibilityState(PageVisibilityState) OVERRIDE;
140 142
141 // CanvasImageSource implementation 143 // CanvasImageSource implementation
142 virtual PassRefPtr<Image> getSourceImageForCanvas(SourceImageMode, SourceIma geStatus*) const OVERRIDE; 144 virtual PassRefPtr<Image> getSourceImageForCanvas(SourceImageMode, SourceIma geStatus*) const OVERRIDE;
143 virtual bool wouldTaintOrigin(SecurityOrigin*) const OVERRIDE; 145 virtual bool wouldTaintOrigin(SecurityOrigin*) const OVERRIDE;
144 virtual FloatSize sourceSize() const OVERRIDE; 146 virtual FloatSize sourceSize() const OVERRIDE;
145 147
(...skipping 18 matching lines...) Expand all
164 void createImageBuffer(); 166 void createImageBuffer();
165 void createImageBufferInternal(); 167 void createImageBufferInternal();
166 void clearImageBuffer(); 168 void clearImageBuffer();
167 169
168 void setSurfaceSize(const IntSize&); 170 void setSurfaceSize(const IntSize&);
169 171
170 bool paintsIntoCanvasBuffer() const; 172 bool paintsIntoCanvasBuffer() const;
171 173
172 void updateExternallyAllocatedMemory() const; 174 void updateExternallyAllocatedMemory() const;
173 175
176 String toDataURLInternal(const String& mimeType, const double* quality) cons t;
177
174 HashSet<CanvasObserver*> m_observers; 178 HashSet<CanvasObserver*> m_observers;
175 179
176 IntSize m_size; 180 IntSize m_size;
177 181
178 OwnPtrWillBeMember<CanvasRenderingContext> m_context; 182 OwnPtrWillBeMember<CanvasRenderingContext> m_context;
179 183
180 bool m_ignoreReset; 184 bool m_ignoreReset;
181 bool m_accelerationDisabled; 185 bool m_accelerationDisabled;
182 FloatRect m_dirtyRect; 186 FloatRect m_dirtyRect;
183 187
184 mutable intptr_t m_externallyAllocatedMemory; 188 mutable intptr_t m_externallyAllocatedMemory;
185 189
186 bool m_originClean; 190 bool m_originClean;
187 191
188 // It prevents HTMLCanvasElement::buffer() from continuously re-attempting t o allocate an imageBuffer 192 // It prevents HTMLCanvasElement::buffer() from continuously re-attempting t o allocate an imageBuffer
189 // after the first attempt failed. 193 // after the first attempt failed.
190 mutable bool m_didFailToCreateImageBuffer; 194 mutable bool m_didFailToCreateImageBuffer;
191 mutable bool m_didClearImageBuffer; 195 mutable bool m_didClearImageBuffer;
192 OwnPtr<ImageBuffer> m_imageBuffer; 196 OwnPtr<ImageBuffer> m_imageBuffer;
193 mutable OwnPtr<GraphicsContextStateSaver> m_contextStateSaver; 197 mutable OwnPtr<GraphicsContextStateSaver> m_contextStateSaver;
194 198
195 mutable RefPtr<Image> m_presentedImage; 199 mutable RefPtr<Image> m_presentedImage;
196 mutable RefPtr<Image> m_copiedImage; // FIXME: This is temporary for platfor ms that have to copy the image buffer to render (and for CSSCanvasValue). 200 mutable RefPtr<Image> m_copiedImage; // FIXME: This is temporary for platfor ms that have to copy the image buffer to render (and for CSSCanvasValue).
197 }; 201 };
198 202
199 } //namespace 203 } //namespace
200 204
201 #endif 205 #endif
OLDNEW
« no previous file with comments | « no previous file | Source/core/html/HTMLCanvasElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698