| 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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 } | 300 } |
| 301 } else { | 301 } else { |
| 302 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); | 302 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); |
| 303 } | 303 } |
| 304 | 304 |
| 305 restoreFramebufferBindings(); | 305 restoreFramebufferBindings(); |
| 306 m_contentsChanged = false; | 306 m_contentsChanged = false; |
| 307 | 307 |
| 308 m_context->produceTextureDirectCHROMIUM(frontColorBufferMailbox->textureInfo
.textureId, GL_TEXTURE_2D, frontColorBufferMailbox->mailbox.name); | 308 m_context->produceTextureDirectCHROMIUM(frontColorBufferMailbox->textureInfo
.textureId, GL_TEXTURE_2D, frontColorBufferMailbox->mailbox.name); |
| 309 m_context->flush(); | 309 m_context->flush(); |
| 310 frontColorBufferMailbox->mailbox.syncPoint = m_context->insertSyncPoint(); | 310 frontColorBufferMailbox->mailbox.validSyncToken = m_context->insertSyncPoint
(frontColorBufferMailbox->mailbox.syncToken); |
| 311 frontColorBufferMailbox->mailbox.allowOverlay = frontColorBufferMailbox->tex
tureInfo.imageId != 0; | 311 frontColorBufferMailbox->mailbox.allowOverlay = frontColorBufferMailbox->tex
tureInfo.imageId != 0; |
| 312 setBufferClearNeeded(true); | 312 setBufferClearNeeded(true); |
| 313 | 313 |
| 314 // set m_parentDrawingBuffer to make sure 'this' stays alive as long as it h
as live mailboxes | 314 // set m_parentDrawingBuffer to make sure 'this' stays alive as long as it h
as live mailboxes |
| 315 ASSERT(!frontColorBufferMailbox->m_parentDrawingBuffer); | 315 ASSERT(!frontColorBufferMailbox->m_parentDrawingBuffer); |
| 316 frontColorBufferMailbox->m_parentDrawingBuffer = this; | 316 frontColorBufferMailbox->m_parentDrawingBuffer = this; |
| 317 *outMailbox = frontColorBufferMailbox->mailbox; | 317 *outMailbox = frontColorBufferMailbox->mailbox; |
| 318 m_frontColorBuffer = { frontColorBufferMailbox->textureInfo, frontColorBuffe
rMailbox->mailbox }; | 318 m_frontColorBuffer = { frontColorBufferMailbox->textureInfo, frontColorBuffe
rMailbox->mailbox }; |
| 319 return true; | 319 return true; |
| 320 } | 320 } |
| 321 | 321 |
| 322 void DrawingBuffer::mailboxReleased(const WebExternalTextureMailbox& mailbox, bo
ol lostResource) | 322 void DrawingBuffer::mailboxReleased(const WebExternalTextureMailbox& mailbox, bo
ol lostResource) |
| 323 { | 323 { |
| 324 if (m_destructionInProgress || m_context->isContextLost() || lostResource ||
m_isHidden) { | 324 if (m_destructionInProgress || m_context->isContextLost() || lostResource ||
m_isHidden) { |
| 325 mailboxReleasedWithoutRecycling(mailbox); | 325 mailboxReleasedWithoutRecycling(mailbox); |
| 326 return; | 326 return; |
| 327 } | 327 } |
| 328 | 328 |
| 329 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { | 329 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { |
| 330 RefPtr<MailboxInfo> mailboxInfo = m_textureMailboxes[i]; | 330 RefPtr<MailboxInfo> mailboxInfo = m_textureMailboxes[i]; |
| 331 if (nameEquals(mailboxInfo->mailbox, mailbox)) { | 331 if (nameEquals(mailboxInfo->mailbox, mailbox)) { |
| 332 mailboxInfo->mailbox.syncPoint = mailbox.syncPoint; | 332 memcpy(mailboxInfo->mailbox.syncToken, mailbox.syncToken, |
| 333 sizeof(mailboxInfo->mailbox.syncToken)); |
| 334 mailboxInfo->mailbox.validSyncToken = mailbox.validSyncToken; |
| 333 ASSERT(mailboxInfo->m_parentDrawingBuffer.get() == this); | 335 ASSERT(mailboxInfo->m_parentDrawingBuffer.get() == this); |
| 334 mailboxInfo->m_parentDrawingBuffer.clear(); | 336 mailboxInfo->m_parentDrawingBuffer.clear(); |
| 335 m_recycledMailboxQueue.prepend(mailboxInfo->mailbox); | 337 m_recycledMailboxQueue.prepend(mailboxInfo->mailbox); |
| 336 return; | 338 return; |
| 337 } | 339 } |
| 338 } | 340 } |
| 339 ASSERT_NOT_REACHED(); | 341 ASSERT_NOT_REACHED(); |
| 340 } | 342 } |
| 341 | 343 |
| 342 void DrawingBuffer::mailboxReleasedWithoutRecycling(const WebExternalTextureMail
box& mailbox) | 344 void DrawingBuffer::mailboxReleasedWithoutRecycling(const WebExternalTextureMail
box& mailbox) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 362 | 364 |
| 363 RefPtr<MailboxInfo> mailboxInfo; | 365 RefPtr<MailboxInfo> mailboxInfo; |
| 364 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { | 366 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { |
| 365 if (nameEquals(m_textureMailboxes[i]->mailbox, mailbox)) { | 367 if (nameEquals(m_textureMailboxes[i]->mailbox, mailbox)) { |
| 366 mailboxInfo = m_textureMailboxes[i]; | 368 mailboxInfo = m_textureMailboxes[i]; |
| 367 break; | 369 break; |
| 368 } | 370 } |
| 369 } | 371 } |
| 370 ASSERT(mailboxInfo); | 372 ASSERT(mailboxInfo); |
| 371 | 373 |
| 372 if (mailboxInfo->mailbox.syncPoint) { | 374 if (mailboxInfo->mailbox.validSyncToken) { |
| 373 m_context->waitSyncPoint(mailboxInfo->mailbox.syncPoint); | 375 m_context->waitSyncToken(mailboxInfo->mailbox.syncToken); |
| 374 mailboxInfo->mailbox.syncPoint = 0; | 376 mailboxInfo->mailbox.validSyncToken = false; |
| 375 } | 377 } |
| 376 | 378 |
| 377 if (mailboxInfo->size != m_size) { | 379 if (mailboxInfo->size != m_size) { |
| 378 m_context->bindTexture(GL_TEXTURE_2D, mailboxInfo->textureInfo.textureId
); | 380 m_context->bindTexture(GL_TEXTURE_2D, mailboxInfo->textureInfo.textureId
); |
| 379 allocateTextureMemory(&mailboxInfo->textureInfo, m_size); | 381 allocateTextureMemory(&mailboxInfo->textureInfo, m_size); |
| 380 mailboxInfo->size = m_size; | 382 mailboxInfo->size = m_size; |
| 381 } | 383 } |
| 382 | 384 |
| 383 return mailboxInfo.release(); | 385 return mailboxInfo.release(); |
| 384 } | 386 } |
| 385 | 387 |
| 386 PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::createNewMailbox(const Tex
tureInfo& info) | 388 PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::createNewMailbox(const Tex
tureInfo& info) |
| 387 { | 389 { |
| 388 RefPtr<MailboxInfo> returnMailbox = adoptRef(new MailboxInfo()); | 390 RefPtr<MailboxInfo> returnMailbox = adoptRef(new MailboxInfo()); |
| 389 m_context->genMailboxCHROMIUM(returnMailbox->mailbox.name); | 391 m_context->genMailboxCHROMIUM(returnMailbox->mailbox.name); |
| 390 returnMailbox->textureInfo = info; | 392 returnMailbox->textureInfo = info; |
| 391 returnMailbox->size = m_size; | 393 returnMailbox->size = m_size; |
| 392 m_textureMailboxes.append(returnMailbox); | 394 m_textureMailboxes.append(returnMailbox); |
| 393 return returnMailbox.release(); | 395 return returnMailbox.release(); |
| 394 } | 396 } |
| 395 | 397 |
| 396 void DrawingBuffer::deleteMailbox(const WebExternalTextureMailbox& mailbox) | 398 void DrawingBuffer::deleteMailbox(const WebExternalTextureMailbox& mailbox) |
| 397 { | 399 { |
| 398 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { | 400 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { |
| 399 if (nameEquals(m_textureMailboxes[i]->mailbox, mailbox)) { | 401 if (nameEquals(m_textureMailboxes[i]->mailbox, mailbox)) { |
| 400 if (mailbox.syncPoint) | 402 if (mailbox.validSyncToken) |
| 401 m_context->waitSyncPoint(mailbox.syncPoint); | 403 m_context->waitSyncToken(mailbox.syncToken); |
| 402 | 404 |
| 403 deleteChromiumImageForTexture(&m_textureMailboxes[i]->textureInfo); | 405 deleteChromiumImageForTexture(&m_textureMailboxes[i]->textureInfo); |
| 404 | 406 |
| 405 m_context->deleteTexture(m_textureMailboxes[i]->textureInfo.textureI
d); | 407 m_context->deleteTexture(m_textureMailboxes[i]->textureInfo.textureI
d); |
| 406 m_textureMailboxes.remove(i); | 408 m_textureMailboxes.remove(i); |
| 407 return; | 409 return; |
| 408 } | 410 } |
| 409 } | 411 } |
| 410 ASSERT_NOT_REACHED(); | 412 ASSERT_NOT_REACHED(); |
| 411 } | 413 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 WebExternalTextureMailbox mailbox; | 501 WebExternalTextureMailbox mailbox; |
| 500 GLint textureId = 0; | 502 GLint textureId = 0; |
| 501 if (sourceBuffer == FrontBuffer && m_frontColorBuffer.texInfo.textureId) { | 503 if (sourceBuffer == FrontBuffer && m_frontColorBuffer.texInfo.textureId) { |
| 502 textureId = m_frontColorBuffer.texInfo.textureId; | 504 textureId = m_frontColorBuffer.texInfo.textureId; |
| 503 mailbox = m_frontColorBuffer.mailbox; | 505 mailbox = m_frontColorBuffer.mailbox; |
| 504 } else { | 506 } else { |
| 505 textureId = m_colorBuffer.textureId; | 507 textureId = m_colorBuffer.textureId; |
| 506 m_context->genMailboxCHROMIUM(mailbox.name); | 508 m_context->genMailboxCHROMIUM(mailbox.name); |
| 507 m_context->produceTextureDirectCHROMIUM(textureId, GL_TEXTURE_2D, mailbo
x.name); | 509 m_context->produceTextureDirectCHROMIUM(textureId, GL_TEXTURE_2D, mailbo
x.name); |
| 508 m_context->flush(); | 510 m_context->flush(); |
| 509 mailbox.syncPoint = m_context->insertSyncPoint(); | 511 mailbox.validSyncToken = m_context->insertSyncPoint(mailbox.syncToken); |
| 510 } | 512 } |
| 511 | 513 |
| 512 context->waitSyncPoint(mailbox.syncPoint); | 514 context->waitSyncToken(mailbox.syncToken); |
| 513 Platform3DObject sourceTexture = context->createAndConsumeTextureCHROMIUM(GL
_TEXTURE_2D, mailbox.name); | 515 Platform3DObject sourceTexture = context->createAndConsumeTextureCHROMIUM(GL
_TEXTURE_2D, mailbox.name); |
| 514 | 516 |
| 515 GLboolean unpackPremultiplyAlphaNeeded = GL_FALSE; | 517 GLboolean unpackPremultiplyAlphaNeeded = GL_FALSE; |
| 516 GLboolean unpackUnpremultiplyAlphaNeeded = GL_FALSE; | 518 GLboolean unpackUnpremultiplyAlphaNeeded = GL_FALSE; |
| 517 if (m_actualAttributes.alpha && m_actualAttributes.premultipliedAlpha && !pr
emultiplyAlpha) | 519 if (m_actualAttributes.alpha && m_actualAttributes.premultipliedAlpha && !pr
emultiplyAlpha) |
| 518 unpackUnpremultiplyAlphaNeeded = GL_TRUE; | 520 unpackUnpremultiplyAlphaNeeded = GL_TRUE; |
| 519 else if (m_actualAttributes.alpha && !m_actualAttributes.premultipliedAlpha
&& premultiplyAlpha) | 521 else if (m_actualAttributes.alpha && !m_actualAttributes.premultipliedAlpha
&& premultiplyAlpha) |
| 520 unpackPremultiplyAlphaNeeded = GL_TRUE; | 522 unpackPremultiplyAlphaNeeded = GL_TRUE; |
| 521 | 523 |
| 522 context->copyTextureCHROMIUM(GL_TEXTURE_2D, sourceTexture, texture, internal
Format, destType, flipY, unpackPremultiplyAlphaNeeded, unpackUnpremultiplyAlphaN
eeded); | 524 context->copyTextureCHROMIUM(GL_TEXTURE_2D, sourceTexture, texture, internal
Format, destType, flipY, unpackPremultiplyAlphaNeeded, unpackUnpremultiplyAlphaN
eeded); |
| 523 | 525 |
| 524 context->deleteTexture(sourceTexture); | 526 context->deleteTexture(sourceTexture); |
| 525 | 527 |
| 526 context->flush(); | 528 context->flush(); |
| 527 m_context->waitSyncPoint(context->insertSyncPoint()); | 529 GLbyte syncToken[24]; |
| 530 if (context->insertSyncPoint(syncToken)) |
| 531 m_context->waitSyncToken(syncToken); |
| 528 | 532 |
| 529 return true; | 533 return true; |
| 530 } | 534 } |
| 531 | 535 |
| 532 Platform3DObject DrawingBuffer::framebuffer() const | 536 Platform3DObject DrawingBuffer::framebuffer() const |
| 533 { | 537 { |
| 534 return m_fbo; | 538 return m_fbo; |
| 535 } | 539 } |
| 536 | 540 |
| 537 WebLayer* DrawingBuffer::platformLayer() | 541 WebLayer* DrawingBuffer::platformLayer() |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1017 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) | 1021 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) |
| 1018 { | 1022 { |
| 1019 if (info->imageId) { | 1023 if (info->imageId) { |
| 1020 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId); | 1024 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId); |
| 1021 m_context->destroyImageCHROMIUM(info->imageId); | 1025 m_context->destroyImageCHROMIUM(info->imageId); |
| 1022 info->imageId = 0; | 1026 info->imageId = 0; |
| 1023 } | 1027 } |
| 1024 } | 1028 } |
| 1025 | 1029 |
| 1026 } // namespace blink | 1030 } // namespace blink |
| OLD | NEW |