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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
290 m_context->produceTextureDirectCHROMIUM(frontColorBufferMailbox->textureInfo .textureId, GL_TEXTURE_2D, frontColorBufferMailbox->mailbox.name); | 290 m_context->produceTextureDirectCHROMIUM(frontColorBufferMailbox->textureInfo .textureId, GL_TEXTURE_2D, frontColorBufferMailbox->mailbox.name); |
291 m_context->flush(); | 291 m_context->flush(); |
292 frontColorBufferMailbox->mailbox.syncPoint = m_context->insertSyncPoint(); | 292 frontColorBufferMailbox->mailbox.syncPoint = m_context->insertSyncPoint(); |
293 frontColorBufferMailbox->mailbox.allowOverlay = frontColorBufferMailbox->tex tureInfo.imageId != 0; | 293 frontColorBufferMailbox->mailbox.allowOverlay = frontColorBufferMailbox->tex tureInfo.imageId != 0; |
294 markLayerComposited(); | 294 markLayerComposited(); |
295 | 295 |
296 // set m_parentDrawingBuffer to make sure 'this' stays alive as long as it h as live mailboxes | 296 // set m_parentDrawingBuffer to make sure 'this' stays alive as long as it h as live mailboxes |
297 ASSERT(!frontColorBufferMailbox->m_parentDrawingBuffer); | 297 ASSERT(!frontColorBufferMailbox->m_parentDrawingBuffer); |
298 frontColorBufferMailbox->m_parentDrawingBuffer = this; | 298 frontColorBufferMailbox->m_parentDrawingBuffer = this; |
299 *outMailbox = frontColorBufferMailbox->mailbox; | 299 *outMailbox = frontColorBufferMailbox->mailbox; |
300 m_frontColorBuffer = frontColorBufferMailbox->textureInfo; | 300 m_frontColorBuffer = { frontColorBufferMailbox->textureInfo, frontColorBuffe rMailbox->mailbox }; |
301 return true; | 301 return true; |
302 } | 302 } |
303 | 303 |
304 void DrawingBuffer::mailboxReleased(const WebExternalTextureMailbox& mailbox, bo ol lostResource) | 304 void DrawingBuffer::mailboxReleased(const WebExternalTextureMailbox& mailbox, bo ol lostResource) |
305 { | 305 { |
306 if (m_destructionInProgress || m_context->isContextLost() || lostResource || m_isHidden) { | 306 if (m_destructionInProgress || m_context->isContextLost() || lostResource || m_isHidden) { |
307 mailboxReleasedWithoutRecycling(mailbox); | 307 mailboxReleasedWithoutRecycling(mailbox); |
308 return; | 308 return; |
309 } | 309 } |
310 | 310 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
450 m_context->getIntegerv(GL_STENCIL_BITS, &stencilBits); | 450 m_context->getIntegerv(GL_STENCIL_BITS, &stencilBits); |
451 m_actualAttributes.stencil = stencilBits > 0; | 451 m_actualAttributes.stencil = stencilBits > 0; |
452 } | 452 } |
453 m_actualAttributes.antialias = multisample(); | 453 m_actualAttributes.antialias = multisample(); |
454 return true; | 454 return true; |
455 } | 455 } |
456 | 456 |
457 bool DrawingBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, Platfor m3DObject texture, GLenum internalFormat, GLenum destType, GLint level, bool pre multiplyAlpha, bool flipY, bool fromFrontBuffer) | 457 bool DrawingBuffer::copyToPlatformTexture(WebGraphicsContext3D* context, Platfor m3DObject texture, GLenum internalFormat, GLenum destType, GLint level, bool pre multiplyAlpha, bool flipY, bool fromFrontBuffer) |
458 { | 458 { |
459 GLint textureId = m_colorBuffer.textureId; | 459 GLint textureId = m_colorBuffer.textureId; |
460 if (fromFrontBuffer && m_frontColorBuffer.textureId) | 460 if (fromFrontBuffer && m_frontColorBuffer.texInfo.textureId) |
461 textureId = m_frontColorBuffer.textureId; | 461 textureId = m_frontColorBuffer.texInfo.textureId; |
462 | 462 |
463 if (m_contentsChanged) { | 463 if (m_contentsChanged) { |
464 if (m_multisampleMode != None) { | 464 if (m_multisampleMode != None) { |
465 commit(); | 465 commit(); |
466 if (!m_framebufferBinding) | 466 if (!m_framebufferBinding) |
467 bind(); | 467 bind(); |
468 else | 468 else |
469 restoreFramebufferBinding(); | 469 restoreFramebufferBinding(); |
470 } | 470 } |
471 m_context->flush(); | 471 m_context->flush(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
529 | 529 |
530 void DrawingBuffer::paintCompositedResultsToCanvas(ImageBuffer* imageBuffer) | 530 void DrawingBuffer::paintCompositedResultsToCanvas(ImageBuffer* imageBuffer) |
531 { | 531 { |
532 if (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR) | 532 if (m_context->getGraphicsResetStatusARB() != GL_NO_ERROR) |
533 return; | 533 return; |
534 | 534 |
535 if (!imageBuffer) | 535 if (!imageBuffer) |
536 return; | 536 return; |
537 Platform3DObject tex = imageBuffer->getBackingTexture(); | 537 Platform3DObject tex = imageBuffer->getBackingTexture(); |
538 if (tex) { | 538 if (tex) { |
539 RefPtr<MailboxInfo> bufferMailbox = adoptRef(new MailboxInfo()); | |
540 m_context->genMailboxCHROMIUM(bufferMailbox->mailbox.name); | |
541 m_context->produceTextureDirectCHROMIUM(m_frontColorBuffer.textureId, GL _TEXTURE_2D, bufferMailbox->mailbox.name); | |
dshwang
2014/10/20 19:00:25
As the method name, this method exists for copying
| |
542 m_context->flush(); | |
543 | |
544 bufferMailbox->mailbox.syncPoint = m_context->insertSyncPoint(); | |
545 OwnPtr<WebGraphicsContext3DProvider> provider = | 539 OwnPtr<WebGraphicsContext3DProvider> provider = |
546 adoptPtr(Platform::current()->createSharedOffscreenGraphicsContext3D Provider()); | 540 adoptPtr(Platform::current()->createSharedOffscreenGraphicsContext3D Provider()); |
547 if (!provider) | 541 if (!provider) |
548 return; | 542 return; |
549 WebGraphicsContext3D* context = provider->context3d(); | 543 WebGraphicsContext3D* context = provider->context3d(); |
550 if (!context) | 544 if (!context) |
551 return; | 545 return; |
552 | 546 |
553 context->waitSyncPoint(bufferMailbox->mailbox.syncPoint); | 547 context->waitSyncPoint(m_frontColorBuffer.mailbox.syncPoint); |
554 Platform3DObject sourceTexture = context->createAndConsumeTextureCHROMIU M(GL_TEXTURE_2D, bufferMailbox->mailbox.name); | 548 Platform3DObject sourceTexture = context->createAndConsumeTextureCHROMIU M(GL_TEXTURE_2D, m_frontColorBuffer.mailbox.name); |
555 context->copyTextureCHROMIUM(GL_TEXTURE_2D, sourceTexture, | 549 context->copyTextureCHROMIUM(GL_TEXTURE_2D, sourceTexture, |
556 tex, 0, GL_RGBA, GL_UNSIGNED_BYTE); | 550 tex, 0, GL_RGBA, GL_UNSIGNED_BYTE); |
557 context->deleteTexture(sourceTexture); | 551 context->deleteTexture(sourceTexture); |
558 context->flush(); | 552 context->flush(); |
559 m_context->waitSyncPoint(context->insertSyncPoint()); | 553 m_context->waitSyncPoint(context->insertSyncPoint()); |
560 imageBuffer->didModifyBackingTexture(); | 554 imageBuffer->didModifyBackingTexture(); |
561 | |
562 return; | 555 return; |
563 } | 556 } |
564 | 557 |
565 Platform3DObject framebuffer = m_context->createFramebuffer(); | 558 Platform3DObject framebuffer = m_context->createFramebuffer(); |
566 m_context->bindFramebuffer(GL_FRAMEBUFFER, framebuffer); | 559 m_context->bindFramebuffer(GL_FRAMEBUFFER, framebuffer); |
567 // We don't need to bind a copy of m_frontColorBuffer since the texture para meters are untouched. | 560 // We don't need to bind a copy of m_frontColorBuffer since the texture para meters are untouched. |
568 m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEX TURE_2D, m_frontColorBuffer.textureId, 0); | 561 m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEX TURE_2D, m_frontColorBuffer.texInfo.textureId, 0); |
569 | 562 |
570 paintFramebufferToCanvas(framebuffer, size().width(), size().height(), !m_ac tualAttributes.premultipliedAlpha, imageBuffer); | 563 paintFramebufferToCanvas(framebuffer, size().width(), size().height(), !m_ac tualAttributes.premultipliedAlpha, imageBuffer); |
571 m_context->deleteFramebuffer(framebuffer); | 564 m_context->deleteFramebuffer(framebuffer); |
572 // Since we're using the same context as WebGL, we have to restore any state we change (in this case, just the framebuffer binding). | 565 // Since we're using the same context as WebGL, we have to restore any state we change (in this case, just the framebuffer binding). |
573 restoreFramebufferBinding(); | 566 restoreFramebufferBinding(); |
574 } | 567 } |
575 | 568 |
576 void DrawingBuffer::clearPlatformLayer() | 569 void DrawingBuffer::clearPlatformLayer() |
577 { | 570 { |
578 if (m_layer) | 571 if (m_layer) |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
610 m_context->deleteRenderbuffer(m_stencilBuffer); | 603 m_context->deleteRenderbuffer(m_stencilBuffer); |
611 | 604 |
612 if (m_colorBuffer.textureId) { | 605 if (m_colorBuffer.textureId) { |
613 deleteChromiumImageForTexture(&m_colorBuffer); | 606 deleteChromiumImageForTexture(&m_colorBuffer); |
614 m_context->deleteTexture(m_colorBuffer.textureId); | 607 m_context->deleteTexture(m_colorBuffer.textureId); |
615 } | 608 } |
616 | 609 |
617 setSize(IntSize()); | 610 setSize(IntSize()); |
618 | 611 |
619 m_colorBuffer = TextureInfo(); | 612 m_colorBuffer = TextureInfo(); |
620 m_frontColorBuffer = TextureInfo(); | 613 m_frontColorBuffer = FrontBufferInfo(); |
621 m_multisampleColorBuffer = 0; | 614 m_multisampleColorBuffer = 0; |
622 m_depthStencilBuffer = 0; | 615 m_depthStencilBuffer = 0; |
623 m_depthBuffer = 0; | 616 m_depthBuffer = 0; |
624 m_stencilBuffer = 0; | 617 m_stencilBuffer = 0; |
625 m_multisampleFBO = 0; | 618 m_multisampleFBO = 0; |
626 m_fbo = 0; | 619 m_fbo = 0; |
627 m_contextEvictionManager.clear(); | 620 m_contextEvictionManager.clear(); |
628 | 621 |
629 if (m_layer) | 622 if (m_layer) |
630 GraphicsLayer::unregisterContentsLayer(m_layer->layer()); | 623 GraphicsLayer::unregisterContentsLayer(m_layer->layer()); |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1060 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) | 1053 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) |
1061 { | 1054 { |
1062 if (info->imageId) { | 1055 if (info->imageId) { |
1063 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId); | 1056 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId); |
1064 m_context->destroyImageCHROMIUM(info->imageId); | 1057 m_context->destroyImageCHROMIUM(info->imageId); |
1065 info->imageId = 0; | 1058 info->imageId = 0; |
1066 } | 1059 } |
1067 } | 1060 } |
1068 | 1061 |
1069 } // namespace blink | 1062 } // namespace blink |
OLD | NEW |