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

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: rebase to ToT Created 6 years, 8 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // texture. 122 // texture.
123 void setActiveTextureUnit(GLint textureUnit) { m_activeTextureUnit = texture Unit; } 123 void setActiveTextureUnit(GLint textureUnit) { m_activeTextureUnit = texture Unit; }
124 124
125 bool multisample() const; 125 bool multisample() const;
126 126
127 Platform3DObject framebuffer() const; 127 Platform3DObject framebuffer() const;
128 128
129 void markContentsChanged(); 129 void markContentsChanged();
130 void markLayerComposited(); 130 void markLayerComposited();
131 bool layerComposited() const; 131 bool layerComposited() const;
132 void setIsHidden(bool);
132 133
133 blink::WebLayer* platformLayer(); 134 blink::WebLayer* platformLayer();
134 void paintCompositedResultsToCanvas(ImageBuffer*); 135 void paintCompositedResultsToCanvas(ImageBuffer*);
135 136
136 blink::WebGraphicsContext3D* context(); 137 blink::WebGraphicsContext3D* context();
137 138
138 // WebExternalTextureLayerClient implementation. 139 // WebExternalTextureLayerClient implementation.
139 virtual bool prepareMailbox(blink::WebExternalTextureMailbox*, blink::WebExt ernalBitmap*) OVERRIDE; 140 virtual bool prepareMailbox(blink::WebExternalTextureMailbox*, blink::WebExt ernalBitmap*) OVERRIDE;
140 virtual void mailboxReleased(const blink::WebExternalTextureMailbox&) OVERRI DE; 141 virtual void mailboxReleased(const blink::WebExternalTextureMailbox&) OVERRI DE;
141 142
142 // Destroys the TEXTURE_2D binding for the owned context 143 // Destroys the TEXTURE_2D binding for the owned context
143 bool copyToPlatformTexture(blink::WebGraphicsContext3D*, Platform3DObject te xture, GLenum internalFormat, 144 bool copyToPlatformTexture(blink::WebGraphicsContext3D*, Platform3DObject te xture, GLenum internalFormat,
144 GLenum destType, GLint level, bool premultiplyAlpha, bool flipY); 145 GLenum destType, GLint level, bool premultiplyAlpha, bool flipY);
145 146
146 void setPackAlignment(GLint param); 147 void setPackAlignment(GLint param);
147 148
148 void paintRenderingResultsToCanvas(ImageBuffer*); 149 void paintRenderingResultsToCanvas(ImageBuffer*);
149 PassRefPtr<Uint8ClampedArray> paintRenderingResultsToImageData(int&, int&); 150 PassRefPtr<Uint8ClampedArray> paintRenderingResultsToImageData(int&, int&);
150 151
151 protected: // For unittests 152 protected: // For unittests
152 DrawingBuffer( 153 DrawingBuffer(
153 PassOwnPtr<blink::WebGraphicsContext3D>, 154 PassOwnPtr<blink::WebGraphicsContext3D>,
154 PassOwnPtr<Extensions3DUtil>, 155 PassOwnPtr<Extensions3DUtil>,
155 bool multisampleExtensionSupported, 156 bool multisampleExtensionSupported,
156 bool packedDepthStencilExtensionSupported, PreserveDrawingBuffer, PassRe fPtr<ContextEvictionManager>); 157 bool packedDepthStencilExtensionSupported, PreserveDrawingBuffer, PassRe fPtr<ContextEvictionManager>);
157 158
158 bool initialize(const IntSize&); 159 bool initialize(const IntSize&);
159 160
160 private: 161 private:
161 void mailboxReleasedWhileDestructionInProgress(const blink::WebExternalTextu reMailbox&); 162 void mailboxReleasedWithoutRecycling(const blink::WebExternalTextureMailbox& );
162 163
163 unsigned createColorTexture(const IntSize& size = IntSize()); 164 unsigned createColorTexture(const IntSize& size = IntSize());
164 // Create the depth/stencil and multisample buffers, if needed. 165 // Create the depth/stencil and multisample buffers, if needed.
165 void createSecondaryBuffers(); 166 void createSecondaryBuffers();
166 bool resizeFramebuffer(const IntSize&); 167 bool resizeFramebuffer(const IntSize&);
167 bool resizeMultisampleFramebuffer(const IntSize&); 168 bool resizeMultisampleFramebuffer(const IntSize&);
168 void resizeDepthStencil(const IntSize&); 169 void resizeDepthStencil(const IntSize&);
169 170
170 // Bind to the m_framebufferBinding if it's not 0. 171 // Bind to the m_framebufferBinding if it's not 0.
171 void restoreFramebufferBinding(); 172 void restoreFramebufferBinding();
172 173
173 void clearPlatformLayer(); 174 void clearPlatformLayer();
174 175
175 PassRefPtr<MailboxInfo> recycledMailbox(); 176 PassRefPtr<MailboxInfo> recycledMailbox();
176 PassRefPtr<MailboxInfo> createNewMailbox(unsigned); 177 PassRefPtr<MailboxInfo> createNewMailbox(unsigned);
177 void deleteMailbox(const blink::WebExternalTextureMailbox&); 178 void deleteMailbox(const blink::WebExternalTextureMailbox&);
179 void freeRecycledMailboxes();
178 180
179 // Updates the current size of the buffer, ensuring that s_currentResourceUs ePixels is updated. 181 // Updates the current size of the buffer, ensuring that s_currentResourceUs ePixels is updated.
180 void setSize(const IntSize& size); 182 void setSize(const IntSize& size);
181 183
182 // Calculates the difference in pixels between the current buffer size and t he proposed size. 184 // Calculates the difference in pixels between the current buffer size and t he proposed size.
183 static int pixelDelta(const IntSize& newSize, const IntSize& curSize); 185 static int pixelDelta(const IntSize& newSize, const IntSize& curSize);
184 186
185 // Given the desired buffer size, provides the largest dimensions that will fit in the pixel budget 187 // Given the desired buffer size, provides the largest dimensions that will fit in the pixel budget
186 // Returns true if the buffer will only fit if the oldest WebGL context is f orcibly lost 188 // Returns true if the buffer will only fit if the oldest WebGL context is f orcibly lost
187 IntSize adjustSizeWithContextEviction(const IntSize&, bool& evictContext); 189 IntSize adjustSizeWithContextEviction(const IntSize&, bool& evictContext);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 MultisampleMode m_multisampleMode; 250 MultisampleMode m_multisampleMode;
249 251
250 blink::WebGraphicsContext3D::Attributes m_attributes; 252 blink::WebGraphicsContext3D::Attributes m_attributes;
251 unsigned m_internalColorFormat; 253 unsigned m_internalColorFormat;
252 unsigned m_colorFormat; 254 unsigned m_colorFormat;
253 unsigned m_internalRenderbufferFormat; 255 unsigned m_internalRenderbufferFormat;
254 int m_maxTextureSize; 256 int m_maxTextureSize;
255 int m_sampleCount; 257 int m_sampleCount;
256 int m_packAlignment; 258 int m_packAlignment;
257 bool m_destructionInProgress; 259 bool m_destructionInProgress;
260 bool m_isHidden;
258 261
259 OwnPtr<blink::WebExternalTextureLayer> m_layer; 262 OwnPtr<blink::WebExternalTextureLayer> m_layer;
260 263
261 // All of the mailboxes that this DrawingBuffer has ever created. 264 // All of the mailboxes that this DrawingBuffer has ever created.
262 Vector<RefPtr<MailboxInfo> > m_textureMailboxes; 265 Vector<RefPtr<MailboxInfo> > m_textureMailboxes;
263 // Mailboxes that were released by the compositor can be used again by this DrawingBuffer. 266 // Mailboxes that were released by the compositor can be used again by this DrawingBuffer.
264 Deque<blink::WebExternalTextureMailbox> m_recycledMailboxQueue; 267 Deque<blink::WebExternalTextureMailbox> m_recycledMailboxQueue;
265 268
266 RefPtr<ContextEvictionManager> m_contextEvictionManager; 269 RefPtr<ContextEvictionManager> m_contextEvictionManager;
267 270
268 // If the width and height of the Canvas's backing store don't 271 // If the width and height of the Canvas's backing store don't
269 // match those that we were given in the most recent call to 272 // match those that we were given in the most recent call to
270 // reshape(), then we need an intermediate bitmap to read back the 273 // reshape(), then we need an intermediate bitmap to read back the
271 // frame buffer into. This seems to happen when CSS styles are 274 // frame buffer into. This seems to happen when CSS styles are
272 // used to resize the Canvas. 275 // used to resize the Canvas.
273 SkBitmap m_resizingBitmap; 276 SkBitmap m_resizingBitmap;
274 277
275 // Used to flip a bitmap vertically. 278 // Used to flip a bitmap vertically.
276 Vector<uint8_t> m_scanline; 279 Vector<uint8_t> m_scanline;
277 }; 280 };
278 281
279 } // namespace WebCore 282 } // namespace WebCore
280 283
281 #endif // DrawingBuffer_h 284 #endif // DrawingBuffer_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698