Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| 11 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
| 12 * documentation and/or other materials provided with the distribution. | 12 * documentation and/or other materials provided with the distribution. |
| 13 * | 13 * |
| 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY | 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
| 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY | 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
| 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "modules/webgl/WebGLDrawBuffers.h" | 26 #include "modules/webgl/WebGLDrawBuffers.h" |
| 27 | 27 |
| 28 #include "gpu/command_buffer/client/gles2_interface.h" | 28 #include "gpu/command_buffer/client/gles2_interface.h" |
| 29 #include "modules/webgl/WebGLFramebuffer.h" | 29 #include "modules/webgl/WebGLFramebuffer.h" |
| 30 #include "wtf/Assertions.h" | |
|
Zhenyao Mo
2016/04/14 20:15:15
why do you need this?
| |
| 30 | 31 |
| 31 namespace blink { | 32 namespace blink { |
| 32 | 33 |
| 33 WebGLDrawBuffers::WebGLDrawBuffers(WebGLRenderingContextBase* context) | 34 WebGLDrawBuffers::WebGLDrawBuffers(WebGLRenderingContextBase* context) |
| 34 : WebGLExtension(context) | 35 : WebGLExtension(context) |
| 35 { | 36 { |
| 36 context->extensionsUtil()->ensureExtensionEnabled("GL_EXT_draw_buffers"); | 37 context->extensionsUtil()->ensureExtensionEnabled("GL_EXT_draw_buffers"); |
| 37 } | 38 } |
| 38 | 39 |
| 39 WebGLDrawBuffers::~WebGLDrawBuffers() | 40 WebGLDrawBuffers::~WebGLDrawBuffers() |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 gl->GenTextures(1, &depth); | 134 gl->GenTextures(1, &depth); |
| 134 gl->BindTexture(GL_TEXTURE_2D, depth); | 135 gl->BindTexture(GL_TEXTURE_2D, depth); |
| 135 gl->TexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 1, 1, 0, GL_DEPTH_C OMPONENT, GL_UNSIGNED_INT, buffer); | 136 gl->TexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 1, 1, 0, GL_DEPTH_C OMPONENT, GL_UNSIGNED_INT, buffer); |
| 136 } | 137 } |
| 137 | 138 |
| 138 Vector<Platform3DObject> colors; | 139 Vector<Platform3DObject> colors; |
| 139 bool ok = true; | 140 bool ok = true; |
| 140 GLint maxAllowedBuffers = std::min(maxDrawBuffers, maxColorAttachments); | 141 GLint maxAllowedBuffers = std::min(maxDrawBuffers, maxColorAttachments); |
| 141 for (GLint i = 0; i < maxAllowedBuffers; ++i) { | 142 for (GLint i = 0; i < maxAllowedBuffers; ++i) { |
| 142 GLuint color; | 143 GLuint color; |
| 144 | |
|
Ken Russell (switch to Gerrit)
2016/04/14 20:33:08
If you can undo this whitespace change and the one
| |
| 143 gl->GenTextures(1, &color); | 145 gl->GenTextures(1, &color); |
| 144 colors.append(color); | 146 colors.append(color); |
| 145 gl->BindTexture(GL_TEXTURE_2D, color); | 147 gl->BindTexture(GL_TEXTURE_2D, color); |
| 146 gl->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_ BYTE, buffer); | 148 gl->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_ BYTE, buffer); |
| 147 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TE XTURE_2D, color, 0); | 149 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TE XTURE_2D, color, 0); |
| 148 if (gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLET E) { | 150 if (gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLET E) { |
| 149 ok = false; | 151 ok = false; |
| 150 break; | 152 break; |
| 151 } | 153 } |
| 152 if (supportsDepth) { | 154 if (supportsDepth) { |
| 153 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEX TURE_2D, depth, 0); | 155 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEX TURE_2D, depth, 0); |
| 154 if (gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COM PLETE) { | 156 if (gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COM PLETE) { |
| 155 ok = false; | 157 ok = false; |
| 156 break; | 158 break; |
| 157 } | 159 } |
| 158 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEX TURE_2D, 0, 0); | 160 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEX TURE_2D, 0, 0); |
| 159 } | 161 } |
| 160 if (supportsDepthStencil) { | 162 if (supportsDepthStencil) { |
| 161 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEX TURE_2D, depthStencil, 0); | 163 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT , GL_TEXTURE_2D, depthStencil, 0); |
|
Ken Russell (switch to Gerrit)
2016/04/14 20:33:08
Could you please add a comment that the DEPTH_STEN
| |
| 162 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_T EXTURE_2D, depthStencil, 0); | |
| 163 if (gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COM PLETE) { | 164 if (gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COM PLETE) { |
| 164 ok = false; | 165 ok = false; |
| 165 break; | 166 break; |
| 166 } | 167 } |
| 167 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEX TURE_2D, 0, 0); | 168 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT , GL_TEXTURE_2D, 0, 0); |
| 168 gl->FramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_T EXTURE_2D, 0, 0); | |
| 169 } | 169 } |
| 170 } | 170 } |
| 171 | 171 |
| 172 webglContext->restoreCurrentFramebuffer(); | 172 webglContext->restoreCurrentFramebuffer(); |
| 173 gl->DeleteFramebuffers(1, &fbo); | 173 gl->DeleteFramebuffers(1, &fbo); |
| 174 webglContext->restoreCurrentTexture2D(); | 174 webglContext->restoreCurrentTexture2D(); |
| 175 if (supportsDepth) | 175 if (supportsDepth) |
| 176 gl->DeleteTextures(1, &depth); | 176 gl->DeleteTextures(1, &depth); |
| 177 if (supportsDepthStencil) | 177 if (supportsDepthStencil) |
| 178 gl->DeleteTextures(1, &depthStencil); | 178 gl->DeleteTextures(1, &depthStencil); |
| 179 gl->DeleteTextures(colors.size(), colors.data()); | 179 gl->DeleteTextures(colors.size(), colors.data()); |
| 180 | |
| 180 return ok; | 181 return ok; |
| 181 } | 182 } |
| 182 | 183 |
| 183 } // namespace blink | 184 } // namespace blink |
| OLD | NEW |