| 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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 m_context->discardFramebufferEXT(GL_FRAMEBUFFER, 3, attachments); | 305 m_context->discardFramebufferEXT(GL_FRAMEBUFFER, 3, attachments); |
| 306 } | 306 } |
| 307 } else { | 307 } else { |
| 308 m_context->copyTextureCHROMIUM(GL_TEXTURE_2D, m_colorBuffer.textureId, f
rontColorBufferMailbox->textureInfo.textureId, GL_RGBA, GL_UNSIGNED_BYTE, GL_FAL
SE, GL_FALSE, GL_FALSE); | 308 m_context->copyTextureCHROMIUM(GL_TEXTURE_2D, m_colorBuffer.textureId, f
rontColorBufferMailbox->textureInfo.textureId, GL_RGBA, GL_UNSIGNED_BYTE, GL_FAL
SE, GL_FALSE, GL_FALSE); |
| 309 } | 309 } |
| 310 | 310 |
| 311 restoreFramebufferBindings(); | 311 restoreFramebufferBindings(); |
| 312 m_contentsChanged = false; | 312 m_contentsChanged = false; |
| 313 | 313 |
| 314 m_context->produceTextureDirectCHROMIUM(frontColorBufferMailbox->textureInfo
.textureId, GL_TEXTURE_2D, frontColorBufferMailbox->mailbox.name); | 314 m_context->produceTextureDirectCHROMIUM(frontColorBufferMailbox->textureInfo
.textureId, GL_TEXTURE_2D, frontColorBufferMailbox->mailbox.name); |
| 315 const WGC3Duint64 fenceSync = m_context->insertFenceSyncCHROMIUM(); | |
| 316 m_context->flush(); | 315 m_context->flush(); |
| 317 frontColorBufferMailbox->mailbox.validSyncToken = m_context->genSyncTokenCHR
OMIUM(fenceSync, frontColorBufferMailbox->mailbox.syncToken); | 316 frontColorBufferMailbox->mailbox.validSyncToken = m_context->insertSyncPoint
(frontColorBufferMailbox->mailbox.syncToken); |
| 318 frontColorBufferMailbox->mailbox.allowOverlay = frontColorBufferMailbox->tex
tureInfo.imageId != 0; | 317 frontColorBufferMailbox->mailbox.allowOverlay = frontColorBufferMailbox->tex
tureInfo.imageId != 0; |
| 319 setBufferClearNeeded(true); | 318 setBufferClearNeeded(true); |
| 320 | 319 |
| 321 // set m_parentDrawingBuffer to make sure 'this' stays alive as long as it h
as live mailboxes | 320 // set m_parentDrawingBuffer to make sure 'this' stays alive as long as it h
as live mailboxes |
| 322 ASSERT(!frontColorBufferMailbox->m_parentDrawingBuffer); | 321 ASSERT(!frontColorBufferMailbox->m_parentDrawingBuffer); |
| 323 frontColorBufferMailbox->m_parentDrawingBuffer = this; | 322 frontColorBufferMailbox->m_parentDrawingBuffer = this; |
| 324 *outMailbox = frontColorBufferMailbox->mailbox; | 323 *outMailbox = frontColorBufferMailbox->mailbox; |
| 325 m_frontColorBuffer = { frontColorBufferMailbox->textureInfo, frontColorBuffe
rMailbox->mailbox }; | 324 m_frontColorBuffer = { frontColorBufferMailbox->textureInfo, frontColorBuffe
rMailbox->mailbox }; |
| 326 return true; | 325 return true; |
| 327 } | 326 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 RefPtr<MailboxInfo> mailboxInfo; | 371 RefPtr<MailboxInfo> mailboxInfo; |
| 373 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { | 372 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { |
| 374 if (nameEquals(m_textureMailboxes[i]->mailbox, mailbox)) { | 373 if (nameEquals(m_textureMailboxes[i]->mailbox, mailbox)) { |
| 375 mailboxInfo = m_textureMailboxes[i]; | 374 mailboxInfo = m_textureMailboxes[i]; |
| 376 break; | 375 break; |
| 377 } | 376 } |
| 378 } | 377 } |
| 379 ASSERT(mailboxInfo); | 378 ASSERT(mailboxInfo); |
| 380 | 379 |
| 381 if (mailboxInfo->mailbox.validSyncToken) { | 380 if (mailboxInfo->mailbox.validSyncToken) { |
| 382 m_context->waitSyncTokenCHROMIUM(mailboxInfo->mailbox.syncToken); | 381 m_context->waitSyncToken(mailboxInfo->mailbox.syncToken); |
| 383 mailboxInfo->mailbox.validSyncToken = false; | 382 mailboxInfo->mailbox.validSyncToken = false; |
| 384 } | 383 } |
| 385 | 384 |
| 386 if (mailboxInfo->size != m_size) { | 385 if (mailboxInfo->size != m_size) { |
| 387 m_context->bindTexture(GL_TEXTURE_2D, mailboxInfo->textureInfo.textureId
); | 386 m_context->bindTexture(GL_TEXTURE_2D, mailboxInfo->textureInfo.textureId
); |
| 388 allocateTextureMemory(&mailboxInfo->textureInfo, m_size); | 387 allocateTextureMemory(&mailboxInfo->textureInfo, m_size); |
| 389 mailboxInfo->size = m_size; | 388 mailboxInfo->size = m_size; |
| 390 } | 389 } |
| 391 | 390 |
| 392 return mailboxInfo.release(); | 391 return mailboxInfo.release(); |
| 393 } | 392 } |
| 394 | 393 |
| 395 PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::createNewMailbox(const Tex
tureInfo& info) | 394 PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::createNewMailbox(const Tex
tureInfo& info) |
| 396 { | 395 { |
| 397 RefPtr<MailboxInfo> returnMailbox = adoptRef(new MailboxInfo()); | 396 RefPtr<MailboxInfo> returnMailbox = adoptRef(new MailboxInfo()); |
| 398 m_context->genMailboxCHROMIUM(returnMailbox->mailbox.name); | 397 m_context->genMailboxCHROMIUM(returnMailbox->mailbox.name); |
| 399 returnMailbox->textureInfo = info; | 398 returnMailbox->textureInfo = info; |
| 400 returnMailbox->size = m_size; | 399 returnMailbox->size = m_size; |
| 401 m_textureMailboxes.append(returnMailbox); | 400 m_textureMailboxes.append(returnMailbox); |
| 402 return returnMailbox.release(); | 401 return returnMailbox.release(); |
| 403 } | 402 } |
| 404 | 403 |
| 405 void DrawingBuffer::deleteMailbox(const WebExternalTextureMailbox& mailbox) | 404 void DrawingBuffer::deleteMailbox(const WebExternalTextureMailbox& mailbox) |
| 406 { | 405 { |
| 407 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { | 406 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { |
| 408 if (nameEquals(m_textureMailboxes[i]->mailbox, mailbox)) { | 407 if (nameEquals(m_textureMailboxes[i]->mailbox, mailbox)) { |
| 409 if (mailbox.validSyncToken) | 408 if (mailbox.validSyncToken) |
| 410 m_context->waitSyncTokenCHROMIUM(mailbox.syncToken); | 409 m_context->waitSyncToken(mailbox.syncToken); |
| 411 | 410 |
| 412 deleteChromiumImageForTexture(&m_textureMailboxes[i]->textureInfo); | 411 deleteChromiumImageForTexture(&m_textureMailboxes[i]->textureInfo); |
| 413 | 412 |
| 414 m_context->deleteTexture(m_textureMailboxes[i]->textureInfo.textureI
d); | 413 m_context->deleteTexture(m_textureMailboxes[i]->textureInfo.textureI
d); |
| 415 m_textureMailboxes.remove(i); | 414 m_textureMailboxes.remove(i); |
| 416 return; | 415 return; |
| 417 } | 416 } |
| 418 } | 417 } |
| 419 ASSERT_NOT_REACHED(); | 418 ASSERT_NOT_REACHED(); |
| 420 } | 419 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 // Contexts may be in a different share group. We must transfer the texture
through a mailbox first | 506 // Contexts may be in a different share group. We must transfer the texture
through a mailbox first |
| 508 WebExternalTextureMailbox mailbox; | 507 WebExternalTextureMailbox mailbox; |
| 509 GLint textureId = 0; | 508 GLint textureId = 0; |
| 510 if (sourceBuffer == FrontBuffer && m_frontColorBuffer.texInfo.textureId) { | 509 if (sourceBuffer == FrontBuffer && m_frontColorBuffer.texInfo.textureId) { |
| 511 textureId = m_frontColorBuffer.texInfo.textureId; | 510 textureId = m_frontColorBuffer.texInfo.textureId; |
| 512 mailbox = m_frontColorBuffer.mailbox; | 511 mailbox = m_frontColorBuffer.mailbox; |
| 513 } else { | 512 } else { |
| 514 textureId = m_colorBuffer.textureId; | 513 textureId = m_colorBuffer.textureId; |
| 515 m_context->genMailboxCHROMIUM(mailbox.name); | 514 m_context->genMailboxCHROMIUM(mailbox.name); |
| 516 m_context->produceTextureDirectCHROMIUM(textureId, GL_TEXTURE_2D, mailbo
x.name); | 515 m_context->produceTextureDirectCHROMIUM(textureId, GL_TEXTURE_2D, mailbo
x.name); |
| 517 const WGC3Duint64 fenceSync = m_context->insertFenceSyncCHROMIUM(); | |
| 518 m_context->flush(); | 516 m_context->flush(); |
| 519 mailbox.validSyncToken = m_context->genSyncTokenCHROMIUM(fenceSync, mail
box.syncToken); | 517 mailbox.validSyncToken = m_context->insertSyncPoint(mailbox.syncToken); |
| 520 } | 518 } |
| 521 | 519 |
| 522 if (mailbox.validSyncToken) | 520 context->waitSyncToken(mailbox.syncToken); |
| 523 context->waitSyncTokenCHROMIUM(mailbox.syncToken); | |
| 524 Platform3DObject sourceTexture = context->createAndConsumeTextureCHROMIUM(GL
_TEXTURE_2D, mailbox.name); | 521 Platform3DObject sourceTexture = context->createAndConsumeTextureCHROMIUM(GL
_TEXTURE_2D, mailbox.name); |
| 525 | 522 |
| 526 GLboolean unpackPremultiplyAlphaNeeded = GL_FALSE; | 523 GLboolean unpackPremultiplyAlphaNeeded = GL_FALSE; |
| 527 GLboolean unpackUnpremultiplyAlphaNeeded = GL_FALSE; | 524 GLboolean unpackUnpremultiplyAlphaNeeded = GL_FALSE; |
| 528 if (m_actualAttributes.alpha && m_actualAttributes.premultipliedAlpha && !pr
emultiplyAlpha) | 525 if (m_actualAttributes.alpha && m_actualAttributes.premultipliedAlpha && !pr
emultiplyAlpha) |
| 529 unpackUnpremultiplyAlphaNeeded = GL_TRUE; | 526 unpackUnpremultiplyAlphaNeeded = GL_TRUE; |
| 530 else if (m_actualAttributes.alpha && !m_actualAttributes.premultipliedAlpha
&& premultiplyAlpha) | 527 else if (m_actualAttributes.alpha && !m_actualAttributes.premultipliedAlpha
&& premultiplyAlpha) |
| 531 unpackPremultiplyAlphaNeeded = GL_TRUE; | 528 unpackPremultiplyAlphaNeeded = GL_TRUE; |
| 532 | 529 |
| 533 context->copyTextureCHROMIUM(GL_TEXTURE_2D, sourceTexture, texture, internal
Format, destType, flipY, unpackPremultiplyAlphaNeeded, unpackUnpremultiplyAlphaN
eeded); | 530 context->copyTextureCHROMIUM(GL_TEXTURE_2D, sourceTexture, texture, internal
Format, destType, flipY, unpackPremultiplyAlphaNeeded, unpackUnpremultiplyAlphaN
eeded); |
| 534 | 531 |
| 535 context->deleteTexture(sourceTexture); | 532 context->deleteTexture(sourceTexture); |
| 536 | 533 |
| 537 const WGC3Duint64 fenceSync = context->insertFenceSyncCHROMIUM(); | |
| 538 | |
| 539 context->flush(); | 534 context->flush(); |
| 540 GLbyte syncToken[24]; | 535 GLbyte syncToken[24]; |
| 541 if (context->genSyncTokenCHROMIUM(fenceSync, syncToken)) | 536 if (context->insertSyncPoint(syncToken)) |
| 542 m_context->waitSyncTokenCHROMIUM(syncToken); | 537 m_context->waitSyncToken(syncToken); |
| 543 | 538 |
| 544 return true; | 539 return true; |
| 545 } | 540 } |
| 546 | 541 |
| 547 Platform3DObject DrawingBuffer::framebuffer() const | 542 Platform3DObject DrawingBuffer::framebuffer() const |
| 548 { | 543 { |
| 549 return m_fbo; | 544 return m_fbo; |
| 550 } | 545 } |
| 551 | 546 |
| 552 WebLayer* DrawingBuffer::platformLayer() | 547 WebLayer* DrawingBuffer::platformLayer() |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 988 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) | 983 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) |
| 989 { | 984 { |
| 990 if (info->imageId) { | 985 if (info->imageId) { |
| 991 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId); | 986 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId); |
| 992 m_context->destroyImageCHROMIUM(info->imageId); | 987 m_context->destroyImageCHROMIUM(info->imageId); |
| 993 info->imageId = 0; | 988 info->imageId = 0; |
| 994 } | 989 } |
| 995 } | 990 } |
| 996 | 991 |
| 997 } // namespace blink | 992 } // namespace blink |
| OLD | NEW |