| 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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 // owns the SharedBitmap. | 317 // owns the SharedBitmap. |
| 318 auto func = WTF::bind(&DrawingBuffer::softwareMailboxReleased, | 318 auto func = WTF::bind(&DrawingBuffer::softwareMailboxReleased, |
| 319 RefPtr<DrawingBuffer>(this), | 319 RefPtr<DrawingBuffer>(this), |
| 320 WTF::passed(std::move(bitmap)), | 320 WTF::passed(std::move(bitmap)), |
| 321 m_size); | 321 m_size); |
| 322 *outReleaseCallback = cc::SingleReleaseCallback::Create( | 322 *outReleaseCallback = cc::SingleReleaseCallback::Create( |
| 323 convertToBaseCallback(std::move(func))); | 323 convertToBaseCallback(std::move(func))); |
| 324 return true; | 324 return true; |
| 325 } | 325 } |
| 326 | 326 |
| 327 if (m_webGLVersion > WebGL1) { |
| 328 m_gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); |
| 329 } |
| 330 |
| 327 // We must restore the texture binding since creating new textures, | 331 // We must restore the texture binding since creating new textures, |
| 328 // consuming and producing mailboxes changes it. | 332 // consuming and producing mailboxes changes it. |
| 329 ScopedTextureUnit0BindingRestorer restorer(m_gl, m_activeTextureUnit, m_text
ure2DBinding); | 333 ScopedTextureUnit0BindingRestorer restorer(m_gl, m_activeTextureUnit, m_text
ure2DBinding); |
| 330 | 334 |
| 331 // First try to recycle an old buffer. | 335 // First try to recycle an old buffer. |
| 332 RefPtr<MailboxInfo> mailboxInfo = takeRecycledMailbox(); | 336 RefPtr<MailboxInfo> mailboxInfo = takeRecycledMailbox(); |
| 333 | 337 |
| 334 // No buffer available to recycle, create a new one. | 338 // No buffer available to recycle, create a new one. |
| 335 if (!mailboxInfo) | 339 if (!mailboxInfo) |
| 336 mailboxInfo = createNewMailbox(createTextureAndAllocateMemory(m_size)); | 340 mailboxInfo = createNewMailbox(createTextureAndAllocateMemory(m_size)); |
| 337 | 341 |
| 338 if (m_preserveDrawingBuffer == Discard) { | 342 if (m_preserveDrawingBuffer == Discard) { |
| 339 std::swap(mailboxInfo->textureInfo, m_colorBuffer); | 343 std::swap(mailboxInfo->textureInfo, m_colorBuffer); |
| 340 attachColorBufferToReadFramebuffer(); | 344 attachColorBufferToReadFramebuffer(); |
| 341 | 345 |
| 342 if (m_discardFramebufferSupported) { | 346 if (m_discardFramebufferSupported) { |
| 343 // Explicitly discard framebuffer to save GPU memory bandwidth for t
ile-based GPU arch. | 347 // Explicitly discard framebuffer to save GPU memory bandwidth for t
ile-based GPU arch. |
| 344 const GLenum attachments[3] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_ATTAC
HMENT, GL_STENCIL_ATTACHMENT }; | 348 const GLenum attachments[3] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_ATTAC
HMENT, GL_STENCIL_ATTACHMENT }; |
| 345 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); | 349 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); |
| 346 m_gl->DiscardFramebufferEXT(GL_FRAMEBUFFER, 3, attachments); | 350 m_gl->DiscardFramebufferEXT(GL_FRAMEBUFFER, 3, attachments); |
| 347 } | 351 } |
| 348 } else { | 352 } else { |
| 349 m_gl->CopySubTextureCHROMIUM(m_colorBuffer.textureId, mailboxInfo->textu
reInfo.textureId, | 353 m_gl->CopySubTextureCHROMIUM(m_colorBuffer.textureId, mailboxInfo->textu
reInfo.textureId, |
| 350 0, 0, 0, 0, m_size.width(), m_size.height(), GL_FALSE, GL_FALSE, GL_
FALSE); | 354 0, 0, 0, 0, m_size.width(), m_size.height(), GL_FALSE, GL_FALSE, GL_
FALSE); |
| 351 } | 355 } |
| 352 | 356 |
| 353 restoreFramebufferBindings(); | 357 restoreFramebufferBindings(); |
| 358 restorePixelUnpackBufferBindings(); |
| 354 m_contentsChanged = false; | 359 m_contentsChanged = false; |
| 355 | 360 |
| 356 m_gl->ProduceTextureDirectCHROMIUM(mailboxInfo->textureInfo.textureId, mailb
oxInfo->textureInfo.parameters.target, mailboxInfo->mailbox.name); | 361 m_gl->ProduceTextureDirectCHROMIUM(mailboxInfo->textureInfo.textureId, mailb
oxInfo->textureInfo.parameters.target, mailboxInfo->mailbox.name); |
| 357 const GLuint64 fenceSync = m_gl->InsertFenceSyncCHROMIUM(); | 362 const GLuint64 fenceSync = m_gl->InsertFenceSyncCHROMIUM(); |
| 358 #if OS(MACOSX) | 363 #if OS(MACOSX) |
| 359 m_gl->DescheduleUntilFinishedCHROMIUM(); | 364 m_gl->DescheduleUntilFinishedCHROMIUM(); |
| 360 #endif | 365 #endif |
| 361 m_gl->Flush(); | 366 m_gl->Flush(); |
| 362 gpu::SyncToken syncToken; | 367 gpu::SyncToken syncToken; |
| 363 m_gl->GenSyncTokenCHROMIUM(fenceSync, syncToken.GetData()); | 368 m_gl->GenSyncTokenCHROMIUM(fenceSync, syncToken.GetData()); |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 m_gl->Enable(GL_SCISSOR_TEST); | 950 m_gl->Enable(GL_SCISSOR_TEST); |
| 946 } | 951 } |
| 947 | 952 |
| 948 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); | 953 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); |
| 949 if (m_antiAliasingMode == ScreenSpaceAntialiasing) { | 954 if (m_antiAliasingMode == ScreenSpaceAntialiasing) { |
| 950 m_gl->ApplyScreenSpaceAntialiasingCHROMIUM(); | 955 m_gl->ApplyScreenSpaceAntialiasingCHROMIUM(); |
| 951 } | 956 } |
| 952 m_contentsChangeCommitted = true; | 957 m_contentsChangeCommitted = true; |
| 953 } | 958 } |
| 954 | 959 |
| 960 void DrawingBuffer::restorePixelUnpackBufferBindings() |
| 961 { |
| 962 if (m_webGLVersion > WebGL1) { |
| 963 m_gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, m_pixelUnpackBufferBinding); |
| 964 } |
| 965 } |
| 966 |
| 955 void DrawingBuffer::restoreFramebufferBindings() | 967 void DrawingBuffer::restoreFramebufferBindings() |
| 956 { | 968 { |
| 957 if (m_drawFramebufferBinding && m_readFramebufferBinding) { | 969 if (m_drawFramebufferBinding && m_readFramebufferBinding) { |
| 958 if (m_drawFramebufferBinding == m_readFramebufferBinding) { | 970 if (m_drawFramebufferBinding == m_readFramebufferBinding) { |
| 959 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_readFramebufferBinding); | 971 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_readFramebufferBinding); |
| 960 } else { | 972 } else { |
| 961 m_gl->BindFramebuffer(GL_READ_FRAMEBUFFER, m_readFramebufferBinding)
; | 973 m_gl->BindFramebuffer(GL_READ_FRAMEBUFFER, m_readFramebufferBinding)
; |
| 962 m_gl->BindFramebuffer(GL_DRAW_FRAMEBUFFER, m_drawFramebufferBinding)
; | 974 m_gl->BindFramebuffer(GL_DRAW_FRAMEBUFFER, m_drawFramebufferBinding)
; |
| 963 } | 975 } |
| 964 return; | 976 return; |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1226 | 1238 |
| 1227 void DrawingBuffer::restoreTextureBindings() | 1239 void DrawingBuffer::restoreTextureBindings() |
| 1228 { | 1240 { |
| 1229 // This class potentially modifies the bindings for GL_TEXTURE_2D and | 1241 // This class potentially modifies the bindings for GL_TEXTURE_2D and |
| 1230 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since | 1242 // GL_TEXTURE_RECTANGLE. Only GL_TEXTURE_2D needs to be restored since |
| 1231 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE. | 1243 // the public interface for WebGL does not support GL_TEXTURE_RECTANGLE. |
| 1232 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); | 1244 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); |
| 1233 } | 1245 } |
| 1234 | 1246 |
| 1235 } // namespace blink | 1247 } // namespace blink |
| OLD | NEW |