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

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

Issue 381113003: Revert 177827 "WebGL: Free temporary GPU resources held by inact..." (Closed) Base URL: svn://svn.chromium.org/blink/
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 | Annotate | Revision Log
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 // set m_parentDrawingBuffer to make sure 'this' stays alive as long as it h as live mailboxes 270 // set m_parentDrawingBuffer to make sure 'this' stays alive as long as it h as live mailboxes
293 ASSERT(!frontColorBufferMailbox->m_parentDrawingBuffer); 271 ASSERT(!frontColorBufferMailbox->m_parentDrawingBuffer);
294 frontColorBufferMailbox->m_parentDrawingBuffer = this; 272 frontColorBufferMailbox->m_parentDrawingBuffer = this;
295 *outMailbox = frontColorBufferMailbox->mailbox; 273 *outMailbox = frontColorBufferMailbox->mailbox;
296 m_frontColorBuffer = frontColorBufferMailbox->textureInfo; 274 m_frontColorBuffer = frontColorBufferMailbox->textureInfo;
297 return true; 275 return true;
298 } 276 }
299 277
300 void DrawingBuffer::mailboxReleased(const blink::WebExternalTextureMailbox& mail box) 278 void DrawingBuffer::mailboxReleased(const blink::WebExternalTextureMailbox& mail box)
301 { 279 {
302 if (m_destructionInProgress || m_isHidden) { 280 if (m_destructionInProgress) {
303 mailboxReleasedWithoutRecycling(mailbox); 281 mailboxReleasedWhileDestructionInProgress(mailbox);
304 return; 282 return;
305 } 283 }
306 284
307 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { 285 for (size_t i = 0; i < m_textureMailboxes.size(); i++) {
308 RefPtr<MailboxInfo> mailboxInfo = m_textureMailboxes[i]; 286 RefPtr<MailboxInfo> mailboxInfo = m_textureMailboxes[i];
309 if (nameEquals(mailboxInfo->mailbox, mailbox)) { 287 if (nameEquals(mailboxInfo->mailbox, mailbox)) {
310 mailboxInfo->mailbox.syncPoint = mailbox.syncPoint; 288 mailboxInfo->mailbox.syncPoint = mailbox.syncPoint;
311 ASSERT(mailboxInfo->m_parentDrawingBuffer.get() == this); 289 ASSERT(mailboxInfo->m_parentDrawingBuffer.get() == this);
312 mailboxInfo->m_parentDrawingBuffer.clear(); 290 mailboxInfo->m_parentDrawingBuffer.clear();
313 m_recycledMailboxQueue.prepend(mailboxInfo->mailbox); 291 m_recycledMailboxQueue.prepend(mailboxInfo->mailbox);
314 return; 292 return;
315 } 293 }
316 } 294 }
317 ASSERT_NOT_REACHED(); 295 ASSERT_NOT_REACHED();
318 } 296 }
319 297
320 void DrawingBuffer::mailboxReleasedWithoutRecycling(const blink::WebExternalText ureMailbox& mailbox) 298 void DrawingBuffer::mailboxReleasedWhileDestructionInProgress(const blink::WebEx ternalTextureMailbox& mailbox)
321 { 299 {
322 ASSERT(m_textureMailboxes.size()); 300 ASSERT(m_textureMailboxes.size());
323 m_context->makeContextCurrent(); 301 m_context->makeContextCurrent();
324 // Ensure not to call the destructor until deleteMailbox() is completed. 302 // Ensure not to call the destructor until deleteMailbox() is completed.
325 RefPtr<DrawingBuffer> self = this; 303 RefPtr<DrawingBuffer> self = this;
326 deleteMailbox(mailbox); 304 deleteMailbox(mailbox);
327 } 305 }
328 306
329 PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::recycledMailbox() 307 PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::recycledMailbox()
330 { 308 {
(...skipping 754 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 | « trunk/Source/platform/graphics/gpu/DrawingBuffer.h ('k') | trunk/Source/platform/graphics/gpu/DrawingBufferTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698