| 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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 // Ensure not to call the destructor until deleteMailbox() is completed. | 384 // Ensure not to call the destructor until deleteMailbox() is completed. |
| 385 RefPtr<DrawingBuffer> self = this; | 385 RefPtr<DrawingBuffer> self = this; |
| 386 deleteMailbox(mailbox); | 386 deleteMailbox(mailbox); |
| 387 } | 387 } |
| 388 | 388 |
| 389 PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::recycledMailbox() | 389 PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::recycledMailbox() |
| 390 { | 390 { |
| 391 if (m_recycledMailboxQueue.isEmpty()) | 391 if (m_recycledMailboxQueue.isEmpty()) |
| 392 return PassRefPtr<MailboxInfo>(); | 392 return PassRefPtr<MailboxInfo>(); |
| 393 | 393 |
| 394 // Creation of image backed mailboxes is very expensive, so be less |
| 395 // aggressive about pruning them. |
| 396 size_t cacheLimit = 1; |
| 397 if (RuntimeEnabledFeatures::webGLImageChromiumEnabled()) |
| 398 cacheLimit = 4; |
| 399 |
| 394 WebExternalTextureMailbox mailbox; | 400 WebExternalTextureMailbox mailbox; |
| 395 while (!m_recycledMailboxQueue.isEmpty()) { | 401 while (m_recycledMailboxQueue.size() > cacheLimit) { |
| 396 mailbox = m_recycledMailboxQueue.takeLast(); | 402 mailbox = m_recycledMailboxQueue.takeLast(); |
| 397 // Never have more than one mailbox in the released state. | 403 deleteMailbox(mailbox); |
| 398 if (!m_recycledMailboxQueue.isEmpty()) | |
| 399 deleteMailbox(mailbox); | |
| 400 } | 404 } |
| 405 mailbox = m_recycledMailboxQueue.takeLast(); |
| 401 | 406 |
| 402 RefPtr<MailboxInfo> mailboxInfo; | 407 RefPtr<MailboxInfo> mailboxInfo; |
| 403 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { | 408 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { |
| 404 if (nameEquals(m_textureMailboxes[i]->mailbox, mailbox)) { | 409 if (nameEquals(m_textureMailboxes[i]->mailbox, mailbox)) { |
| 405 mailboxInfo = m_textureMailboxes[i]; | 410 mailboxInfo = m_textureMailboxes[i]; |
| 406 break; | 411 break; |
| 407 } | 412 } |
| 408 } | 413 } |
| 409 ASSERT(mailboxInfo); | 414 ASSERT(mailboxInfo); |
| 410 | 415 |
| (...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1079 | 1084 |
| 1080 void DrawingBuffer::restoreTextureBindings() | 1085 void DrawingBuffer::restoreTextureBindings() |
| 1081 { | 1086 { |
| 1082 // This class potentially modifies the bindings for GL_TEXTURE_2D and | 1087 // This class potentially modifies the bindings for GL_TEXTURE_2D and |
| 1083 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since | 1088 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since |
| 1084 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE. | 1089 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE. |
| 1085 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); | 1090 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); |
| 1086 } | 1091 } |
| 1087 | 1092 |
| 1088 } // namespace blink | 1093 } // namespace blink |
| OLD | NEW |