OLD | NEW |
---|---|
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 Loading... | |
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) | |
151 , m_contextEvictionManager(contextEvictionManager) | 152 , m_contextEvictionManager(contextEvictionManager) |
152 { | 153 { |
153 // Used by browser tests to detect the use of a DrawingBuffer. | 154 // Used by browser tests to detect the use of a DrawingBuffer. |
154 TRACE_EVENT_INSTANT0("test_gpu", "DrawingBufferCreation"); | 155 TRACE_EVENT_INSTANT0("test_gpu", "DrawingBufferCreation"); |
155 #ifndef NDEBUG | 156 #ifndef NDEBUG |
156 drawingBufferCounter.increment(); | 157 drawingBufferCounter.increment(); |
157 #endif | 158 #endif |
158 } | 159 } |
159 | 160 |
160 DrawingBuffer::~DrawingBuffer() | 161 DrawingBuffer::~DrawingBuffer() |
(...skipping 17 matching lines...) Expand all Loading... | |
178 bool DrawingBuffer::layerComposited() const | 179 bool DrawingBuffer::layerComposited() const |
179 { | 180 { |
180 return m_layerComposited; | 181 return m_layerComposited; |
181 } | 182 } |
182 | 183 |
183 void DrawingBuffer::markLayerComposited() | 184 void DrawingBuffer::markLayerComposited() |
184 { | 185 { |
185 m_layerComposited = true; | 186 m_layerComposited = true; |
186 } | 187 } |
187 | 188 |
189 | |
190 void DrawingBuffer::setIsHidden(bool hidden) | |
191 { | |
192 ASSERT(!m_destructionInProgress); | |
193 bool newHiddenValue = hidden || m_destructionInProgress; | |
194 if (m_isHidden == newHiddenValue) | |
195 return; | |
196 | |
197 m_isHidden = newHiddenValue; | |
198 if (m_isHidden) | |
199 freeRecycledMailboxes(); | |
danakj
2014/07/09 15:27:28
Have you considered sending the renderer composito
dshwang
2014/07/09 16:04:29
I've not considered yet.
Currently, WebGL can rele
danakj
2014/07/09 16:08:48
I mean if WebGL goes invisible the renderer compos
Ken Russell (switch to Gerrit)
2014/07/09 17:27:17
If the compositor releases its reference to the la
| |
200 } | |
201 | |
202 void DrawingBuffer::freeRecycledMailboxes() | |
203 { | |
204 if (m_recycledMailboxQueue.isEmpty()) | |
205 return; | |
206 m_context->makeContextCurrent(); | |
207 while (!m_recycledMailboxQueue.isEmpty()) | |
208 deleteMailbox(m_recycledMailboxQueue.takeLast()); | |
209 } | |
210 | |
188 blink::WebGraphicsContext3D* DrawingBuffer::context() | 211 blink::WebGraphicsContext3D* DrawingBuffer::context() |
189 { | 212 { |
190 return m_context.get(); | 213 return m_context.get(); |
191 } | 214 } |
192 | 215 |
193 bool DrawingBuffer::prepareMailbox(blink::WebExternalTextureMailbox* outMailbox, blink::WebExternalBitmap* bitmap) | 216 bool DrawingBuffer::prepareMailbox(blink::WebExternalTextureMailbox* outMailbox, blink::WebExternalBitmap* bitmap) |
194 { | 217 { |
195 if (!m_contentsChanged) | 218 if (!m_contentsChanged || m_isHidden) |
danakj
2014/07/09 15:27:28
Does this ever happen? The compositor never produc
dshwang
2014/07/09 16:04:29
That's good point. I think so. Let me check.
| |
196 return false; | 219 return false; |
197 | 220 |
198 if (m_destructionInProgress) { | 221 if (m_destructionInProgress) { |
199 // It can be hit in the following sequence. | 222 // It can be hit in the following sequence. |
200 // 1. WebGL draws something. | 223 // 1. WebGL draws something. |
201 // 2. The compositor begins the frame. | 224 // 2. The compositor begins the frame. |
202 // 3. Javascript makes a context lost using WEBGL_lose_context extension . | 225 // 3. Javascript makes a context lost using WEBGL_lose_context extension . |
203 // 4. Here. | 226 // 4. Here. |
204 return false; | 227 return false; |
205 } | 228 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
271 // set m_parentDrawingBuffer to make sure 'this' stays alive as long as it h as live mailboxes | 294 // set m_parentDrawingBuffer to make sure 'this' stays alive as long as it h as live mailboxes |
272 ASSERT(!frontColorBufferMailbox->m_parentDrawingBuffer); | 295 ASSERT(!frontColorBufferMailbox->m_parentDrawingBuffer); |
273 frontColorBufferMailbox->m_parentDrawingBuffer = this; | 296 frontColorBufferMailbox->m_parentDrawingBuffer = this; |
274 *outMailbox = frontColorBufferMailbox->mailbox; | 297 *outMailbox = frontColorBufferMailbox->mailbox; |
275 m_frontColorBuffer = frontColorBufferMailbox->textureInfo; | 298 m_frontColorBuffer = frontColorBufferMailbox->textureInfo; |
276 return true; | 299 return true; |
277 } | 300 } |
278 | 301 |
279 void DrawingBuffer::mailboxReleased(const blink::WebExternalTextureMailbox& mail box) | 302 void DrawingBuffer::mailboxReleased(const blink::WebExternalTextureMailbox& mail box) |
280 { | 303 { |
281 if (m_destructionInProgress) { | 304 if (m_destructionInProgress || m_isHidden) { |
282 mailboxReleasedWhileDestructionInProgress(mailbox); | 305 mailboxReleasedWithoutRecycling(mailbox); |
283 return; | 306 return; |
284 } | 307 } |
285 | 308 |
286 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { | 309 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { |
287 RefPtr<MailboxInfo> mailboxInfo = m_textureMailboxes[i]; | 310 RefPtr<MailboxInfo> mailboxInfo = m_textureMailboxes[i]; |
288 if (nameEquals(mailboxInfo->mailbox, mailbox)) { | 311 if (nameEquals(mailboxInfo->mailbox, mailbox)) { |
289 mailboxInfo->mailbox.syncPoint = mailbox.syncPoint; | 312 mailboxInfo->mailbox.syncPoint = mailbox.syncPoint; |
290 ASSERT(mailboxInfo->m_parentDrawingBuffer.get() == this); | 313 ASSERT(mailboxInfo->m_parentDrawingBuffer.get() == this); |
291 mailboxInfo->m_parentDrawingBuffer.clear(); | 314 mailboxInfo->m_parentDrawingBuffer.clear(); |
292 m_recycledMailboxQueue.prepend(mailboxInfo->mailbox); | 315 m_recycledMailboxQueue.prepend(mailboxInfo->mailbox); |
293 return; | 316 return; |
294 } | 317 } |
295 } | 318 } |
296 ASSERT_NOT_REACHED(); | 319 ASSERT_NOT_REACHED(); |
297 } | 320 } |
298 | 321 |
299 void DrawingBuffer::mailboxReleasedWhileDestructionInProgress(const blink::WebEx ternalTextureMailbox& mailbox) | 322 void DrawingBuffer::mailboxReleasedWithoutRecycling(const blink::WebExternalText ureMailbox& mailbox) |
300 { | 323 { |
301 ASSERT(m_textureMailboxes.size()); | 324 ASSERT(m_textureMailboxes.size()); |
302 m_context->makeContextCurrent(); | 325 m_context->makeContextCurrent(); |
303 // Ensure not to call the destructor until deleteMailbox() is completed. | 326 // Ensure not to call the destructor until deleteMailbox() is completed. |
304 RefPtr<DrawingBuffer> self = this; | 327 RefPtr<DrawingBuffer> self = this; |
305 deleteMailbox(mailbox); | 328 deleteMailbox(mailbox); |
306 } | 329 } |
307 | 330 |
308 PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::recycledMailbox() | 331 PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::recycledMailbox() |
309 { | 332 { |
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1063 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) | 1086 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) |
1064 { | 1087 { |
1065 if (info->imageId) { | 1088 if (info->imageId) { |
1066 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId); | 1089 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId); |
1067 m_context->destroyImageCHROMIUM(info->imageId); | 1090 m_context->destroyImageCHROMIUM(info->imageId); |
1068 info->imageId = 0; | 1091 info->imageId = 0; |
1069 } | 1092 } |
1070 } | 1093 } |
1071 | 1094 |
1072 } // namespace WebCore | 1095 } // namespace WebCore |
OLD | NEW |