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 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 613 } | 613 } |
| 614 } | 614 } |
| 615 | 615 |
| 616 bool DrawingBuffer::resizeFramebuffer(const IntSize& size) | 616 bool DrawingBuffer::resizeFramebuffer(const IntSize& size) |
| 617 { | 617 { |
| 618 // resize regular FBO | 618 // resize regular FBO |
| 619 m_context->bindFramebuffer(GL_FRAMEBUFFER, m_fbo); | 619 m_context->bindFramebuffer(GL_FRAMEBUFFER, m_fbo); |
| 620 | 620 |
| 621 m_context->bindTexture(GL_TEXTURE_2D, m_colorBuffer.textureId); | 621 m_context->bindTexture(GL_TEXTURE_2D, m_colorBuffer.textureId); |
| 622 | 622 |
| 623 allocateTextureMemory(&m_colorBuffer, size); | 623 if (!allocateTextureMemory(&m_colorBuffer, size)) |
| 624 return false; | |
| 624 | 625 |
| 625 if (m_multisampleMode == ImplicitResolve) | 626 if (m_multisampleMode == ImplicitResolve) |
| 626 m_context->framebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_A TTACHMENT0, GL_TEXTURE_2D, m_colorBuffer.textureId, 0, m_sampleCount); | 627 m_context->framebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_A TTACHMENT0, GL_TEXTURE_2D, m_colorBuffer.textureId, 0, m_sampleCount); |
| 627 else | 628 else |
| 628 m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL _TEXTURE_2D, m_colorBuffer.textureId, 0); | 629 m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL _TEXTURE_2D, m_colorBuffer.textureId, 0); |
| 629 | 630 |
| 630 m_context->bindTexture(GL_TEXTURE_2D, 0); | 631 m_context->bindTexture(GL_TEXTURE_2D, 0); |
| 631 | 632 |
| 632 if (m_multisampleMode != ExplicitResolve) | 633 if (m_multisampleMode != ExplicitResolve) { |
| 633 resizeDepthStencil(size); | 634 if (!resizeDepthStencil(size)) |
| 635 return false; | |
| 636 } | |
| 634 if (m_context->checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMP LETE) | 637 if (m_context->checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMP LETE) |
| 635 return false; | 638 return false; |
| 636 | 639 |
| 637 return true; | 640 return true; |
| 638 } | 641 } |
| 639 | 642 |
| 640 bool DrawingBuffer::resizeMultisampleFramebuffer(const IntSize& size) | 643 bool DrawingBuffer::resizeMultisampleFramebuffer(const IntSize& size) |
| 641 { | 644 { |
| 642 if (m_multisampleMode == ExplicitResolve) { | 645 if (m_multisampleMode == ExplicitResolve) { |
| 643 m_context->bindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); | 646 m_context->bindFramebuffer(GL_FRAMEBUFFER, m_multisampleFBO); |
| 644 | 647 |
| 645 m_context->bindRenderbuffer(GL_RENDERBUFFER, m_multisampleColorBuffer); | 648 m_context->bindRenderbuffer(GL_RENDERBUFFER, m_multisampleColorBuffer); |
| 646 m_context->renderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m_sam pleCount, m_internalRenderbufferFormat, size.width(), size.height()); | 649 m_context->renderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m_sam pleCount, m_internalRenderbufferFormat, size.width(), size.height()); |
| 647 | 650 |
| 648 if (m_context->getError() == GL_OUT_OF_MEMORY) | 651 if (m_context->getError() == GL_OUT_OF_MEMORY) |
| 649 return false; | 652 return false; |
| 650 | 653 |
| 651 m_context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_multisampleColorBuffer); | 654 m_context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_multisampleColorBuffer); |
| 652 resizeDepthStencil(size); | 655 if (!resizeDepthStencil(size)) |
| 656 return false; | |
| 653 if (m_context->checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_ COMPLETE) | 657 if (m_context->checkFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_ COMPLETE) |
| 654 return false; | 658 return false; |
| 655 } | 659 } |
| 656 | 660 |
| 657 return true; | 661 return true; |
| 658 } | 662 } |
| 659 | 663 |
| 660 void DrawingBuffer::resizeDepthStencil(const IntSize& size) | 664 bool DrawingBuffer::resizeDepthStencil(const IntSize& size) |
| 661 { | 665 { |
| 662 if (!m_requestedAttributes.depth && !m_requestedAttributes.stencil) | 666 if (!m_requestedAttributes.depth && !m_requestedAttributes.stencil) |
| 663 return; | 667 return true; |
| 664 | 668 |
| 665 if (m_packedDepthStencilExtensionSupported) { | 669 if (m_packedDepthStencilExtensionSupported) { |
| 666 if (!m_depthStencilBuffer) | 670 if (!m_depthStencilBuffer) |
| 667 m_depthStencilBuffer = m_context->createRenderbuffer(); | 671 m_depthStencilBuffer = m_context->createRenderbuffer(); |
| 668 m_context->bindRenderbuffer(GL_RENDERBUFFER, m_depthStencilBuffer); | 672 m_context->bindRenderbuffer(GL_RENDERBUFFER, m_depthStencilBuffer); |
| 669 if (m_multisampleMode == ImplicitResolve) | 673 if (m_multisampleMode == ImplicitResolve) |
| 670 m_context->renderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_samp leCount, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); | 674 m_context->renderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_samp leCount, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); |
| 671 else if (m_multisampleMode == ExplicitResolve) | 675 else if (m_multisampleMode == ExplicitResolve) |
| 672 m_context->renderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m _sampleCount, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); | 676 m_context->renderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m _sampleCount, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); |
| 673 else | 677 else |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 694 if (m_multisampleMode == ImplicitResolve) | 698 if (m_multisampleMode == ImplicitResolve) |
| 695 m_context->renderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_ sampleCount, GL_STENCIL_INDEX8, size.width(), size.height()); | 699 m_context->renderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_ sampleCount, GL_STENCIL_INDEX8, size.width(), size.height()); |
| 696 else if (m_multisampleMode == ExplicitResolve) | 700 else if (m_multisampleMode == ExplicitResolve) |
| 697 m_context->renderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFE R, m_sampleCount, GL_STENCIL_INDEX8, size.width(), size.height()); | 701 m_context->renderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFE R, m_sampleCount, GL_STENCIL_INDEX8, size.width(), size.height()); |
| 698 else | 702 else |
| 699 m_context->renderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX 8, size.width(), size.height()); | 703 m_context->renderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX 8, size.width(), size.height()); |
| 700 m_context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACH MENT, GL_RENDERBUFFER, m_stencilBuffer); | 704 m_context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACH MENT, GL_RENDERBUFFER, m_stencilBuffer); |
| 701 } | 705 } |
| 702 } | 706 } |
| 703 m_context->bindRenderbuffer(GL_RENDERBUFFER, 0); | 707 m_context->bindRenderbuffer(GL_RENDERBUFFER, 0); |
| 708 | |
| 709 if (m_context->getError() == GL_OUT_OF_MEMORY) | |
| 710 return false; | |
|
Ken Russell (switch to Gerrit)
2015/03/31 02:13:33
There's a preexisting bug with all of the getError
| |
| 711 | |
| 712 return true; | |
| 704 } | 713 } |
| 705 | 714 |
| 706 | 715 |
| 707 | 716 |
| 708 void DrawingBuffer::clearFramebuffers(GLbitfield clearMask) | 717 void DrawingBuffer::clearFramebuffers(GLbitfield clearMask) |
| 709 { | 718 { |
| 710 // We will clear the multisample FBO, but we also need to clear the non-mult isampled buffer. | 719 // We will clear the multisample FBO, but we also need to clear the non-mult isampled buffer. |
| 711 if (m_multisampleFBO) { | 720 if (m_multisampleFBO) { |
| 712 m_context->bindFramebuffer(GL_FRAMEBUFFER, m_fbo); | 721 m_context->bindFramebuffer(GL_FRAMEBUFFER, m_fbo); |
| 713 m_context->clear(GL_COLOR_BUFFER_BIT); | 722 m_context->clear(GL_COLOR_BUFFER_BIT); |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 956 memcpy(rowA, scanline, rowBytes); | 965 memcpy(rowA, scanline, rowBytes); |
| 957 } | 966 } |
| 958 } | 967 } |
| 959 | 968 |
| 960 void DrawingBuffer::texImage2DResourceSafe(GLenum target, GLint level, GLenum in ternalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLint unpackAlignment) | 969 void DrawingBuffer::texImage2DResourceSafe(GLenum target, GLint level, GLenum in ternalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLint unpackAlignment) |
| 961 { | 970 { |
| 962 ASSERT(unpackAlignment == 1 || unpackAlignment == 2 || unpackAlignment == 4 || unpackAlignment == 8); | 971 ASSERT(unpackAlignment == 1 || unpackAlignment == 2 || unpackAlignment == 4 || unpackAlignment == 8); |
| 963 m_context->texImage2D(target, level, internalformat, width, height, border, format, type, 0); | 972 m_context->texImage2D(target, level, internalformat, width, height, border, format, type, 0); |
| 964 } | 973 } |
| 965 | 974 |
| 966 void DrawingBuffer::allocateTextureMemory(TextureInfo* info, const IntSize& size ) | 975 bool DrawingBuffer::allocateTextureMemory(TextureInfo* info, const IntSize& size ) |
| 967 { | 976 { |
| 968 if (RuntimeEnabledFeatures::webGLImageChromiumEnabled()) { | 977 if (RuntimeEnabledFeatures::webGLImageChromiumEnabled()) { |
| 969 deleteChromiumImageForTexture(info); | 978 deleteChromiumImageForTexture(info); |
| 970 | 979 |
| 971 info->imageId = m_context->createGpuMemoryBufferImageCHROMIUM(size.width (), size.height(), GL_RGBA, GC3D_SCANOUT_CHROMIUM); | 980 info->imageId = m_context->createGpuMemoryBufferImageCHROMIUM(size.width (), size.height(), GL_RGBA, GC3D_SCANOUT_CHROMIUM); |
| 981 | |
| 982 if (m_context->getError() == GL_OUT_OF_MEMORY) | |
| 983 return false; | |
| 984 | |
| 972 if (info->imageId) { | 985 if (info->imageId) { |
| 973 m_context->bindTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId); | 986 m_context->bindTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId); |
| 974 return; | 987 return true; |
| 975 } | 988 } |
| 976 } | 989 } |
| 977 | 990 |
| 978 texImage2DResourceSafe(GL_TEXTURE_2D, 0, m_internalColorFormat, size.width() , size.height(), 0, m_colorFormat, GL_UNSIGNED_BYTE); | 991 texImage2DResourceSafe(GL_TEXTURE_2D, 0, m_internalColorFormat, size.width() , size.height(), 0, m_colorFormat, GL_UNSIGNED_BYTE); |
| 992 | |
| 993 if (m_context->getError() == GL_OUT_OF_MEMORY) | |
| 994 return false; | |
| 995 | |
| 996 return true; | |
| 979 } | 997 } |
| 980 | 998 |
| 981 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) | 999 void DrawingBuffer::deleteChromiumImageForTexture(TextureInfo* info) |
| 982 { | 1000 { |
| 983 if (info->imageId) { | 1001 if (info->imageId) { |
| 984 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId); | 1002 m_context->releaseTexImage2DCHROMIUM(GL_TEXTURE_2D, info->imageId); |
| 985 m_context->destroyImageCHROMIUM(info->imageId); | 1003 m_context->destroyImageCHROMIUM(info->imageId); |
| 986 info->imageId = 0; | 1004 info->imageId = 0; |
| 987 } | 1005 } |
| 988 } | 1006 } |
| 989 | 1007 |
| 990 } // namespace blink | 1008 } // namespace blink |
| OLD | NEW |