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

Side by Side Diff: Source/core/html/canvas/WebGL2RenderingContextBase.cpp

Issue 1205573003: WebGL 2: validate read buffer attachment when reading from FBO (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/html/canvas/WebGL2RenderingContextBase.h" 6 #include "core/html/canvas/WebGL2RenderingContextBase.h"
7 7
8 #include "bindings/core/v8/WebGLAny.h" 8 #include "bindings/core/v8/WebGLAny.h"
9 #include "core/html/HTMLCanvasElement.h" 9 #include "core/html/HTMLCanvasElement.h"
10 #include "core/html/HTMLImageElement.h" 10 #include "core/html/HTMLImageElement.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 return; 161 return;
162 162
163 webContext()->invalidateSubFramebuffer(target, attachments.size(), attachmen ts.data(), x, y, width, height); 163 webContext()->invalidateSubFramebuffer(target, attachments.size(), attachmen ts.data(), x, y, width, height);
164 } 164 }
165 165
166 void WebGL2RenderingContextBase::readBuffer(GLenum mode) 166 void WebGL2RenderingContextBase::readBuffer(GLenum mode)
167 { 167 {
168 if (isContextLost()) 168 if (isContextLost())
169 return; 169 return;
170 170
171 switch (mode) {
172 case GL_BACK:
173 case GL_NONE:
174 case GL_COLOR_ATTACHMENT0:
175 break;
176 default:
177 if (attachment > GL_COLOR_ATTACHMENT0
178 && attachment < static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + maxColorA ttachments()))
179 break;
180 synthesizeGLError(GL_INVALID_ENUM, "readBuffer", "invalid read buffer");
181 return;
182 }
183
184 WebGLFramebuffer* readFramebufferBinding = getFramebufferBinding(GL_READ_FRA MEBUFFER);
185 if (!readFramebufferBinding) {
186 ASSERT(drawingBuffer());
187 if (mode != GL_BACK || mode != GL_NONE) {
188 synthesizeGLError(GL_INVALID_OPERATION, "readBuffer", "invalid read buffer");
189 return;
190 }
191 } else {
192 if (mode == GL_BACK) {
193 synthesizeGLError(GL_INVALID_OPERATION, "readBuffer", "invalid read buffer");
194 return;
195 }
196 m_readbufferOfFBO = mode;
197 }
171 webContext()->readBuffer(mode); 198 webContext()->readBuffer(mode);
172 } 199 }
173 200
174 void WebGL2RenderingContextBase::renderbufferStorageImpl( 201 void WebGL2RenderingContextBase::renderbufferStorageImpl(
175 GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsize i height, 202 GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsize i height,
176 const char* functionName) 203 const char* functionName)
177 { 204 {
178 switch (internalformat) { 205 switch (internalformat) {
179 case GL_R8UI: 206 case GL_R8UI:
180 case GL_R8I: 207 case GL_R8I:
(...skipping 1904 matching lines...) Expand 10 before | Expand all | Expand 10 after
2085 m_boundPixelUnpackBuffer = nullptr; 2112 m_boundPixelUnpackBuffer = nullptr;
2086 if (m_boundTransformFeedbackBuffer == buffer) 2113 if (m_boundTransformFeedbackBuffer == buffer)
2087 m_boundTransformFeedbackBuffer = nullptr; 2114 m_boundTransformFeedbackBuffer = nullptr;
2088 if (m_boundUniformBuffer == buffer) 2115 if (m_boundUniformBuffer == buffer)
2089 m_boundUniformBuffer = nullptr; 2116 m_boundUniformBuffer = nullptr;
2090 2117
2091 WebGLRenderingContextBase::removeBoundBuffer(buffer); 2118 WebGLRenderingContextBase::removeBoundBuffer(buffer);
2092 } 2119 }
2093 2120
2094 } // namespace blink 2121 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698