| 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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 | 269 |
| 270 // We must restore the texture binding since creating new textures, | 270 // We must restore the texture binding since creating new textures, |
| 271 // consuming and producing mailboxes changes it. | 271 // consuming and producing mailboxes changes it. |
| 272 ScopedTextureUnit0BindingRestorer restorer(m_gl, m_activeTextureUnit, m_text
ure2DBinding); | 272 ScopedTextureUnit0BindingRestorer restorer(m_gl, m_activeTextureUnit, m_text
ure2DBinding); |
| 273 | 273 |
| 274 // First try to recycle an old buffer. | 274 // First try to recycle an old buffer. |
| 275 RefPtr<MailboxInfo> frontColorBufferMailbox = recycledMailbox(); | 275 RefPtr<MailboxInfo> frontColorBufferMailbox = recycledMailbox(); |
| 276 | 276 |
| 277 // No buffer available to recycle, create a new one. | 277 // No buffer available to recycle, create a new one. |
| 278 if (!frontColorBufferMailbox) { | 278 if (!frontColorBufferMailbox) { |
| 279 frontColorBufferMailbox = createNewMailbox(createTextureAndAllocateMemor
y(m_size)); | 279 TextureInfo newTexture = createTextureAndAllocateMemory(m_size); |
| 280 // Bad things happened, abandon ship. |
| 281 if (!newTexture.textureId) |
| 282 return false; |
| 283 |
| 284 frontColorBufferMailbox = createNewMailbox(newTexture); |
| 280 } | 285 } |
| 281 | 286 |
| 282 if (m_preserveDrawingBuffer == Discard) { | 287 if (m_preserveDrawingBuffer == Discard) { |
| 283 std::swap(frontColorBufferMailbox->textureInfo, m_colorBuffer); | 288 std::swap(frontColorBufferMailbox->textureInfo, m_colorBuffer); |
| 284 // It appears safe to overwrite the context's framebuffer binding in the
Discard case since there will always be a | 289 // It appears safe to overwrite the context's framebuffer binding in the
Discard case since there will always be a |
| 285 // WebGLRenderingContext::clearIfComposited() call made before the next
draw call which restores the framebuffer binding. | 290 // WebGLRenderingContext::clearIfComposited() call made before the next
draw call which restores the framebuffer binding. |
| 286 // If this stops being true at some point, we should track the current f
ramebuffer binding in the DrawingBuffer and restore | 291 // If this stops being true at some point, we should track the current f
ramebuffer binding in the DrawingBuffer and restore |
| 287 // it after attaching the new back buffer here. | 292 // it after attaching the new back buffer here. |
| 288 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); | 293 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); |
| 289 attachColorBufferToCurrentFBO(); | 294 attachColorBufferToCurrentFBO(); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 | 432 |
| 428 void DrawingBuffer::deleteMailbox(const WebExternalTextureMailbox& mailbox) | 433 void DrawingBuffer::deleteMailbox(const WebExternalTextureMailbox& mailbox) |
| 429 { | 434 { |
| 430 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { | 435 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { |
| 431 if (nameEquals(m_textureMailboxes[i]->mailbox, mailbox)) { | 436 if (nameEquals(m_textureMailboxes[i]->mailbox, mailbox)) { |
| 432 if (mailbox.validSyncToken) | 437 if (mailbox.validSyncToken) |
| 433 m_gl->WaitSyncTokenCHROMIUM(mailbox.syncToken); | 438 m_gl->WaitSyncTokenCHROMIUM(mailbox.syncToken); |
| 434 | 439 |
| 435 deleteChromiumImageForTexture(&m_textureMailboxes[i]->textureInfo); | 440 deleteChromiumImageForTexture(&m_textureMailboxes[i]->textureInfo); |
| 436 | 441 |
| 437 m_gl->DeleteTextures(1, &m_textureMailboxes[i]->textureInfo.textureI
d); | 442 m_context->deleteTexture(m_textureMailboxes[i]->textureInfo.textureI
d); |
| 438 m_textureMailboxes.remove(i); | 443 m_textureMailboxes.remove(i); |
| 439 return; | 444 return; |
| 440 } | 445 } |
| 441 } | 446 } |
| 442 ASSERT_NOT_REACHED(); | 447 ASSERT_NOT_REACHED(); |
| 443 } | 448 } |
| 444 | 449 |
| 445 bool DrawingBuffer::initialize(const IntSize& size) | 450 bool DrawingBuffer::initialize(const IntSize& size) |
| 446 { | 451 { |
| 447 if (m_gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) { | 452 if (m_gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) { |
| 448 // Need to try to restore the context again later. | 453 // Need to try to restore the context again later. |
| 449 return false; | 454 return false; |
| 450 } | 455 } |
| 451 | 456 |
| 452 m_gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize); | 457 m_gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize); |
| 453 | 458 |
| 454 int maxSampleCount = 0; | 459 int maxSampleCount = 0; |
| 455 m_antiAliasingMode = None; | 460 m_antiAliasingMode = None; |
| 456 if (m_requestedAttributes.antialias && m_multisampleExtensionSupported) { | 461 if (m_requestedAttributes.antialias && m_multisampleExtensionSupported) { |
| 457 m_gl->GetIntegerv(GL_MAX_SAMPLES_ANGLE, &maxSampleCount); | 462 m_gl->GetIntegerv(GL_MAX_SAMPLES_ANGLE, &maxSampleCount); |
| 458 m_antiAliasingMode = MSAAExplicitResolve; | 463 m_antiAliasingMode = MSAAExplicitResolve; |
| 459 if (m_extensionsUtil->supportsExtension("GL_EXT_multisampled_render_to_t
exture")) { | 464 if (m_extensionsUtil->supportsExtension("GL_EXT_multisampled_render_to_t
exture")) { |
| 460 m_antiAliasingMode = MSAAImplicitResolve; | 465 m_antiAliasingMode = MSAAImplicitResolve; |
| 461 } else if (m_extensionsUtil->supportsExtension("GL_CHROMIUM_screen_space
_antialiasing")) { | 466 } else if (m_extensionsUtil->supportsExtension("GL_CHROMIUM_screen_space
_antialiasing")) { |
| 462 m_antiAliasingMode = ScreenSpaceAntialiasing; | 467 m_antiAliasingMode = ScreenSpaceAntialiasing; |
| 463 } | 468 } |
| 464 } | 469 } |
| 465 m_sampleCount = std::min(4, maxSampleCount); | 470 m_sampleCount = std::min(4, maxSampleCount); |
| 466 | 471 |
| 467 m_gl->GenFramebuffers(1, &m_fbo); | 472 m_fbo = m_context->createFramebuffer(); |
| 468 | 473 |
| 469 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); | 474 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); |
| 470 createSecondaryBuffers(); | 475 createSecondaryBuffers(); |
| 471 // We first try to initialize everything with the requested attributes. | 476 // We first try to initialize everything with the requested attributes. |
| 472 if (!reset(size)) | 477 if (!reset(size)) |
| 473 return false; | 478 return false; |
| 474 // If that succeeds, we then see what we actually got and update our actual
attributes to reflect that. | 479 // If that succeeds, we then see what we actually got and update our actual
attributes to reflect that. |
| 475 m_actualAttributes = m_requestedAttributes; | 480 m_actualAttributes = m_requestedAttributes; |
| 476 if (m_requestedAttributes.alpha) { | 481 if (m_requestedAttributes.alpha) { |
| 477 WGC3Dint alphaBits = 0; | 482 WGC3Dint alphaBits = 0; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 | 543 |
| 539 GLboolean unpackPremultiplyAlphaNeeded = GL_FALSE; | 544 GLboolean unpackPremultiplyAlphaNeeded = GL_FALSE; |
| 540 GLboolean unpackUnpremultiplyAlphaNeeded = GL_FALSE; | 545 GLboolean unpackUnpremultiplyAlphaNeeded = GL_FALSE; |
| 541 if (m_actualAttributes.alpha && m_actualAttributes.premultipliedAlpha && !pr
emultiplyAlpha) | 546 if (m_actualAttributes.alpha && m_actualAttributes.premultipliedAlpha && !pr
emultiplyAlpha) |
| 542 unpackUnpremultiplyAlphaNeeded = GL_TRUE; | 547 unpackUnpremultiplyAlphaNeeded = GL_TRUE; |
| 543 else if (m_actualAttributes.alpha && !m_actualAttributes.premultipliedAlpha
&& premultiplyAlpha) | 548 else if (m_actualAttributes.alpha && !m_actualAttributes.premultipliedAlpha
&& premultiplyAlpha) |
| 544 unpackPremultiplyAlphaNeeded = GL_TRUE; | 549 unpackPremultiplyAlphaNeeded = GL_TRUE; |
| 545 | 550 |
| 546 gl->CopyTextureCHROMIUM(sourceTexture, texture, internalFormat, destType, fl
ipY, unpackPremultiplyAlphaNeeded, unpackUnpremultiplyAlphaNeeded); | 551 gl->CopyTextureCHROMIUM(sourceTexture, texture, internalFormat, destType, fl
ipY, unpackPremultiplyAlphaNeeded, unpackUnpremultiplyAlphaNeeded); |
| 547 | 552 |
| 548 gl->DeleteTextures(1, &sourceTexture); | 553 context->deleteTexture(sourceTexture); |
| 549 | 554 |
| 550 const GLuint64 fenceSync = gl->InsertFenceSyncCHROMIUM(); | 555 const GLuint64 fenceSync = gl->InsertFenceSyncCHROMIUM(); |
| 551 | 556 |
| 552 gl->Flush(); | 557 gl->Flush(); |
| 553 GLbyte syncToken[24]; | 558 GLbyte syncToken[24]; |
| 554 gl->GenSyncTokenCHROMIUM(fenceSync, syncToken); | 559 gl->GenSyncTokenCHROMIUM(fenceSync, syncToken); |
| 555 m_gl->WaitSyncTokenCHROMIUM(syncToken); | 560 m_gl->WaitSyncTokenCHROMIUM(syncToken); |
| 556 | 561 |
| 557 return true; | 562 return true; |
| 558 } | 563 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 589 { | 594 { |
| 590 ASSERT(!m_destructionInProgress); | 595 ASSERT(!m_destructionInProgress); |
| 591 m_destructionInProgress = true; | 596 m_destructionInProgress = true; |
| 592 | 597 |
| 593 clearPlatformLayer(); | 598 clearPlatformLayer(); |
| 594 | 599 |
| 595 while (!m_recycledMailboxQueue.isEmpty()) | 600 while (!m_recycledMailboxQueue.isEmpty()) |
| 596 deleteMailbox(m_recycledMailboxQueue.takeLast()); | 601 deleteMailbox(m_recycledMailboxQueue.takeLast()); |
| 597 | 602 |
| 598 if (m_multisampleFBO) | 603 if (m_multisampleFBO) |
| 599 m_gl->DeleteFramebuffers(1, &m_multisampleFBO); | 604 m_context->deleteFramebuffer(m_multisampleFBO); |
| 600 | 605 |
| 601 if (m_fbo) | 606 if (m_fbo) |
| 602 m_gl->DeleteFramebuffers(1, &m_fbo); | 607 m_context->deleteFramebuffer(m_fbo); |
| 603 | 608 |
| 604 if (m_multisampleColorBuffer) | 609 if (m_multisampleColorBuffer) |
| 605 m_gl->DeleteRenderbuffers(1, &m_multisampleColorBuffer); | 610 m_context->deleteRenderbuffer(m_multisampleColorBuffer); |
| 606 | 611 |
| 607 if (m_depthStencilBuffer) | 612 if (m_depthStencilBuffer) |
| 608 m_gl->DeleteRenderbuffers(1, &m_depthStencilBuffer); | 613 m_context->deleteRenderbuffer(m_depthStencilBuffer); |
| 609 | 614 |
| 610 if (m_colorBuffer.textureId) { | 615 if (m_colorBuffer.textureId) { |
| 611 deleteChromiumImageForTexture(&m_colorBuffer); | 616 deleteChromiumImageForTexture(&m_colorBuffer); |
| 612 m_gl->DeleteTextures(1, &m_colorBuffer.textureId); | 617 m_context->deleteTexture(m_colorBuffer.textureId); |
| 613 } | 618 } |
| 614 | 619 |
| 615 setSize(IntSize()); | 620 setSize(IntSize()); |
| 616 | 621 |
| 617 m_colorBuffer = TextureInfo(); | 622 m_colorBuffer = TextureInfo(); |
| 618 m_frontColorBuffer = FrontBufferInfo(); | 623 m_frontColorBuffer = FrontBufferInfo(); |
| 619 m_multisampleColorBuffer = 0; | 624 m_multisampleColorBuffer = 0; |
| 620 m_depthStencilBuffer = 0; | 625 m_depthStencilBuffer = 0; |
| 621 m_multisampleFBO = 0; | 626 m_multisampleFBO = 0; |
| 622 m_fbo = 0; | 627 m_fbo = 0; |
| 623 | 628 |
| 624 if (m_layer) | 629 if (m_layer) |
| 625 GraphicsLayer::unregisterContentsLayer(m_layer->layer()); | 630 GraphicsLayer::unregisterContentsLayer(m_layer->layer()); |
| 626 } | 631 } |
| 627 | 632 |
| 628 WebGLId DrawingBuffer::createColorTexture(const TextureParameters& parameters) | 633 WebGLId DrawingBuffer::createColorTexture(const TextureParameters& parameters) |
| 629 { | 634 { |
| 630 GLuint offscreenColorTexture; | 635 WebGLId offscreenColorTexture = m_context->createTexture(); |
| 631 m_gl->GenTextures(1, &offscreenColorTexture); | 636 if (!offscreenColorTexture) |
| 637 return 0; |
| 638 |
| 632 m_gl->BindTexture(parameters.target, offscreenColorTexture); | 639 m_gl->BindTexture(parameters.target, offscreenColorTexture); |
| 633 m_gl->TexParameteri(parameters.target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | 640 m_gl->TexParameteri(parameters.target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 634 m_gl->TexParameteri(parameters.target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | 641 m_gl->TexParameteri(parameters.target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 635 m_gl->TexParameteri(parameters.target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 642 m_gl->TexParameteri(parameters.target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 636 m_gl->TexParameteri(parameters.target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 643 m_gl->TexParameteri(parameters.target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 644 |
| 637 return offscreenColorTexture; | 645 return offscreenColorTexture; |
| 638 } | 646 } |
| 639 | 647 |
| 640 void DrawingBuffer::createSecondaryBuffers() | 648 void DrawingBuffer::createSecondaryBuffers() |
| 641 { | 649 { |
| 642 // create a multisample FBO | 650 // create a multisample FBO |
| 643 if (m_antiAliasingMode == MSAAExplicitResolve) { | 651 if (m_antiAliasingMode == MSAAExplicitResolve) { |
| 644 m_gl->GenFramebuffers(1, &m_multisampleFBO); | 652 m_multisampleFBO = m_context->createFramebuffer(); |
| 645 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); | 653 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); |
| 646 m_gl->GenRenderbuffers(1, &m_multisampleColorBuffer); | 654 m_multisampleColorBuffer = m_context->createRenderbuffer(); |
| 647 } | 655 } |
| 648 } | 656 } |
| 649 | 657 |
| 650 bool DrawingBuffer::resizeFramebuffer(const IntSize& size) | 658 bool DrawingBuffer::resizeFramebuffer(const IntSize& size) |
| 651 { | 659 { |
| 652 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); | 660 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); |
| 653 if (m_antiAliasingMode != MSAAExplicitResolve) | 661 if (m_antiAliasingMode != MSAAExplicitResolve) |
| 654 resizeDepthStencil(size); | 662 resizeDepthStencil(size); |
| 655 if (m_gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) | 663 if (m_gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) |
| 656 return false; | 664 return false; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 677 | 685 |
| 678 return true; | 686 return true; |
| 679 } | 687 } |
| 680 | 688 |
| 681 void DrawingBuffer::resizeDepthStencil(const IntSize& size) | 689 void DrawingBuffer::resizeDepthStencil(const IntSize& size) |
| 682 { | 690 { |
| 683 if (!m_requestedAttributes.depth && !m_requestedAttributes.stencil) | 691 if (!m_requestedAttributes.depth && !m_requestedAttributes.stencil) |
| 684 return; | 692 return; |
| 685 | 693 |
| 686 if (!m_depthStencilBuffer) | 694 if (!m_depthStencilBuffer) |
| 687 m_gl->GenRenderbuffers(1, &m_depthStencilBuffer); | 695 m_depthStencilBuffer = m_context->createRenderbuffer(); |
| 688 m_gl->BindRenderbuffer(GL_RENDERBUFFER, m_depthStencilBuffer); | 696 m_gl->BindRenderbuffer(GL_RENDERBUFFER, m_depthStencilBuffer); |
| 689 if (m_antiAliasingMode == MSAAImplicitResolve) | 697 if (m_antiAliasingMode == MSAAImplicitResolve) |
| 690 m_gl->RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_sampleCount,
GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); | 698 m_gl->RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_sampleCount,
GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); |
| 691 else if (m_antiAliasingMode == MSAAExplicitResolve) | 699 else if (m_antiAliasingMode == MSAAExplicitResolve) |
| 692 m_gl->RenderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m_sampleCo
unt, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); | 700 m_gl->RenderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m_sampleCo
unt, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); |
| 693 else | 701 else |
| 694 m_gl->RenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, size
.width(), size.height()); | 702 m_gl->RenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, size
.width(), size.height()); |
| 695 m_gl->FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, G
L_RENDERBUFFER, m_depthStencilBuffer); | 703 m_gl->FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, G
L_RENDERBUFFER, m_depthStencilBuffer); |
| 696 m_gl->BindRenderbuffer(GL_RENDERBUFFER, 0); | 704 m_gl->BindRenderbuffer(GL_RENDERBUFFER, 0); |
| 697 } | 705 } |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 863 height = size().height(); | 871 height = size().height(); |
| 864 | 872 |
| 865 Checked<int, RecordOverflow> dataSize = 4; | 873 Checked<int, RecordOverflow> dataSize = 4; |
| 866 dataSize *= width; | 874 dataSize *= width; |
| 867 dataSize *= height; | 875 dataSize *= height; |
| 868 if (dataSize.hasOverflowed()) | 876 if (dataSize.hasOverflowed()) |
| 869 return false; | 877 return false; |
| 870 | 878 |
| 871 WTF::ArrayBufferContents pixels(width * height, 4, WTF::ArrayBufferContents:
:NotShared, WTF::ArrayBufferContents::DontInitialize); | 879 WTF::ArrayBufferContents pixels(width * height, 4, WTF::ArrayBufferContents:
:NotShared, WTF::ArrayBufferContents::DontInitialize); |
| 872 | 880 |
| 873 GLuint fbo = 0; | 881 GLint fbo = 0; |
| 874 if (sourceBuffer == FrontBuffer && m_frontColorBuffer.texInfo.textureId) { | 882 if (sourceBuffer == FrontBuffer && m_frontColorBuffer.texInfo.textureId) { |
| 875 m_gl->GenFramebuffers(1, &fbo); | 883 fbo = m_context->createFramebuffer(); |
| 876 m_gl->BindFramebuffer(GL_FRAMEBUFFER, fbo); | 884 m_gl->BindFramebuffer(GL_FRAMEBUFFER, fbo); |
| 877 m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_front
ColorBuffer.texInfo.parameters.target, m_frontColorBuffer.texInfo.textureId, 0); | 885 m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_front
ColorBuffer.texInfo.parameters.target, m_frontColorBuffer.texInfo.textureId, 0); |
| 878 } else { | 886 } else { |
| 879 m_gl->BindFramebuffer(GL_FRAMEBUFFER, framebuffer()); | 887 m_gl->BindFramebuffer(GL_FRAMEBUFFER, framebuffer()); |
| 880 } | 888 } |
| 881 | 889 |
| 882 readBackFramebuffer(static_cast<unsigned char*>(pixels.data()), width, heigh
t, ReadbackRGBA, WebGLImageConversion::AlphaDoNothing); | 890 readBackFramebuffer(static_cast<unsigned char*>(pixels.data()), width, heigh
t, ReadbackRGBA, WebGLImageConversion::AlphaDoNothing); |
| 883 flipVertically(static_cast<uint8_t*>(pixels.data()), width, height); | 891 flipVertically(static_cast<uint8_t*>(pixels.data()), width, height); |
| 884 | 892 |
| 885 if (fbo) { | 893 if (fbo) { |
| 886 m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_front
ColorBuffer.texInfo.parameters.target, 0, 0); | 894 m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_front
ColorBuffer.texInfo.parameters.target, 0, 0); |
| 887 m_gl->DeleteFramebuffers(1, &fbo); | 895 m_context->deleteFramebuffer(fbo); |
| 888 } | 896 } |
| 889 | 897 |
| 890 restoreFramebufferBindings(); | 898 restoreFramebufferBindings(); |
| 891 | 899 |
| 892 pixels.transfer(contents); | 900 pixels.transfer(contents); |
| 893 return true; | 901 return true; |
| 894 } | 902 } |
| 895 | 903 |
| 896 void DrawingBuffer::readBackFramebuffer(unsigned char* pixels, int width, int he
ight, ReadbackOrder readbackOrder, WebGLImageConversion::AlphaOp op) | 904 void DrawingBuffer::readBackFramebuffer(unsigned char* pixels, int width, int he
ight, ReadbackOrder readbackOrder, WebGLImageConversion::AlphaOp op) |
| 897 { | 905 { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 return createDefaultTextureAndAllocateMemory(size); | 975 return createDefaultTextureAndAllocateMemory(size); |
| 968 | 976 |
| 969 // First, try to allocate a CHROMIUM_image. This always has the potential to | 977 // First, try to allocate a CHROMIUM_image. This always has the potential to |
| 970 // fail. | 978 // fail. |
| 971 TextureParameters parameters = chromiumImageTextureParameters(); | 979 TextureParameters parameters = chromiumImageTextureParameters(); |
| 972 WGC3Duint imageId = m_gl->CreateGpuMemoryBufferImageCHROMIUM(size.width(), s
ize.height(), parameters.internalColorFormat, GC3D_SCANOUT_CHROMIUM); | 980 WGC3Duint imageId = m_gl->CreateGpuMemoryBufferImageCHROMIUM(size.width(), s
ize.height(), parameters.internalColorFormat, GC3D_SCANOUT_CHROMIUM); |
| 973 if (!imageId) | 981 if (!imageId) |
| 974 return createDefaultTextureAndAllocateMemory(size); | 982 return createDefaultTextureAndAllocateMemory(size); |
| 975 | 983 |
| 976 WebGLId textureId = createColorTexture(parameters); | 984 WebGLId textureId = createColorTexture(parameters); |
| 985 if (!textureId) { |
| 986 m_gl->DestroyImageCHROMIUM(imageId); |
| 987 return createDefaultTextureAndAllocateMemory(size); |
| 988 } |
| 989 |
| 977 m_gl->BindTexImage2DCHROMIUM(parameters.target, imageId); | 990 m_gl->BindTexImage2DCHROMIUM(parameters.target, imageId); |
| 978 | 991 |
| 979 TextureInfo info; | 992 TextureInfo info; |
| 980 info.textureId = textureId; | 993 info.textureId = textureId; |
| 981 info.imageId = imageId; | 994 info.imageId = imageId; |
| 982 info.parameters = parameters; | 995 info.parameters = parameters; |
| 983 return info; | 996 return info; |
| 984 } | 997 } |
| 985 | 998 |
| 986 DrawingBuffer::TextureInfo DrawingBuffer::createDefaultTextureAndAllocateMemory(
const IntSize& size) | 999 DrawingBuffer::TextureInfo DrawingBuffer::createDefaultTextureAndAllocateMemory(
const IntSize& size) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 | 1038 |
| 1026 if (m_antiAliasingMode == MSAAImplicitResolve) | 1039 if (m_antiAliasingMode == MSAAImplicitResolve) |
| 1027 m_gl->FramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACH
MENT0, target, m_colorBuffer.textureId, 0, m_sampleCount); | 1040 m_gl->FramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACH
MENT0, target, m_colorBuffer.textureId, 0, m_sampleCount); |
| 1028 else | 1041 else |
| 1029 m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target,
m_colorBuffer.textureId, 0); | 1042 m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target,
m_colorBuffer.textureId, 0); |
| 1030 | 1043 |
| 1031 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); | 1044 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); |
| 1032 } | 1045 } |
| 1033 | 1046 |
| 1034 } // namespace blink | 1047 } // namespace blink |
| OLD | NEW |