Chromium Code Reviews| 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); | |
|
Ken Russell (switch to Gerrit)
2014/07/09 20:57:57
This assert seems a little aggressive, but I do ag
| |
| 193 if (m_isHidden == hidden) | |
| 194 return; | |
| 195 m_isHidden = hidden; | |
|
dshwang
2014/07/09 17:40:54
I changes m_isHidden meaning. It doesn't include m
| |
| 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 | |
| 188 blink::WebGraphicsContext3D* DrawingBuffer::context() | 209 blink::WebGraphicsContext3D* DrawingBuffer::context() |
| 189 { | 210 { |
| 190 return m_context.get(); | 211 return m_context.get(); |
| 191 } | 212 } |
| 192 | 213 |
| 193 bool DrawingBuffer::prepareMailbox(blink::WebExternalTextureMailbox* outMailbox, blink::WebExternalBitmap* bitmap) | 214 bool DrawingBuffer::prepareMailbox(blink::WebExternalTextureMailbox* outMailbox, blink::WebExternalBitmap* bitmap) |
| 194 { | 215 { |
| 216 ASSERT(!m_isHidden); | |
|
dshwang
2014/07/09 17:40:54
As danakj@ mentioned, 'm_isHidden == true' never h
| |
| 195 if (!m_contentsChanged) | 217 if (!m_contentsChanged) |
| 196 return false; | 218 return false; |
| 197 | 219 |
| 198 if (m_destructionInProgress) { | 220 if (m_destructionInProgress) { |
| 199 // It can be hit in the following sequence. | 221 // It can be hit in the following sequence. |
| 200 // 1. WebGL draws something. | 222 // 1. WebGL draws something. |
| 201 // 2. The compositor begins the frame. | 223 // 2. The compositor begins the frame. |
| 202 // 3. Javascript makes a context lost using WEBGL_lose_context extension . | 224 // 3. Javascript makes a context lost using WEBGL_lose_context extension . |
| 203 // 4. Here. | 225 // 4. Here. |
| 204 return false; | 226 return false; |
| (...skipping 66 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 | 293 // set m_parentDrawingBuffer to make sure 'this' stays alive as long as it h as live mailboxes |
| 272 ASSERT(!frontColorBufferMailbox->m_parentDrawingBuffer); | 294 ASSERT(!frontColorBufferMailbox->m_parentDrawingBuffer); |
| 273 frontColorBufferMailbox->m_parentDrawingBuffer = this; | 295 frontColorBufferMailbox->m_parentDrawingBuffer = this; |
| 274 *outMailbox = frontColorBufferMailbox->mailbox; | 296 *outMailbox = frontColorBufferMailbox->mailbox; |
| 275 m_frontColorBuffer = frontColorBufferMailbox->textureInfo; | 297 m_frontColorBuffer = frontColorBufferMailbox->textureInfo; |
| 276 return true; | 298 return true; |
| 277 } | 299 } |
| 278 | 300 |
| 279 void DrawingBuffer::mailboxReleased(const blink::WebExternalTextureMailbox& mail box) | 301 void DrawingBuffer::mailboxReleased(const blink::WebExternalTextureMailbox& mail box) |
| 280 { | 302 { |
| 281 if (m_destructionInProgress) { | 303 if (m_destructionInProgress || m_isHidden) { |
| 282 mailboxReleasedWhileDestructionInProgress(mailbox); | 304 mailboxReleasedWithoutRecycling(mailbox); |
| 283 return; | 305 return; |
| 284 } | 306 } |
| 285 | 307 |
| 286 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { | 308 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { |
| 287 RefPtr<MailboxInfo> mailboxInfo = m_textureMailboxes[i]; | 309 RefPtr<MailboxInfo> mailboxInfo = m_textureMailboxes[i]; |
| 288 if (nameEquals(mailboxInfo->mailbox, mailbox)) { | 310 if (nameEquals(mailboxInfo->mailbox, mailbox)) { |
| 289 mailboxInfo->mailbox.syncPoint = mailbox.syncPoint; | 311 mailboxInfo->mailbox.syncPoint = mailbox.syncPoint; |
| 290 ASSERT(mailboxInfo->m_parentDrawingBuffer.get() == this); | 312 ASSERT(mailboxInfo->m_parentDrawingBuffer.get() == this); |
| 291 mailboxInfo->m_parentDrawingBuffer.clear(); | 313 mailboxInfo->m_parentDrawingBuffer.clear(); |
| 292 m_recycledMailboxQueue.prepend(mailboxInfo->mailbox); | 314 m_recycledMailboxQueue.prepend(mailboxInfo->mailbox); |
| 293 return; | 315 return; |
| 294 } | 316 } |
| 295 } | 317 } |
| 296 ASSERT_NOT_REACHED(); | 318 ASSERT_NOT_REACHED(); |
| 297 } | 319 } |
| 298 | 320 |
| 299 void DrawingBuffer::mailboxReleasedWhileDestructionInProgress(const blink::WebEx ternalTextureMailbox& mailbox) | 321 void DrawingBuffer::mailboxReleasedWithoutRecycling(const blink::WebExternalText ureMailbox& mailbox) |
| 300 { | 322 { |
| 301 ASSERT(m_textureMailboxes.size()); | 323 ASSERT(m_textureMailboxes.size()); |
| 302 m_context->makeContextCurrent(); | 324 m_context->makeContextCurrent(); |
| 303 // Ensure not to call the destructor until deleteMailbox() is completed. | 325 // Ensure not to call the destructor until deleteMailbox() is completed. |
| 304 RefPtr<DrawingBuffer> self = this; | 326 RefPtr<DrawingBuffer> self = this; |
| 305 deleteMailbox(mailbox); | 327 deleteMailbox(mailbox); |
| 306 } | 328 } |
| 307 | 329 |
| 308 PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::recycledMailbox() | 330 PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::recycledMailbox() |
| 309 { | 331 { |
| (...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1063 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) | 1085 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) |
| 1064 { | 1086 { |
| 1065 if (info->imageId) { | 1087 if (info->imageId) { |
| 1066 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId); | 1088 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId); |
| 1067 m_context->destroyImageCHROMIUM(info->imageId); | 1089 m_context->destroyImageCHROMIUM(info->imageId); |
| 1068 info->imageId = 0; | 1090 info->imageId = 0; |
| 1069 } | 1091 } |
| 1070 } | 1092 } |
| 1071 | 1093 |
| 1072 } // namespace WebCore | 1094 } // namespace WebCore |
| OLD | NEW |