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

Side by Side Diff: Source/platform/graphics/gpu/DrawingBuffer.h

Issue 251023004: WebGL: Free temporary GPU resources held by inactive or hidden WebGL. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add a layout test Created 6 years, 5 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) 2010, Google Inc. All rights reserved. 2 * Copyright (c) 2010, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 // texture. 135 // texture.
136 void setActiveTextureUnit(GLint textureUnit) { m_activeTextureUnit = texture Unit; } 136 void setActiveTextureUnit(GLint textureUnit) { m_activeTextureUnit = texture Unit; }
137 137
138 bool multisample() const; 138 bool multisample() const;
139 139
140 Platform3DObject framebuffer() const; 140 Platform3DObject framebuffer() const;
141 141
142 void markContentsChanged(); 142 void markContentsChanged();
143 void markLayerComposited(); 143 void markLayerComposited();
144 bool layerComposited() const; 144 bool layerComposited() const;
145 void setIsHidden(bool);
145 146
146 blink::WebLayer* platformLayer(); 147 blink::WebLayer* platformLayer();
147 void paintCompositedResultsToCanvas(ImageBuffer*); 148 void paintCompositedResultsToCanvas(ImageBuffer*);
148 149
149 blink::WebGraphicsContext3D* context(); 150 blink::WebGraphicsContext3D* context();
150 151
151 // Returns the actual context attributes for this drawing buffer which may d iffer from the 152 // Returns the actual context attributes for this drawing buffer which may d iffer from the
152 // requested context attributes due to implementation limits. 153 // requested context attributes due to implementation limits.
153 blink::WebGraphicsContext3D::Attributes getActualAttributes() const { return m_actualAttributes; } 154 blink::WebGraphicsContext3D::Attributes getActualAttributes() const { return m_actualAttributes; }
154 155
(...skipping 16 matching lines...) Expand all
171 PassOwnPtr<Extensions3DUtil>, 172 PassOwnPtr<Extensions3DUtil>,
172 bool multisampleExtensionSupported, 173 bool multisampleExtensionSupported,
173 bool packedDepthStencilExtensionSupported, 174 bool packedDepthStencilExtensionSupported,
174 PreserveDrawingBuffer, 175 PreserveDrawingBuffer,
175 blink::WebGraphicsContext3D::Attributes requestedAttributes, 176 blink::WebGraphicsContext3D::Attributes requestedAttributes,
176 PassRefPtr<ContextEvictionManager>); 177 PassRefPtr<ContextEvictionManager>);
177 178
178 bool initialize(const IntSize&); 179 bool initialize(const IntSize&);
179 180
180 private: 181 private:
181 void mailboxReleasedWhileDestructionInProgress(const blink::WebExternalTextu reMailbox&); 182 void mailboxReleasedWithoutRecycling(const blink::WebExternalTextureMailbox& );
182 183
183 unsigned createColorTexture(); 184 unsigned createColorTexture();
184 // Create the depth/stencil and multisample buffers, if needed. 185 // Create the depth/stencil and multisample buffers, if needed.
185 void createSecondaryBuffers(); 186 void createSecondaryBuffers();
186 bool resizeFramebuffer(const IntSize&); 187 bool resizeFramebuffer(const IntSize&);
187 bool resizeMultisampleFramebuffer(const IntSize&); 188 bool resizeMultisampleFramebuffer(const IntSize&);
188 void resizeDepthStencil(const IntSize&); 189 void resizeDepthStencil(const IntSize&);
189 190
190 // Bind to the m_framebufferBinding if it's not 0. 191 // Bind to the m_framebufferBinding if it's not 0.
191 void restoreFramebufferBinding(); 192 void restoreFramebufferBinding();
192 193
193 void clearPlatformLayer(); 194 void clearPlatformLayer();
194 195
195 PassRefPtr<MailboxInfo> recycledMailbox(); 196 PassRefPtr<MailboxInfo> recycledMailbox();
196 PassRefPtr<MailboxInfo> createNewMailbox(const TextureInfo&); 197 PassRefPtr<MailboxInfo> createNewMailbox(const TextureInfo&);
197 void deleteMailbox(const blink::WebExternalTextureMailbox&); 198 void deleteMailbox(const blink::WebExternalTextureMailbox&);
199 void freeRecycledMailboxes();
198 200
199 // Updates the current size of the buffer, ensuring that s_currentResourceUs ePixels is updated. 201 // Updates the current size of the buffer, ensuring that s_currentResourceUs ePixels is updated.
200 void setSize(const IntSize& size); 202 void setSize(const IntSize& size);
201 203
202 // Calculates the difference in pixels between the current buffer size and t he proposed size. 204 // Calculates the difference in pixels between the current buffer size and t he proposed size.
203 static int pixelDelta(const IntSize& newSize, const IntSize& curSize); 205 static int pixelDelta(const IntSize& newSize, const IntSize& curSize);
204 206
205 // Given the desired buffer size, provides the largest dimensions that will fit in the pixel budget 207 // Given the desired buffer size, provides the largest dimensions that will fit in the pixel budget
206 // Returns true if the buffer will only fit if the oldest WebGL context is f orcibly lost 208 // Returns true if the buffer will only fit if the oldest WebGL context is f orcibly lost
207 IntSize adjustSizeWithContextEviction(const IntSize&, bool& evictContext); 209 IntSize adjustSizeWithContextEviction(const IntSize&, bool& evictContext);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 MultisampleMode m_multisampleMode; 274 MultisampleMode m_multisampleMode;
273 275
274 blink::WebGraphicsContext3D::Attributes m_actualAttributes; 276 blink::WebGraphicsContext3D::Attributes m_actualAttributes;
275 unsigned m_internalColorFormat; 277 unsigned m_internalColorFormat;
276 unsigned m_colorFormat; 278 unsigned m_colorFormat;
277 unsigned m_internalRenderbufferFormat; 279 unsigned m_internalRenderbufferFormat;
278 int m_maxTextureSize; 280 int m_maxTextureSize;
279 int m_sampleCount; 281 int m_sampleCount;
280 int m_packAlignment; 282 int m_packAlignment;
281 bool m_destructionInProgress; 283 bool m_destructionInProgress;
284 bool m_isHidden;
282 285
283 OwnPtr<blink::WebExternalTextureLayer> m_layer; 286 OwnPtr<blink::WebExternalTextureLayer> m_layer;
284 287
285 // All of the mailboxes that this DrawingBuffer has ever created. 288 // All of the mailboxes that this DrawingBuffer has ever created.
286 Vector<RefPtr<MailboxInfo> > m_textureMailboxes; 289 Vector<RefPtr<MailboxInfo> > m_textureMailboxes;
287 // Mailboxes that were released by the compositor can be used again by this DrawingBuffer. 290 // Mailboxes that were released by the compositor can be used again by this DrawingBuffer.
288 Deque<blink::WebExternalTextureMailbox> m_recycledMailboxQueue; 291 Deque<blink::WebExternalTextureMailbox> m_recycledMailboxQueue;
289 292
290 RefPtr<ContextEvictionManager> m_contextEvictionManager; 293 RefPtr<ContextEvictionManager> m_contextEvictionManager;
291 294
292 // If the width and height of the Canvas's backing store don't 295 // If the width and height of the Canvas's backing store don't
293 // match those that we were given in the most recent call to 296 // match those that we were given in the most recent call to
294 // reshape(), then we need an intermediate bitmap to read back the 297 // reshape(), then we need an intermediate bitmap to read back the
295 // frame buffer into. This seems to happen when CSS styles are 298 // frame buffer into. This seems to happen when CSS styles are
296 // used to resize the Canvas. 299 // used to resize the Canvas.
297 SkBitmap m_resizingBitmap; 300 SkBitmap m_resizingBitmap;
298 301
299 // Used to flip a bitmap vertically. 302 // Used to flip a bitmap vertically.
300 Vector<uint8_t> m_scanline; 303 Vector<uint8_t> m_scanline;
301 }; 304 };
302 305
303 } // namespace WebCore 306 } // namespace WebCore
304 307
305 #endif // DrawingBuffer_h 308 #endif // DrawingBuffer_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698