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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/ImageBuffer.h

Issue 1367683002: Make 2D canvas smarter about chosing whether or not to use GPU acceleration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added nullptr check + fixed style check errors Created 5 years, 2 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved. 3 * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved.
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 75
76 ~ImageBuffer(); 76 ~ImageBuffer();
77 77
78 void setClient(ImageBufferClient* client) { m_client = client; } 78 void setClient(ImageBufferClient* client) { m_client = client; }
79 79
80 const IntSize& size() const { return m_surface->size(); } 80 const IntSize& size() const { return m_surface->size(); }
81 bool isAccelerated() const { return m_surface->isAccelerated(); } 81 bool isAccelerated() const { return m_surface->isAccelerated(); }
82 bool isRecording() const { return m_surface->isRecording(); } 82 bool isRecording() const { return m_surface->isRecording(); }
83 void setHasExpensiveOp() { m_surface->setHasExpensiveOp(); } 83 void setHasExpensiveOp() { m_surface->setHasExpensiveOp(); }
84 bool isExpensiveToPaint() const { return m_surface->isExpensiveToPaint(); } 84 bool isExpensiveToPaint() const { return m_surface->isExpensiveToPaint(); }
85 void prepareSurfaceForPaintingIfNeeded() { m_surface->prepareSurfaceForPaint ingIfNeeded(); }
85 bool isSurfaceValid() const; 86 bool isSurfaceValid() const;
86 bool restoreSurface() const; 87 bool restoreSurface() const;
87 void didDraw(const FloatRect&) const; 88 void didDraw(const FloatRect&) const;
88 bool wasDrawnToAfterSnapshot() const { return m_snapshotState == DrawnToAfte rSnapshot; } 89 bool wasDrawnToAfterSnapshot() const { return m_snapshotState == DrawnToAfte rSnapshot; }
89 90
90 void setFilterQuality(SkFilterQuality filterQuality) { m_surface->setFilterQ uality(filterQuality); } 91 void setFilterQuality(SkFilterQuality filterQuality) { m_surface->setFilterQ uality(filterQuality); }
91 void setIsHidden(bool hidden) { m_surface->setIsHidden(hidden); } 92 void setIsHidden(bool hidden) { m_surface->setIsHidden(hidden); }
92 93
93 // Called by subclasses of ImageBufferSurface to install a new canvas object 94 // Called by subclasses of ImageBufferSurface to install a new canvas object
94 void resetCanvas(SkCanvas*) const; 95 void resetCanvas(SkCanvas*) const;
(...skipping 28 matching lines...) Expand all
123 // Destroys the TEXTURE_2D binding for the active texture unit of the passed context 124 // Destroys the TEXTURE_2D binding for the active texture unit of the passed context
124 bool copyToPlatformTexture(WebGraphicsContext3D*, Platform3DObject, GLenum, GLenum, GLint, bool, bool); 125 bool copyToPlatformTexture(WebGraphicsContext3D*, Platform3DObject, GLenum, GLenum, GLint, bool, bool);
125 126
126 bool copyRenderingResultsFromDrawingBuffer(DrawingBuffer*, SourceDrawingBuff er); 127 bool copyRenderingResultsFromDrawingBuffer(DrawingBuffer*, SourceDrawingBuff er);
127 128
128 void flush(); // process deferred draw commands immediately 129 void flush(); // process deferred draw commands immediately
129 void flushGpu(); // Like flush(), but flushes all the way down to the Gpu co ntext if the surface is accelerated 130 void flushGpu(); // Like flush(), but flushes all the way down to the Gpu co ntext if the surface is accelerated
130 131
131 void notifySurfaceInvalid(); 132 void notifySurfaceInvalid();
132 133
133 PassRefPtr<SkImage> newSkImageSnapshot() const; 134 PassRefPtr<SkImage> newSkImageSnapshot(AccelerationHint) const;
134 PassRefPtr<Image> newImageSnapshot() const; 135 PassRefPtr<Image> newImageSnapshot(AccelerationHint = PreferNoAcceleration) const;
135 136
136 DisplayItemClient displayItemClient() const { return toDisplayItemClient(thi s); } 137 DisplayItemClient displayItemClient() const { return toDisplayItemClient(thi s); }
137 String debugName() const { return "ImageBuffer"; } 138 String debugName() const { return "ImageBuffer"; }
138 139
139 void draw(GraphicsContext*, const FloatRect&, const FloatRect*, SkXfermode:: Mode); 140 void draw(GraphicsContext*, const FloatRect&, const FloatRect*, SkXfermode:: Mode);
140 141
141 private: 142 private:
142 ImageBuffer(PassOwnPtr<ImageBufferSurface>); 143 ImageBuffer(PassOwnPtr<ImageBufferSurface>);
143 144
144 enum SnapshotState { 145 enum SnapshotState {
(...skipping 14 matching lines...) Expand all
159 int height() const { return m_size.height(); } 160 int height() const { return m_size.height(); }
160 int width() const { return m_size.width(); } 161 int width() const { return m_size.width(); }
161 162
162 const unsigned char* m_data; 163 const unsigned char* m_data;
163 const IntSize m_size; 164 const IntSize m_size;
164 }; 165 };
165 166
166 } // namespace blink 167 } // namespace blink
167 168
168 #endif // ImageBuffer_h 169 #endif // ImageBuffer_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698