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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 m_context->flush(); | 315 m_context->flush(); |
316 frontColorBufferMailbox->mailbox.syncPoint = m_context->insertSyncPoint(); | 316 frontColorBufferMailbox->mailbox.validSyncToken = m_context->insertSyncPoint
(frontColorBufferMailbox->mailbox.syncToken); |
317 frontColorBufferMailbox->mailbox.allowOverlay = frontColorBufferMailbox->tex
tureInfo.imageId != 0; | 317 frontColorBufferMailbox->mailbox.allowOverlay = frontColorBufferMailbox->tex
tureInfo.imageId != 0; |
318 setBufferClearNeeded(true); | 318 setBufferClearNeeded(true); |
319 | 319 |
320 // 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 |
321 ASSERT(!frontColorBufferMailbox->m_parentDrawingBuffer); | 321 ASSERT(!frontColorBufferMailbox->m_parentDrawingBuffer); |
322 frontColorBufferMailbox->m_parentDrawingBuffer = this; | 322 frontColorBufferMailbox->m_parentDrawingBuffer = this; |
323 *outMailbox = frontColorBufferMailbox->mailbox; | 323 *outMailbox = frontColorBufferMailbox->mailbox; |
324 m_frontColorBuffer = { frontColorBufferMailbox->textureInfo, frontColorBuffe
rMailbox->mailbox }; | 324 m_frontColorBuffer = { frontColorBufferMailbox->textureInfo, frontColorBuffe
rMailbox->mailbox }; |
325 return true; | 325 return true; |
326 } | 326 } |
327 | 327 |
328 void DrawingBuffer::mailboxReleased(const WebExternalTextureMailbox& mailbox, bo
ol lostResource) | 328 void DrawingBuffer::mailboxReleased(const WebExternalTextureMailbox& mailbox, bo
ol lostResource) |
329 { | 329 { |
330 if (m_destructionInProgress || m_context->isContextLost() || lostResource ||
m_isHidden) { | 330 if (m_destructionInProgress || m_context->isContextLost() || lostResource ||
m_isHidden) { |
331 mailboxReleasedWithoutRecycling(mailbox); | 331 mailboxReleasedWithoutRecycling(mailbox); |
332 return; | 332 return; |
333 } | 333 } |
334 | 334 |
335 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { | 335 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { |
336 RefPtr<MailboxInfo> mailboxInfo = m_textureMailboxes[i]; | 336 RefPtr<MailboxInfo> mailboxInfo = m_textureMailboxes[i]; |
337 if (nameEquals(mailboxInfo->mailbox, mailbox)) { | 337 if (nameEquals(mailboxInfo->mailbox, mailbox)) { |
338 mailboxInfo->mailbox.syncPoint = mailbox.syncPoint; | 338 memcpy(mailboxInfo->mailbox.syncToken, mailbox.syncToken, |
| 339 sizeof(mailboxInfo->mailbox.syncToken)); |
| 340 mailboxInfo->mailbox.validSyncToken = mailbox.validSyncToken; |
339 ASSERT(mailboxInfo->m_parentDrawingBuffer.get() == this); | 341 ASSERT(mailboxInfo->m_parentDrawingBuffer.get() == this); |
340 mailboxInfo->m_parentDrawingBuffer.clear(); | 342 mailboxInfo->m_parentDrawingBuffer.clear(); |
341 m_recycledMailboxQueue.prepend(mailboxInfo->mailbox); | 343 m_recycledMailboxQueue.prepend(mailboxInfo->mailbox); |
342 return; | 344 return; |
343 } | 345 } |
344 } | 346 } |
345 ASSERT_NOT_REACHED(); | 347 ASSERT_NOT_REACHED(); |
346 } | 348 } |
347 | 349 |
348 void DrawingBuffer::mailboxReleasedWithoutRecycling(const WebExternalTextureMail
box& mailbox) | 350 void DrawingBuffer::mailboxReleasedWithoutRecycling(const WebExternalTextureMail
box& mailbox) |
(...skipping 19 matching lines...) Expand all Loading... |
368 | 370 |
369 RefPtr<MailboxInfo> mailboxInfo; | 371 RefPtr<MailboxInfo> mailboxInfo; |
370 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { | 372 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { |
371 if (nameEquals(m_textureMailboxes[i]->mailbox, mailbox)) { | 373 if (nameEquals(m_textureMailboxes[i]->mailbox, mailbox)) { |
372 mailboxInfo = m_textureMailboxes[i]; | 374 mailboxInfo = m_textureMailboxes[i]; |
373 break; | 375 break; |
374 } | 376 } |
375 } | 377 } |
376 ASSERT(mailboxInfo); | 378 ASSERT(mailboxInfo); |
377 | 379 |
378 if (mailboxInfo->mailbox.syncPoint) { | 380 if (mailboxInfo->mailbox.validSyncToken) { |
379 m_context->waitSyncPoint(mailboxInfo->mailbox.syncPoint); | 381 m_context->waitSyncToken(mailboxInfo->mailbox.syncToken); |
380 mailboxInfo->mailbox.syncPoint = 0; | 382 mailboxInfo->mailbox.validSyncToken = false; |
381 } | 383 } |
382 | 384 |
383 if (mailboxInfo->size != m_size) { | 385 if (mailboxInfo->size != m_size) { |
384 m_context->bindTexture(GL_TEXTURE_2D, mailboxInfo->textureInfo.textureId
); | 386 m_context->bindTexture(GL_TEXTURE_2D, mailboxInfo->textureInfo.textureId
); |
385 allocateTextureMemory(&mailboxInfo->textureInfo, m_size); | 387 allocateTextureMemory(&mailboxInfo->textureInfo, m_size); |
386 mailboxInfo->size = m_size; | 388 mailboxInfo->size = m_size; |
387 } | 389 } |
388 | 390 |
389 return mailboxInfo.release(); | 391 return mailboxInfo.release(); |
390 } | 392 } |
391 | 393 |
392 PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::createNewMailbox(const Tex
tureInfo& info) | 394 PassRefPtr<DrawingBuffer::MailboxInfo> DrawingBuffer::createNewMailbox(const Tex
tureInfo& info) |
393 { | 395 { |
394 RefPtr<MailboxInfo> returnMailbox = adoptRef(new MailboxInfo()); | 396 RefPtr<MailboxInfo> returnMailbox = adoptRef(new MailboxInfo()); |
395 m_context->genMailboxCHROMIUM(returnMailbox->mailbox.name); | 397 m_context->genMailboxCHROMIUM(returnMailbox->mailbox.name); |
396 returnMailbox->textureInfo = info; | 398 returnMailbox->textureInfo = info; |
397 returnMailbox->size = m_size; | 399 returnMailbox->size = m_size; |
398 m_textureMailboxes.append(returnMailbox); | 400 m_textureMailboxes.append(returnMailbox); |
399 return returnMailbox.release(); | 401 return returnMailbox.release(); |
400 } | 402 } |
401 | 403 |
402 void DrawingBuffer::deleteMailbox(const WebExternalTextureMailbox& mailbox) | 404 void DrawingBuffer::deleteMailbox(const WebExternalTextureMailbox& mailbox) |
403 { | 405 { |
404 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { | 406 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { |
405 if (nameEquals(m_textureMailboxes[i]->mailbox, mailbox)) { | 407 if (nameEquals(m_textureMailboxes[i]->mailbox, mailbox)) { |
406 if (mailbox.syncPoint) | 408 if (mailbox.validSyncToken) |
407 m_context->waitSyncPoint(mailbox.syncPoint); | 409 m_context->waitSyncToken(mailbox.syncToken); |
408 | 410 |
409 deleteChromiumImageForTexture(&m_textureMailboxes[i]->textureInfo); | 411 deleteChromiumImageForTexture(&m_textureMailboxes[i]->textureInfo); |
410 | 412 |
411 m_context->deleteTexture(m_textureMailboxes[i]->textureInfo.textureI
d); | 413 m_context->deleteTexture(m_textureMailboxes[i]->textureInfo.textureI
d); |
412 m_textureMailboxes.remove(i); | 414 m_textureMailboxes.remove(i); |
413 return; | 415 return; |
414 } | 416 } |
415 } | 417 } |
416 ASSERT_NOT_REACHED(); | 418 ASSERT_NOT_REACHED(); |
417 } | 419 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 WebExternalTextureMailbox mailbox; | 507 WebExternalTextureMailbox mailbox; |
506 GLint textureId = 0; | 508 GLint textureId = 0; |
507 if (sourceBuffer == FrontBuffer && m_frontColorBuffer.texInfo.textureId) { | 509 if (sourceBuffer == FrontBuffer && m_frontColorBuffer.texInfo.textureId) { |
508 textureId = m_frontColorBuffer.texInfo.textureId; | 510 textureId = m_frontColorBuffer.texInfo.textureId; |
509 mailbox = m_frontColorBuffer.mailbox; | 511 mailbox = m_frontColorBuffer.mailbox; |
510 } else { | 512 } else { |
511 textureId = m_colorBuffer.textureId; | 513 textureId = m_colorBuffer.textureId; |
512 m_context->genMailboxCHROMIUM(mailbox.name); | 514 m_context->genMailboxCHROMIUM(mailbox.name); |
513 m_context->produceTextureDirectCHROMIUM(textureId, GL_TEXTURE_2D, mailbo
x.name); | 515 m_context->produceTextureDirectCHROMIUM(textureId, GL_TEXTURE_2D, mailbo
x.name); |
514 m_context->flush(); | 516 m_context->flush(); |
515 mailbox.syncPoint = m_context->insertSyncPoint(); | 517 mailbox.validSyncToken = m_context->insertSyncPoint(mailbox.syncToken); |
516 } | 518 } |
517 | 519 |
518 context->waitSyncPoint(mailbox.syncPoint); | 520 context->waitSyncToken(mailbox.syncToken); |
519 Platform3DObject sourceTexture = context->createAndConsumeTextureCHROMIUM(GL
_TEXTURE_2D, mailbox.name); | 521 Platform3DObject sourceTexture = context->createAndConsumeTextureCHROMIUM(GL
_TEXTURE_2D, mailbox.name); |
520 | 522 |
521 GLboolean unpackPremultiplyAlphaNeeded = GL_FALSE; | 523 GLboolean unpackPremultiplyAlphaNeeded = GL_FALSE; |
522 GLboolean unpackUnpremultiplyAlphaNeeded = GL_FALSE; | 524 GLboolean unpackUnpremultiplyAlphaNeeded = GL_FALSE; |
523 if (m_actualAttributes.alpha && m_actualAttributes.premultipliedAlpha && !pr
emultiplyAlpha) | 525 if (m_actualAttributes.alpha && m_actualAttributes.premultipliedAlpha && !pr
emultiplyAlpha) |
524 unpackUnpremultiplyAlphaNeeded = GL_TRUE; | 526 unpackUnpremultiplyAlphaNeeded = GL_TRUE; |
525 else if (m_actualAttributes.alpha && !m_actualAttributes.premultipliedAlpha
&& premultiplyAlpha) | 527 else if (m_actualAttributes.alpha && !m_actualAttributes.premultipliedAlpha
&& premultiplyAlpha) |
526 unpackPremultiplyAlphaNeeded = GL_TRUE; | 528 unpackPremultiplyAlphaNeeded = GL_TRUE; |
527 | 529 |
528 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); |
529 | 531 |
530 context->deleteTexture(sourceTexture); | 532 context->deleteTexture(sourceTexture); |
531 | 533 |
532 context->flush(); | 534 context->flush(); |
533 m_context->waitSyncPoint(context->insertSyncPoint()); | 535 GLbyte syncToken[24]; |
| 536 if (context->insertSyncPoint(syncToken)) |
| 537 m_context->waitSyncToken(syncToken); |
534 | 538 |
535 return true; | 539 return true; |
536 } | 540 } |
537 | 541 |
538 Platform3DObject DrawingBuffer::framebuffer() const | 542 Platform3DObject DrawingBuffer::framebuffer() const |
539 { | 543 { |
540 return m_fbo; | 544 return m_fbo; |
541 } | 545 } |
542 | 546 |
543 WebLayer* DrawingBuffer::platformLayer() | 547 WebLayer* DrawingBuffer::platformLayer() |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1023 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) | 1027 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) |
1024 { | 1028 { |
1025 if (info->imageId) { | 1029 if (info->imageId) { |
1026 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId); | 1030 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId); |
1027 m_context->destroyImageCHROMIUM(info->imageId); | 1031 m_context->destroyImageCHROMIUM(info->imageId); |
1028 info->imageId = 0; | 1032 info->imageId = 0; |
1029 } | 1033 } |
1030 } | 1034 } |
1031 | 1035 |
1032 } // namespace blink | 1036 } // namespace blink |
OLD | NEW |