| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 969 auto releasedMailboxInfo = m_mailboxes.end(); | 969 auto releasedMailboxInfo = m_mailboxes.end(); |
| 970 auto firstMailbox = m_mailboxes.begin(); | 970 auto firstMailbox = m_mailboxes.begin(); |
| 971 | 971 |
| 972 while (true) { | 972 while (true) { |
| 973 --releasedMailboxInfo; | 973 --releasedMailboxInfo; |
| 974 if (releasedMailboxInfo->m_mailbox == mailbox) | 974 if (releasedMailboxInfo->m_mailbox == mailbox) |
| 975 break; | 975 break; |
| 976 DCHECK(releasedMailboxInfo != firstMailbox); | 976 DCHECK(releasedMailboxInfo != firstMailbox); |
| 977 } | 977 } |
| 978 | 978 |
| 979 #if USE_IOSURFACE_FOR_2D_CANVAS |
| 980 if (releasedMailboxInfo->m_imageInfo && !lostResource) { |
| 981 if (contextLost) { |
| 982 deleteCHROMIUMImage(releasedMailboxInfo->m_imageInfo); |
| 983 } else { |
| 984 m_imageInfoCache.append(releasedMailboxInfo->m_imageInfo); |
| 985 } |
| 986 } |
| 987 #endif // USE_IOSURFACE_FOR_2D_CANVAS |
| 988 |
| 979 if (!contextLost) { | 989 if (!contextLost) { |
| 980 // Invalidate texture state in case the compositor altered it since the | 990 // Invalidate texture state in case the compositor altered it since the |
| 981 // copy-on-write. | 991 // copy-on-write. |
| 982 if (releasedMailboxInfo->m_image) { | 992 if (releasedMailboxInfo->m_image) { |
| 983 #if USE_IOSURFACE_FOR_2D_CANVAS | 993 #if USE_IOSURFACE_FOR_2D_CANVAS |
| 984 DCHECK(!releasedMailboxInfo->m_imageInfo); | 994 DCHECK(!releasedMailboxInfo->m_imageInfo); |
| 985 #endif // USE_IOSURFACE_FOR_2D_CANVAS | 995 #endif // USE_IOSURFACE_FOR_2D_CANVAS |
| 986 if (syncToken.HasData()) { | 996 if (syncToken.HasData()) { |
| 987 contextGL()->WaitSyncTokenCHROMIUM(syncToken.GetConstData()); | 997 contextGL()->WaitSyncTokenCHROMIUM(syncToken.GetConstData()); |
| 988 } | 998 } |
| 989 GrTexture* texture = releasedMailboxInfo->m_image->getTexture(); | 999 GrTexture* texture = releasedMailboxInfo->m_image->getTexture(); |
| 990 if (texture) { | 1000 if (texture) { |
| 991 if (lostResource) { | 1001 if (lostResource) { |
| 992 texture->abandon(); | 1002 texture->abandon(); |
| 993 } else { | 1003 } else { |
| 994 texture->textureParamsModified(); | 1004 texture->textureParamsModified(); |
| 995 // Break the mailbox association to avoid leaking mailboxes every time | 1005 // Break the mailbox association to avoid leaking mailboxes every time |
| 996 // skia recycles a texture. | 1006 // skia recycles a texture. |
| 997 gpu::gles2::GLES2Interface* gl = contextGL(); | 1007 gpu::gles2::GLES2Interface* gl = contextGL(); |
| 998 if (gl) | 1008 if (gl) |
| 999 gl->ProduceTextureDirectCHROMIUM( | 1009 gl->ProduceTextureDirectCHROMIUM( |
| 1000 0, GL_TEXTURE_2D, releasedMailboxInfo->m_mailbox.name); | 1010 0, GL_TEXTURE_2D, releasedMailboxInfo->m_mailbox.name); |
| 1001 } | 1011 } |
| 1002 } | 1012 } |
| 1003 } | 1013 } |
| 1004 | |
| 1005 #if USE_IOSURFACE_FOR_2D_CANVAS | |
| 1006 if (releasedMailboxInfo->m_imageInfo && !lostResource) { | |
| 1007 m_imageInfoCache.append(releasedMailboxInfo->m_imageInfo); | |
| 1008 } | |
| 1009 #endif // USE_IOSURFACE_FOR_2D_CANVAS | |
| 1010 } | 1014 } |
| 1011 | 1015 |
| 1012 RefPtr<Canvas2DLayerBridge> selfRef; | 1016 RefPtr<Canvas2DLayerBridge> selfRef; |
| 1013 if (m_destructionInProgress) { | 1017 if (m_destructionInProgress) { |
| 1014 // To avoid memory use after free, take a scoped self-reference | 1018 // To avoid memory use after free, take a scoped self-reference |
| 1015 // to postpone destruction until the end of this function. | 1019 // to postpone destruction until the end of this function. |
| 1016 selfRef = this; | 1020 selfRef = this; |
| 1017 } | 1021 } |
| 1018 | 1022 |
| 1019 // The destruction of 'releasedMailboxInfo' will: | 1023 // The destruction of 'releasedMailboxInfo' will: |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1137 default; | 1141 default; |
| 1138 | 1142 |
| 1139 void Canvas2DLayerBridge::Logger::reportHibernationEvent( | 1143 void Canvas2DLayerBridge::Logger::reportHibernationEvent( |
| 1140 HibernationEvent event) { | 1144 HibernationEvent event) { |
| 1141 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, | 1145 DEFINE_STATIC_LOCAL(EnumerationHistogram, hibernationHistogram, |
| 1142 ("Canvas.HibernationEvents", HibernationEventCount)); | 1146 ("Canvas.HibernationEvents", HibernationEventCount)); |
| 1143 hibernationHistogram.count(event); | 1147 hibernationHistogram.count(event); |
| 1144 } | 1148 } |
| 1145 | 1149 |
| 1146 } // namespace blink | 1150 } // namespace blink |
| OLD | NEW |