Chromium Code Reviews| 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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 TextureInfo newTexture = createTextureAndAllocateMemory(m_size); | 279 TextureInfo newTexture = createTextureAndAllocateMemory(m_size); |
| 280 // Bad things happened, abandon ship. | 280 // Bad things happened, abandon ship. |
| 281 if (!newTexture.textureId) | 281 if (!newTexture.textureId) |
|
danakj
2016/03/22 00:21:26
ditto.
This fixes the rest of the tests.
| |
| 282 return false; | 282 return false; |
| 283 | 283 |
| 284 frontColorBufferMailbox = createNewMailbox(newTexture); | 284 frontColorBufferMailbox = createNewMailbox(newTexture); |
| 285 } | 285 } |
| 286 | 286 |
| 287 if (m_preserveDrawingBuffer == Discard) { | 287 if (m_preserveDrawingBuffer == Discard) { |
| 288 std::swap(frontColorBufferMailbox->textureInfo, m_colorBuffer); | 288 std::swap(frontColorBufferMailbox->textureInfo, m_colorBuffer); |
| 289 // 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 |
| 290 // 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. |
| 291 // 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 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 432 | 432 |
| 433 void DrawingBuffer::deleteMailbox(const WebExternalTextureMailbox& mailbox) | 433 void DrawingBuffer::deleteMailbox(const WebExternalTextureMailbox& mailbox) |
| 434 { | 434 { |
| 435 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { | 435 for (size_t i = 0; i < m_textureMailboxes.size(); i++) { |
| 436 if (nameEquals(m_textureMailboxes[i]->mailbox, mailbox)) { | 436 if (nameEquals(m_textureMailboxes[i]->mailbox, mailbox)) { |
| 437 if (mailbox.validSyncToken) | 437 if (mailbox.validSyncToken) |
| 438 m_gl->WaitSyncTokenCHROMIUM(mailbox.syncToken); | 438 m_gl->WaitSyncTokenCHROMIUM(mailbox.syncToken); |
| 439 | 439 |
| 440 deleteChromiumImageForTexture(&m_textureMailboxes[i]->textureInfo); | 440 deleteChromiumImageForTexture(&m_textureMailboxes[i]->textureInfo); |
| 441 | 441 |
| 442 m_context->deleteTexture(m_textureMailboxes[i]->textureInfo.textureI d); | 442 m_gl->DeleteTextures(1, &m_textureMailboxes[i]->textureInfo.textureI d); |
| 443 m_textureMailboxes.remove(i); | 443 m_textureMailboxes.remove(i); |
| 444 return; | 444 return; |
| 445 } | 445 } |
| 446 } | 446 } |
| 447 ASSERT_NOT_REACHED(); | 447 ASSERT_NOT_REACHED(); |
| 448 } | 448 } |
| 449 | 449 |
| 450 bool DrawingBuffer::initialize(const IntSize& size) | 450 bool DrawingBuffer::initialize(const IntSize& size) |
| 451 { | 451 { |
| 452 if (m_gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) { | 452 if (m_gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR) { |
| 453 // Need to try to restore the context again later. | 453 // Need to try to restore the context again later. |
| 454 return false; | 454 return false; |
| 455 } | 455 } |
| 456 | 456 |
| 457 m_gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize); | 457 m_gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize); |
| 458 | 458 |
| 459 int maxSampleCount = 0; | 459 int maxSampleCount = 0; |
| 460 m_antiAliasingMode = None; | 460 m_antiAliasingMode = None; |
| 461 if (m_requestedAttributes.antialias && m_multisampleExtensionSupported) { | 461 if (m_requestedAttributes.antialias && m_multisampleExtensionSupported) { |
| 462 m_gl->GetIntegerv(GL_MAX_SAMPLES_ANGLE, &maxSampleCount); | 462 m_gl->GetIntegerv(GL_MAX_SAMPLES_ANGLE, &maxSampleCount); |
| 463 m_antiAliasingMode = MSAAExplicitResolve; | 463 m_antiAliasingMode = MSAAExplicitResolve; |
| 464 if (m_extensionsUtil->supportsExtension("GL_EXT_multisampled_render_to_t exture")) { | 464 if (m_extensionsUtil->supportsExtension("GL_EXT_multisampled_render_to_t exture")) { |
| 465 m_antiAliasingMode = MSAAImplicitResolve; | 465 m_antiAliasingMode = MSAAImplicitResolve; |
| 466 } else if (m_extensionsUtil->supportsExtension("GL_CHROMIUM_screen_space _antialiasing")) { | 466 } else if (m_extensionsUtil->supportsExtension("GL_CHROMIUM_screen_space _antialiasing")) { |
| 467 m_antiAliasingMode = ScreenSpaceAntialiasing; | 467 m_antiAliasingMode = ScreenSpaceAntialiasing; |
| 468 } | 468 } |
| 469 } | 469 } |
| 470 m_sampleCount = std::min(4, maxSampleCount); | 470 m_sampleCount = std::min(4, maxSampleCount); |
| 471 | 471 |
| 472 m_fbo = m_context->createFramebuffer(); | 472 m_gl->GenFramebuffers(1, &m_fbo); |
| 473 | 473 |
| 474 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); | 474 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); |
| 475 createSecondaryBuffers(); | 475 createSecondaryBuffers(); |
| 476 // We first try to initialize everything with the requested attributes. | 476 // We first try to initialize everything with the requested attributes. |
| 477 if (!reset(size)) | 477 if (!reset(size)) |
| 478 return false; | 478 return false; |
| 479 // 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. |
| 480 m_actualAttributes = m_requestedAttributes; | 480 m_actualAttributes = m_requestedAttributes; |
| 481 if (m_requestedAttributes.alpha) { | 481 if (m_requestedAttributes.alpha) { |
| 482 WGC3Dint alphaBits = 0; | 482 WGC3Dint alphaBits = 0; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 543 | 543 |
| 544 GLboolean unpackPremultiplyAlphaNeeded = GL_FALSE; | 544 GLboolean unpackPremultiplyAlphaNeeded = GL_FALSE; |
| 545 GLboolean unpackUnpremultiplyAlphaNeeded = GL_FALSE; | 545 GLboolean unpackUnpremultiplyAlphaNeeded = GL_FALSE; |
| 546 if (m_actualAttributes.alpha && m_actualAttributes.premultipliedAlpha && !pr emultiplyAlpha) | 546 if (m_actualAttributes.alpha && m_actualAttributes.premultipliedAlpha && !pr emultiplyAlpha) |
| 547 unpackUnpremultiplyAlphaNeeded = GL_TRUE; | 547 unpackUnpremultiplyAlphaNeeded = GL_TRUE; |
| 548 else if (m_actualAttributes.alpha && !m_actualAttributes.premultipliedAlpha && premultiplyAlpha) | 548 else if (m_actualAttributes.alpha && !m_actualAttributes.premultipliedAlpha && premultiplyAlpha) |
| 549 unpackPremultiplyAlphaNeeded = GL_TRUE; | 549 unpackPremultiplyAlphaNeeded = GL_TRUE; |
| 550 | 550 |
| 551 gl->CopyTextureCHROMIUM(sourceTexture, texture, internalFormat, destType, fl ipY, unpackPremultiplyAlphaNeeded, unpackUnpremultiplyAlphaNeeded); | 551 gl->CopyTextureCHROMIUM(sourceTexture, texture, internalFormat, destType, fl ipY, unpackPremultiplyAlphaNeeded, unpackUnpremultiplyAlphaNeeded); |
| 552 | 552 |
| 553 context->deleteTexture(sourceTexture); | 553 gl->DeleteTextures(1, &sourceTexture); |
| 554 | 554 |
| 555 const GLuint64 fenceSync = gl->InsertFenceSyncCHROMIUM(); | 555 const GLuint64 fenceSync = gl->InsertFenceSyncCHROMIUM(); |
| 556 | 556 |
| 557 gl->Flush(); | 557 gl->Flush(); |
| 558 GLbyte syncToken[24]; | 558 GLbyte syncToken[24]; |
| 559 gl->GenSyncTokenCHROMIUM(fenceSync, syncToken); | 559 gl->GenSyncTokenCHROMIUM(fenceSync, syncToken); |
| 560 m_gl->WaitSyncTokenCHROMIUM(syncToken); | 560 m_gl->WaitSyncTokenCHROMIUM(syncToken); |
| 561 | 561 |
| 562 return true; | 562 return true; |
| 563 } | 563 } |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 594 { | 594 { |
| 595 ASSERT(!m_destructionInProgress); | 595 ASSERT(!m_destructionInProgress); |
| 596 m_destructionInProgress = true; | 596 m_destructionInProgress = true; |
| 597 | 597 |
| 598 clearPlatformLayer(); | 598 clearPlatformLayer(); |
| 599 | 599 |
| 600 while (!m_recycledMailboxQueue.isEmpty()) | 600 while (!m_recycledMailboxQueue.isEmpty()) |
| 601 deleteMailbox(m_recycledMailboxQueue.takeLast()); | 601 deleteMailbox(m_recycledMailboxQueue.takeLast()); |
| 602 | 602 |
| 603 if (m_multisampleFBO) | 603 if (m_multisampleFBO) |
| 604 m_context->deleteFramebuffer(m_multisampleFBO); | 604 m_gl->DeleteFramebuffers(1, &m_multisampleFBO); |
| 605 | 605 |
| 606 if (m_fbo) | 606 if (m_fbo) |
| 607 m_context->deleteFramebuffer(m_fbo); | 607 m_gl->DeleteFramebuffers(1, &m_fbo); |
| 608 | 608 |
| 609 if (m_multisampleColorBuffer) | 609 if (m_multisampleColorBuffer) |
| 610 m_context->deleteRenderbuffer(m_multisampleColorBuffer); | 610 m_gl->DeleteRenderbuffers(1, &m_multisampleColorBuffer); |
| 611 | 611 |
| 612 if (m_depthStencilBuffer) | 612 if (m_depthStencilBuffer) |
| 613 m_context->deleteRenderbuffer(m_depthStencilBuffer); | 613 m_gl->DeleteRenderbuffers(1, &m_depthStencilBuffer); |
| 614 | 614 |
| 615 if (m_colorBuffer.textureId) { | 615 if (m_colorBuffer.textureId) { |
| 616 deleteChromiumImageForTexture(&m_colorBuffer); | 616 deleteChromiumImageForTexture(&m_colorBuffer); |
| 617 m_context->deleteTexture(m_colorBuffer.textureId); | 617 m_gl->DeleteTextures(1, &m_colorBuffer.textureId); |
| 618 } | 618 } |
| 619 | 619 |
| 620 setSize(IntSize()); | 620 setSize(IntSize()); |
| 621 | 621 |
| 622 m_colorBuffer = TextureInfo(); | 622 m_colorBuffer = TextureInfo(); |
| 623 m_frontColorBuffer = FrontBufferInfo(); | 623 m_frontColorBuffer = FrontBufferInfo(); |
| 624 m_multisampleColorBuffer = 0; | 624 m_multisampleColorBuffer = 0; |
| 625 m_depthStencilBuffer = 0; | 625 m_depthStencilBuffer = 0; |
| 626 m_multisampleFBO = 0; | 626 m_multisampleFBO = 0; |
| 627 m_fbo = 0; | 627 m_fbo = 0; |
| 628 | 628 |
| 629 if (m_layer) | 629 if (m_layer) |
| 630 GraphicsLayer::unregisterContentsLayer(m_layer->layer()); | 630 GraphicsLayer::unregisterContentsLayer(m_layer->layer()); |
| 631 } | 631 } |
| 632 | 632 |
| 633 WebGLId DrawingBuffer::createColorTexture(const TextureParameters& parameters) | 633 WebGLId DrawingBuffer::createColorTexture(const TextureParameters& parameters) |
| 634 { | 634 { |
| 635 WebGLId offscreenColorTexture = m_context->createTexture(); | 635 GLuint offscreenColorTexture; |
| 636 m_gl->GenTextures(1, &offscreenColorTexture); | |
| 636 if (!offscreenColorTexture) | 637 if (!offscreenColorTexture) |
|
danakj
2016/03/22 00:21:26
This is one problem. Texture id can't be 0 from Ge
Ken Russell (switch to Gerrit)
2016/03/22 00:30:30
What about the situation where the context's been
danakj
2016/03/22 00:37:14
I don't think that has any impact on our ability t
| |
| 637 return 0; | 638 return 0; |
| 638 | 639 |
| 639 m_gl->BindTexture(parameters.target, offscreenColorTexture); | 640 m_gl->BindTexture(parameters.target, offscreenColorTexture); |
| 640 m_gl->TexParameteri(parameters.target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | 641 m_gl->TexParameteri(parameters.target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 641 m_gl->TexParameteri(parameters.target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | 642 m_gl->TexParameteri(parameters.target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 642 m_gl->TexParameteri(parameters.target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 643 m_gl->TexParameteri(parameters.target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 643 m_gl->TexParameteri(parameters.target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 644 m_gl->TexParameteri(parameters.target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 644 | 645 |
| 645 return offscreenColorTexture; | 646 return offscreenColorTexture; |
| 646 } | 647 } |
| 647 | 648 |
| 648 void DrawingBuffer::createSecondaryBuffers() | 649 void DrawingBuffer::createSecondaryBuffers() |
| 649 { | 650 { |
| 650 // create a multisample FBO | 651 // create a multisample FBO |
| 651 if (m_antiAliasingMode == MSAAExplicitResolve) { | 652 if (m_antiAliasingMode == MSAAExplicitResolve) { |
| 652 m_multisampleFBO = m_context->createFramebuffer(); | 653 m_gl->GenFramebuffers(1, &m_multisampleFBO); |
| 653 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); | 654 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); |
| 654 m_multisampleColorBuffer = m_context->createRenderbuffer(); | 655 m_gl->GenRenderbuffers(1, &m_multisampleColorBuffer); |
| 655 } | 656 } |
| 656 } | 657 } |
| 657 | 658 |
| 658 bool DrawingBuffer::resizeFramebuffer(const IntSize& size) | 659 bool DrawingBuffer::resizeFramebuffer(const IntSize& size) |
| 659 { | 660 { |
| 660 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); | 661 m_gl->BindFramebuffer(GL_FRAMEBUFFER, m_fbo); |
| 661 if (m_antiAliasingMode != MSAAExplicitResolve) | 662 if (m_antiAliasingMode != MSAAExplicitResolve) |
| 662 resizeDepthStencil(size); | 663 resizeDepthStencil(size); |
| 663 if (m_gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) | 664 if (m_gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) |
| 664 return false; | 665 return false; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 685 | 686 |
| 686 return true; | 687 return true; |
| 687 } | 688 } |
| 688 | 689 |
| 689 void DrawingBuffer::resizeDepthStencil(const IntSize& size) | 690 void DrawingBuffer::resizeDepthStencil(const IntSize& size) |
| 690 { | 691 { |
| 691 if (!m_requestedAttributes.depth && !m_requestedAttributes.stencil) | 692 if (!m_requestedAttributes.depth && !m_requestedAttributes.stencil) |
| 692 return; | 693 return; |
| 693 | 694 |
| 694 if (!m_depthStencilBuffer) | 695 if (!m_depthStencilBuffer) |
| 695 m_depthStencilBuffer = m_context->createRenderbuffer(); | 696 m_gl->GenRenderbuffers(1, &m_depthStencilBuffer); |
| 696 m_gl->BindRenderbuffer(GL_RENDERBUFFER, m_depthStencilBuffer); | 697 m_gl->BindRenderbuffer(GL_RENDERBUFFER, m_depthStencilBuffer); |
| 697 if (m_antiAliasingMode == MSAAImplicitResolve) | 698 if (m_antiAliasingMode == MSAAImplicitResolve) |
| 698 m_gl->RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_sampleCount, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); | 699 m_gl->RenderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_sampleCount, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); |
| 699 else if (m_antiAliasingMode == MSAAExplicitResolve) | 700 else if (m_antiAliasingMode == MSAAExplicitResolve) |
| 700 m_gl->RenderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m_sampleCo unt, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); | 701 m_gl->RenderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m_sampleCo unt, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); |
| 701 else | 702 else |
| 702 m_gl->RenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, size .width(), size.height()); | 703 m_gl->RenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, size .width(), size.height()); |
| 703 m_gl->FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, G L_RENDERBUFFER, m_depthStencilBuffer); | 704 m_gl->FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, G L_RENDERBUFFER, m_depthStencilBuffer); |
| 704 m_gl->BindRenderbuffer(GL_RENDERBUFFER, 0); | 705 m_gl->BindRenderbuffer(GL_RENDERBUFFER, 0); |
| 705 } | 706 } |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 871 height = size().height(); | 872 height = size().height(); |
| 872 | 873 |
| 873 Checked<int, RecordOverflow> dataSize = 4; | 874 Checked<int, RecordOverflow> dataSize = 4; |
| 874 dataSize *= width; | 875 dataSize *= width; |
| 875 dataSize *= height; | 876 dataSize *= height; |
| 876 if (dataSize.hasOverflowed()) | 877 if (dataSize.hasOverflowed()) |
| 877 return false; | 878 return false; |
| 878 | 879 |
| 879 WTF::ArrayBufferContents pixels(width * height, 4, WTF::ArrayBufferContents: :NotShared, WTF::ArrayBufferContents::DontInitialize); | 880 WTF::ArrayBufferContents pixels(width * height, 4, WTF::ArrayBufferContents: :NotShared, WTF::ArrayBufferContents::DontInitialize); |
| 880 | 881 |
| 881 GLint fbo = 0; | 882 GLuint fbo = 0; |
| 882 if (sourceBuffer == FrontBuffer && m_frontColorBuffer.texInfo.textureId) { | 883 if (sourceBuffer == FrontBuffer && m_frontColorBuffer.texInfo.textureId) { |
| 883 fbo = m_context->createFramebuffer(); | 884 m_gl->GenFramebuffers(1, &fbo); |
| 884 m_gl->BindFramebuffer(GL_FRAMEBUFFER, fbo); | 885 m_gl->BindFramebuffer(GL_FRAMEBUFFER, fbo); |
| 885 m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_front ColorBuffer.texInfo.parameters.target, m_frontColorBuffer.texInfo.textureId, 0); | 886 m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_front ColorBuffer.texInfo.parameters.target, m_frontColorBuffer.texInfo.textureId, 0); |
| 886 } else { | 887 } else { |
| 887 m_gl->BindFramebuffer(GL_FRAMEBUFFER, framebuffer()); | 888 m_gl->BindFramebuffer(GL_FRAMEBUFFER, framebuffer()); |
| 888 } | 889 } |
| 889 | 890 |
| 890 readBackFramebuffer(static_cast<unsigned char*>(pixels.data()), width, heigh t, ReadbackRGBA, WebGLImageConversion::AlphaDoNothing); | 891 readBackFramebuffer(static_cast<unsigned char*>(pixels.data()), width, heigh t, ReadbackRGBA, WebGLImageConversion::AlphaDoNothing); |
| 891 flipVertically(static_cast<uint8_t*>(pixels.data()), width, height); | 892 flipVertically(static_cast<uint8_t*>(pixels.data()), width, height); |
| 892 | 893 |
| 893 if (fbo) { | 894 if (fbo) { |
| 894 m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_front ColorBuffer.texInfo.parameters.target, 0, 0); | 895 m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_front ColorBuffer.texInfo.parameters.target, 0, 0); |
| 895 m_context->deleteFramebuffer(fbo); | 896 m_gl->DeleteFramebuffers(1, &fbo); |
| 896 } | 897 } |
| 897 | 898 |
| 898 restoreFramebufferBindings(); | 899 restoreFramebufferBindings(); |
| 899 | 900 |
| 900 pixels.transfer(contents); | 901 pixels.transfer(contents); |
| 901 return true; | 902 return true; |
| 902 } | 903 } |
| 903 | 904 |
| 904 void DrawingBuffer::readBackFramebuffer(unsigned char* pixels, int width, int he ight, ReadbackOrder readbackOrder, WebGLImageConversion::AlphaOp op) | 905 void DrawingBuffer::readBackFramebuffer(unsigned char* pixels, int width, int he ight, ReadbackOrder readbackOrder, WebGLImageConversion::AlphaOp op) |
| 905 { | 906 { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 975 return createDefaultTextureAndAllocateMemory(size); | 976 return createDefaultTextureAndAllocateMemory(size); |
| 976 | 977 |
| 977 // First, try to allocate a CHROMIUM_image. This always has the potential to | 978 // First, try to allocate a CHROMIUM_image. This always has the potential to |
| 978 // fail. | 979 // fail. |
| 979 TextureParameters parameters = chromiumImageTextureParameters(); | 980 TextureParameters parameters = chromiumImageTextureParameters(); |
| 980 WGC3Duint imageId = m_gl->CreateGpuMemoryBufferImageCHROMIUM(size.width(), s ize.height(), parameters.internalColorFormat, GC3D_SCANOUT_CHROMIUM); | 981 WGC3Duint imageId = m_gl->CreateGpuMemoryBufferImageCHROMIUM(size.width(), s ize.height(), parameters.internalColorFormat, GC3D_SCANOUT_CHROMIUM); |
| 981 if (!imageId) | 982 if (!imageId) |
| 982 return createDefaultTextureAndAllocateMemory(size); | 983 return createDefaultTextureAndAllocateMemory(size); |
| 983 | 984 |
| 984 WebGLId textureId = createColorTexture(parameters); | 985 WebGLId textureId = createColorTexture(parameters); |
| 985 if (!textureId) { | 986 if (!textureId) { |
|
danakj
2016/03/22 00:21:26
ditto
| |
| 986 m_gl->DestroyImageCHROMIUM(imageId); | 987 m_gl->DestroyImageCHROMIUM(imageId); |
| 987 return createDefaultTextureAndAllocateMemory(size); | 988 return createDefaultTextureAndAllocateMemory(size); |
| 988 } | 989 } |
| 989 | 990 |
| 990 m_gl->BindTexImage2DCHROMIUM(parameters.target, imageId); | 991 m_gl->BindTexImage2DCHROMIUM(parameters.target, imageId); |
| 991 | 992 |
| 992 TextureInfo info; | 993 TextureInfo info; |
| 993 info.textureId = textureId; | 994 info.textureId = textureId; |
| 994 info.imageId = imageId; | 995 info.imageId = imageId; |
| 995 info.parameters = parameters; | 996 info.parameters = parameters; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1038 | 1039 |
| 1039 if (m_antiAliasingMode == MSAAImplicitResolve) | 1040 if (m_antiAliasingMode == MSAAImplicitResolve) |
| 1040 m_gl->FramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACH MENT0, target, m_colorBuffer.textureId, 0, m_sampleCount); | 1041 m_gl->FramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACH MENT0, target, m_colorBuffer.textureId, 0, m_sampleCount); |
| 1041 else | 1042 else |
| 1042 m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target, m_colorBuffer.textureId, 0); | 1043 m_gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target, m_colorBuffer.textureId, 0); |
| 1043 | 1044 |
| 1044 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); | 1045 m_gl->BindTexture(GL_TEXTURE_2D, m_texture2DBinding); |
| 1045 } | 1046 } |
| 1046 | 1047 |
| 1047 } // namespace blink | 1048 } // namespace blink |
| OLD | NEW |