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

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

Issue 385663002: Revert of WebGL: Free temporary GPU resources held by inactive or hidden WebGL. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 , m_contentsChangeCommitted(false) 141 , m_contentsChangeCommitted(false)
142 , m_layerComposited(false) 142 , m_layerComposited(false)
143 , m_multisampleMode(None) 143 , m_multisampleMode(None)
144 , m_internalColorFormat(0) 144 , m_internalColorFormat(0)
145 , m_colorFormat(0) 145 , m_colorFormat(0)
146 , m_internalRenderbufferFormat(0) 146 , m_internalRenderbufferFormat(0)
147 , m_maxTextureSize(0) 147 , m_maxTextureSize(0)
148 , m_sampleCount(0) 148 , m_sampleCount(0)
149 , m_packAlignment(4) 149 , m_packAlignment(4)
150 , m_destructionInProgress(false) 150 , m_destructionInProgress(false)
151 , m_isHidden(false)
152 , m_contextEvictionManager(contextEvictionManager) 151 , m_contextEvictionManager(contextEvictionManager)
153 { 152 {
154 // Used by browser tests to detect the use of a DrawingBuffer. 153 // Used by browser tests to detect the use of a DrawingBuffer.
155 TRACE_EVENT_INSTANT0("test_gpu", "DrawingBufferCreation"); 154 TRACE_EVENT_INSTANT0("test_gpu", "DrawingBufferCreation");
156 #ifndef NDEBUG 155 #ifndef NDEBUG
157 drawingBufferCounter.increment(); 156 drawingBufferCounter.increment();
158 #endif 157 #endif
159 } 158 }
160 159
161 DrawingBuffer::~DrawingBuffer() 160 DrawingBuffer::~DrawingBuffer()
(...skipping 17 matching lines...) Expand all
179 bool DrawingBuffer::layerComposited() const 178 bool DrawingBuffer::layerComposited() const
180 { 179 {
181 return m_layerComposited; 180 return m_layerComposited;
182 } 181 }
183 182
184 void DrawingBuffer::markLayerComposited() 183 void DrawingBuffer::markLayerComposited()
185 { 184 {
186 m_layerComposited = true; 185 m_layerComposited = true;
187 } 186 }
188 187
189
190 void DrawingBuffer::setIsHidden(bool hidden)
191 {
192 ASSERT(!m_destructionInProgress);
193 if (m_isHidden == hidden)
194 return;
195 m_isHidden = hidden;
196 if (m_isHidden)
197 freeRecycledMailboxes();
198 }
199
200 void DrawingBuffer::freeRecycledMailboxes()
201 {
202 if (m_recycledMailboxQueue.isEmpty())
203 return;
204 m_context->makeContextCurrent();
205 while (!m_recycledMailboxQueue.isEmpty())
206 deleteMailbox(m_recycledMailboxQueue.takeLast());
207 }
208
209 blink::WebGraphicsContext3D* DrawingBuffer::context() 188 blink::WebGraphicsContext3D* DrawingBuffer::context()
210 { 189 {
211 return m_context.get(); 190 return m_context.get();
212 } 191 }
213 192
214 bool DrawingBuffer::prepareMailbox(blink::WebExternalTextureMailbox* outMailbox, blink::WebExternalBitmap* bitmap) 193 bool DrawingBuffer::prepareMailbox(blink::WebExternalTextureMailbox* outMailbox, blink::WebExternalBitmap* bitmap)
215 { 194 {
216 ASSERT(!m_isHidden);
217 if (!m_contentsChanged) 195 if (!m_contentsChanged)
218 return false; 196 return false;
219 197
220 if (m_destructionInProgress) { 198 if (m_destructionInProgress) {
221 // It can be hit in the following sequence. 199 // It can be hit in the following sequence.
222 // 1. WebGL draws something. 200 // 1. WebGL draws something.
223 // 2. The compositor begins the frame. 201 // 2. The compositor begins the frame.
224 // 3. Javascript makes a context lost using WEBGL_lose_context extension . 202 // 3. Javascript makes a context lost using WEBGL_lose_context extension .
225 // 4. Here. 203 // 4. Here.
226 return false; 204 return false;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 // set m_parentDrawingBuffer to make sure 'this' stays alive as long as it h as live mailboxes 271 // set m_parentDrawingBuffer to make sure 'this' stays alive as long as it h as live mailboxes
294 ASSERT(!frontColorBufferMailbox->m_parentDrawingBuffer); 272 ASSERT(!frontColorBufferMailbox->m_parentDrawingBuffer);
295 frontColorBufferMailbox->m_parentDrawingBuffer = this; 273 frontColorBufferMailbox->m_parentDrawingBuffer = this;
296 *outMailbox = frontColorBufferMailbox->mailbox; 274 *outMailbox = frontColorBufferMailbox->mailbox;
297 m_frontColorBuffer = frontColorBufferMailbox->textureInfo; 275 m_frontColorBuffer = frontColorBufferMailbox->textureInfo;
298 return true; 276 return true;
299 } 277 }
300 278
301 void DrawingBuffer::mailboxReleased(const blink::WebExternalTextureMailbox& mail box) 279 void DrawingBuffer::mailboxReleased(const blink::WebExternalTextureMailbox& mail box)
302 { 280 {
303 if (m_destructionInProgress || m_isHidden) { 281 if (m_destructionInProgress) {
304 mailboxReleasedWithoutRecycling(mailbox); 282 mailboxReleasedWhileDestructionInProgress(mailbox);
305 return; 283 return;
306 } 284 }
307 285
308 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { 286 for (size_t i = 0; i < m_textureMailboxes.size(); i++) {
309 RefPtr<MailboxInfo> mailboxInfo = m_textureMailboxes[i]; 287 RefPtr<MailboxInfo> mailboxInfo = m_textureMailboxes[i];
310 if (nameEquals(mailboxInfo->mailbox, mailbox)) { 288 if (nameEquals(mailboxInfo->mailbox, mailbox)) {
311 mailboxInfo->mailbox.syncPoint = mailbox.syncPoint; 289 mailboxInfo->mailbox.syncPoint = mailbox.syncPoint;
312 ASSERT(mailboxInfo->m_parentDrawingBuffer.get() == this); 290 ASSERT(mailboxInfo->m_parentDrawingBuffer.get() == this);
313 mailboxInfo->m_parentDrawingBuffer.clear(); 291 mailboxInfo->m_parentDrawingBuffer.clear();
314 m_recycledMailboxQueue.prepend(mailboxInfo->mailbox); 292 m_recycledMailboxQueue.prepend(mailboxInfo->mailbox);
315 return; 293 return;
316 } 294 }
317 } 295 }
318 ASSERT_NOT_REACHED(); 296 ASSERT_NOT_REACHED();
319 } 297 }
320 298
321 void DrawingBuffer::mailboxReleasedWithoutRecycling(const blink::WebExternalText ureMailbox& mailbox) 299 void DrawingBuffer::mailboxReleasedWhileDestructionInProgress(const blink::WebEx ternalTextureMailbox& mailbox)
322 { 300 {
323 ASSERT(m_textureMailboxes.size()); 301 ASSERT(m_textureMailboxes.size());
324 m_context->makeContextCurrent(); 302 m_context->makeContextCurrent();
325 // Ensure not to call the destructor until deleteMailbox() is completed. 303 // Ensure not to call the destructor until deleteMailbox() is completed.
326 RefPtr<DrawingBuffer> self = this; 304 RefPtr<DrawingBuffer> self = this;
327 deleteMailbox(mailbox); 305 deleteMailbox(mailbox);
328 } 306 }
329 307
330 PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::recycledMailbox() 308 PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::recycledMailbox()
331 { 309 {
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) 1063 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info)
1086 { 1064 {
1087 if (info->imageId) { 1065 if (info->imageId) {
1088 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId); 1066 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId);
1089 m_context->destroyImageCHROMIUM(info->imageId); 1067 m_context->destroyImageCHROMIUM(info->imageId);
1090 info->imageId = 0; 1068 info->imageId = 0;
1091 } 1069 }
1092 } 1070 }
1093 1071
1094 } // namespace WebCore 1072 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/platform/graphics/gpu/DrawingBuffer.h ('k') | Source/platform/graphics/gpu/DrawingBufferTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698