Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(404)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/gpu/DrawingBuffer.cpp

Issue 1698303002: Revert 1675973002 and 1683213002. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 return nullptr; 97 return nullptr;
98 } 98 }
99 99
100 OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(context.g et()); 100 OwnPtr<Extensions3DUtil> extensionsUtil = Extensions3DUtil::create(context.g et());
101 if (!extensionsUtil->isValid()) { 101 if (!extensionsUtil->isValid()) {
102 // This might be the first time we notice that the WebGraphicsContext3D is lost. 102 // This might be the first time we notice that the WebGraphicsContext3D is lost.
103 return nullptr; 103 return nullptr;
104 } 104 }
105 ASSERT(extensionsUtil->supportsExtension("GL_OES_packed_depth_stencil")); 105 ASSERT(extensionsUtil->supportsExtension("GL_OES_packed_depth_stencil"));
106 extensionsUtil->ensureExtensionEnabled("GL_OES_packed_depth_stencil"); 106 extensionsUtil->ensureExtensionEnabled("GL_OES_packed_depth_stencil");
107 107 bool multisampleSupported = (extensionsUtil->supportsExtension("GL_CHROMIUM_ framebuffer_multisample")
108 SupportedExtensions exts;
109 exts.multisample = (extensionsUtil->supportsExtension("GL_CHROMIUM_framebuff er_multisample")
110 || extensionsUtil->supportsExtension("GL_EXT_multisampled_render_to_text ure")) 108 || extensionsUtil->supportsExtension("GL_EXT_multisampled_render_to_text ure"))
111 && extensionsUtil->supportsExtension("GL_OES_rgb8_rgba8"); 109 && extensionsUtil->supportsExtension("GL_OES_rgb8_rgba8");
112 if (exts.multisample) { 110 if (multisampleSupported) {
113 extensionsUtil->ensureExtensionEnabled("GL_OES_rgb8_rgba8"); 111 extensionsUtil->ensureExtensionEnabled("GL_OES_rgb8_rgba8");
114 if (extensionsUtil->supportsExtension("GL_CHROMIUM_framebuffer_multisamp le")) 112 if (extensionsUtil->supportsExtension("GL_CHROMIUM_framebuffer_multisamp le"))
115 extensionsUtil->ensureExtensionEnabled("GL_CHROMIUM_framebuffer_mult isample"); 113 extensionsUtil->ensureExtensionEnabled("GL_CHROMIUM_framebuffer_mult isample");
116 else 114 else
117 extensionsUtil->ensureExtensionEnabled("GL_EXT_multisampled_render_t o_texture"); 115 extensionsUtil->ensureExtensionEnabled("GL_EXT_multisampled_render_t o_texture");
118 } 116 }
119 exts.depth24 = extensionsUtil->supportsExtension("GL_OES_depth24"); 117 bool discardFramebufferSupported = extensionsUtil->supportsExtension("GL_EXT _discard_framebuffer");
120 if (exts.depth24) 118 if (discardFramebufferSupported)
121 extensionsUtil->ensureExtensionEnabled("GL_OES_depth24");
122 exts.discardFramebuffer = extensionsUtil->supportsExtension("GL_EXT_discard_ framebuffer");
123 if (exts.discardFramebuffer)
124 extensionsUtil->ensureExtensionEnabled("GL_EXT_discard_framebuffer"); 119 extensionsUtil->ensureExtensionEnabled("GL_EXT_discard_framebuffer");
125 120
126 RefPtr<DrawingBuffer> drawingBuffer = adoptRef(new DrawingBuffer(std::move(c ontext), extensionsUtil.release(), exts, preserve, requestedAttributes)); 121 RefPtr<DrawingBuffer> drawingBuffer = adoptRef(new DrawingBuffer(std::move(c ontext), extensionsUtil.release(), multisampleSupported, true, discardFramebuffe rSupported, preserve, requestedAttributes));
127 if (!drawingBuffer->initialize(size)) { 122 if (!drawingBuffer->initialize(size)) {
128 drawingBuffer->beginDestruction(); 123 drawingBuffer->beginDestruction();
129 return PassRefPtr<DrawingBuffer>(); 124 return PassRefPtr<DrawingBuffer>();
130 } 125 }
131 return drawingBuffer.release(); 126 return drawingBuffer.release();
132 } 127 }
133 128
134 void DrawingBuffer::forceNextDrawingBufferCreationToFail() 129 void DrawingBuffer::forceNextDrawingBufferCreationToFail()
135 { 130 {
136 shouldFailDrawingBufferCreationForTesting = true; 131 shouldFailDrawingBufferCreationForTesting = true;
137 } 132 }
138 133
139 DrawingBuffer::SupportedExtensions::SupportedExtensions() :
140 multisample(false), depth24(false), discardFramebuffer(false) {}
141
142 DrawingBuffer::DrawingBuffer(PassOwnPtr<WebGraphicsContext3D> context, 134 DrawingBuffer::DrawingBuffer(PassOwnPtr<WebGraphicsContext3D> context,
143 PassOwnPtr<Extensions3DUtil> extensionsUtil, 135 PassOwnPtr<Extensions3DUtil> extensionsUtil,
144 const SupportedExtensions& supportedExtensions, 136 bool multisampleExtensionSupported,
137 bool packedDepthStencilExtensionSupported,
138 bool discardFramebufferSupported,
145 PreserveDrawingBuffer preserve, 139 PreserveDrawingBuffer preserve,
146 WebGraphicsContext3D::Attributes requestedAttributes) 140 WebGraphicsContext3D::Attributes requestedAttributes)
147 : m_preserveDrawingBuffer(preserve) 141 : m_preserveDrawingBuffer(preserve)
148 , m_scissorEnabled(false) 142 , m_scissorEnabled(false)
149 , m_texture2DBinding(0) 143 , m_texture2DBinding(0)
150 , m_drawFramebufferBinding(0) 144 , m_drawFramebufferBinding(0)
151 , m_readFramebufferBinding(0) 145 , m_readFramebufferBinding(0)
152 , m_activeTextureUnit(GL_TEXTURE0) 146 , m_activeTextureUnit(GL_TEXTURE0)
153 , m_context(std::move(context)) 147 , m_context(std::move(context))
154 , m_extensionsUtil(std::move(extensionsUtil)) 148 , m_extensionsUtil(std::move(extensionsUtil))
155 , m_size(-1, -1) 149 , m_size(-1, -1)
156 , m_requestedAttributes(requestedAttributes) 150 , m_requestedAttributes(requestedAttributes)
157 , m_multisampleExtensionSupported(supportedExtensions.multisample) 151 , m_multisampleExtensionSupported(multisampleExtensionSupported)
158 , m_depth24ExtensionSupported(supportedExtensions.depth24) 152 , m_packedDepthStencilExtensionSupported(packedDepthStencilExtensionSupporte d)
159 , m_discardFramebufferSupported(supportedExtensions.discardFramebuffer) 153 , m_discardFramebufferSupported(discardFramebufferSupported)
160 , m_fbo(0) 154 , m_fbo(0)
161 , m_depthStencilBuffer(0) 155 , m_depthStencilBuffer(0)
162 , m_depthBuffer(0) 156 , m_depthBuffer(0)
157 , m_stencilBuffer(0)
163 , m_multisampleFBO(0) 158 , m_multisampleFBO(0)
164 , m_multisampleColorBuffer(0) 159 , m_multisampleColorBuffer(0)
165 , m_contentsChanged(true) 160 , m_contentsChanged(true)
166 , m_contentsChangeCommitted(false) 161 , m_contentsChangeCommitted(false)
167 , m_bufferClearNeeded(false) 162 , m_bufferClearNeeded(false)
168 , m_antiAliasingMode(None) 163 , m_antiAliasingMode(None)
169 , m_maxTextureSize(0) 164 , m_maxTextureSize(0)
170 , m_sampleCount(0) 165 , m_sampleCount(0)
171 , m_packAlignment(4) 166 , m_packAlignment(4)
172 , m_destructionInProgress(false) 167 , m_destructionInProgress(false)
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 606
612 if (m_multisampleColorBuffer) 607 if (m_multisampleColorBuffer)
613 m_context->deleteRenderbuffer(m_multisampleColorBuffer); 608 m_context->deleteRenderbuffer(m_multisampleColorBuffer);
614 609
615 if (m_depthStencilBuffer) 610 if (m_depthStencilBuffer)
616 m_context->deleteRenderbuffer(m_depthStencilBuffer); 611 m_context->deleteRenderbuffer(m_depthStencilBuffer);
617 612
618 if (m_depthBuffer) 613 if (m_depthBuffer)
619 m_context->deleteRenderbuffer(m_depthBuffer); 614 m_context->deleteRenderbuffer(m_depthBuffer);
620 615
616 if (m_stencilBuffer)
617 m_context->deleteRenderbuffer(m_stencilBuffer);
618
621 if (m_colorBuffer.textureId) { 619 if (m_colorBuffer.textureId) {
622 deleteChromiumImageForTexture(&m_colorBuffer); 620 deleteChromiumImageForTexture(&m_colorBuffer);
623 m_context->deleteTexture(m_colorBuffer.textureId); 621 m_context->deleteTexture(m_colorBuffer.textureId);
624 } 622 }
625 623
626 setSize(IntSize()); 624 setSize(IntSize());
627 625
628 m_colorBuffer = TextureInfo(); 626 m_colorBuffer = TextureInfo();
629 m_frontColorBuffer = FrontBufferInfo(); 627 m_frontColorBuffer = FrontBufferInfo();
630 m_multisampleColorBuffer = 0; 628 m_multisampleColorBuffer = 0;
631 m_depthStencilBuffer = 0; 629 m_depthStencilBuffer = 0;
632 m_depthBuffer = 0; 630 m_depthBuffer = 0;
631 m_stencilBuffer = 0;
633 m_multisampleFBO = 0; 632 m_multisampleFBO = 0;
634 m_fbo = 0; 633 m_fbo = 0;
635 634
636 if (m_layer) 635 if (m_layer)
637 GraphicsLayer::unregisterContentsLayer(m_layer->layer()); 636 GraphicsLayer::unregisterContentsLayer(m_layer->layer());
638 } 637 }
639 638
640 WebGLId DrawingBuffer::createColorTexture(const TextureParameters& parameters) 639 WebGLId DrawingBuffer::createColorTexture(const TextureParameters& parameters)
641 { 640 {
642 WebGLId offscreenColorTexture = m_context->createTexture(); 641 WebGLId offscreenColorTexture = m_context->createTexture();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 } 690 }
692 691
693 return true; 692 return true;
694 } 693 }
695 694
696 void DrawingBuffer::resizeDepthStencil(const IntSize& size) 695 void DrawingBuffer::resizeDepthStencil(const IntSize& size)
697 { 696 {
698 if (!m_requestedAttributes.depth && !m_requestedAttributes.stencil) 697 if (!m_requestedAttributes.depth && !m_requestedAttributes.stencil)
699 return; 698 return;
700 699
701 if (m_requestedAttributes.depth && !m_requestedAttributes.stencil && m_depth 24ExtensionSupported) { 700 if (m_packedDepthStencilExtensionSupported) {
702 if (!m_depthBuffer)
703 m_depthBuffer = m_context->createRenderbuffer();
704 m_context->bindRenderbuffer(GL_RENDERBUFFER, m_depthBuffer);
705 if (m_antiAliasingMode == MSAAImplicitResolve)
706 m_context->renderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_samp leCount, GL_DEPTH_COMPONENT24, size.width(), size.height());
707 else if (m_antiAliasingMode == MSAAExplicitResolve)
708 m_context->renderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m _sampleCount, GL_DEPTH_COMPONENT24, size.width(), size.height());
709 else
710 m_context->renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24 , size.width(), size.height());
711 m_context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depthBuffer);
712 } else {
713 if (!m_depthStencilBuffer) 701 if (!m_depthStencilBuffer)
714 m_depthStencilBuffer = m_context->createRenderbuffer(); 702 m_depthStencilBuffer = m_context->createRenderbuffer();
715 m_context->bindRenderbuffer(GL_RENDERBUFFER, m_depthStencilBuffer); 703 m_context->bindRenderbuffer(GL_RENDERBUFFER, m_depthStencilBuffer);
716 if (m_antiAliasingMode == MSAAImplicitResolve) 704 if (m_antiAliasingMode == MSAAImplicitResolve)
717 m_context->renderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_samp leCount, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); 705 m_context->renderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_samp leCount, GL_DEPTH24_STENCIL8_OES, size.width(), size.height());
718 else if (m_antiAliasingMode == MSAAExplicitResolve) 706 else if (m_antiAliasingMode == MSAAExplicitResolve)
719 m_context->renderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m _sampleCount, GL_DEPTH24_STENCIL8_OES, size.width(), size.height()); 707 m_context->renderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFER, m _sampleCount, GL_DEPTH24_STENCIL8_OES, size.width(), size.height());
720 else 708 else
721 m_context->renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_ OES, size.width(), size.height()); 709 m_context->renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_ OES, size.width(), size.height());
722 m_context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTA CHMENT, GL_RENDERBUFFER, m_depthStencilBuffer); 710 m_context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTA CHMENT, GL_RENDERBUFFER, m_depthStencilBuffer);
711 } else {
712 if (m_requestedAttributes.depth) {
713 if (!m_depthBuffer)
714 m_depthBuffer = m_context->createRenderbuffer();
715 m_context->bindRenderbuffer(GL_RENDERBUFFER, m_depthBuffer);
716 if (m_antiAliasingMode == MSAAImplicitResolve)
717 m_context->renderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_ sampleCount, GL_DEPTH_COMPONENT16, size.width(), size.height());
718 else if (m_antiAliasingMode == MSAAExplicitResolve)
719 m_context->renderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFE R, m_sampleCount, GL_DEPTH_COMPONENT16, size.width(), size.height());
720 else
721 m_context->renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONE NT16, size.width(), size.height());
722 m_context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHME NT, GL_RENDERBUFFER, m_depthBuffer);
723 }
724 if (m_requestedAttributes.stencil) {
725 if (!m_stencilBuffer)
726 m_stencilBuffer = m_context->createRenderbuffer();
727 m_context->bindRenderbuffer(GL_RENDERBUFFER, m_stencilBuffer);
728 if (m_antiAliasingMode == MSAAImplicitResolve)
729 m_context->renderbufferStorageMultisampleEXT(GL_RENDERBUFFER, m_ sampleCount, GL_STENCIL_INDEX8, size.width(), size.height());
730 else if (m_antiAliasingMode == MSAAExplicitResolve)
731 m_context->renderbufferStorageMultisampleCHROMIUM(GL_RENDERBUFFE R, m_sampleCount, GL_STENCIL_INDEX8, size.width(), size.height());
732 else
733 m_context->renderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX 8, size.width(), size.height());
734 m_context->framebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACH MENT, GL_RENDERBUFFER, m_stencilBuffer);
735 }
723 } 736 }
724 m_context->bindRenderbuffer(GL_RENDERBUFFER, 0); 737 m_context->bindRenderbuffer(GL_RENDERBUFFER, 0);
725 } 738 }
726 739
727 740
728 741
729 void DrawingBuffer::clearFramebuffers(GLbitfield clearMask) 742 void DrawingBuffer::clearFramebuffers(GLbitfield clearMask)
730 { 743 {
731 // We will clear the multisample FBO, but we also need to clear the non-mult isampled buffer. 744 // We will clear the multisample FBO, but we also need to clear the non-mult isampled buffer.
732 if (m_multisampleFBO) { 745 if (m_multisampleFBO) {
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 1066
1054 if (m_antiAliasingMode == MSAAImplicitResolve) 1067 if (m_antiAliasingMode == MSAAImplicitResolve)
1055 m_context->framebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_A TTACHMENT0, target, m_colorBuffer.textureId, 0, m_sampleCount); 1068 m_context->framebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_A TTACHMENT0, target, m_colorBuffer.textureId, 0, m_sampleCount);
1056 else 1069 else
1057 m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, ta rget, m_colorBuffer.textureId, 0); 1070 m_context->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, ta rget, m_colorBuffer.textureId, 0);
1058 1071
1059 m_context->bindTexture(GL_TEXTURE_2D, m_texture2DBinding); 1072 m_context->bindTexture(GL_TEXTURE_2D, m_texture2DBinding);
1060 } 1073 }
1061 1074
1062 } // namespace blink 1075 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698