Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1189 // FIXME: Some of these ES3 buffer targets may require additional state tracking. | 1189 // FIXME: Some of these ES3 buffer targets may require additional state tracking. |
| 1190 break; | 1190 break; |
| 1191 default: | 1191 default: |
| 1192 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid target"); | 1192 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid target"); |
| 1193 return false; | 1193 return false; |
| 1194 } | 1194 } |
| 1195 | 1195 |
| 1196 return true; | 1196 return true; |
| 1197 } | 1197 } |
| 1198 | 1198 |
| 1199 bool WebGL2RenderingContextBase::validateGetFramebufferAttachmentParameters(cons t char* functionName, GLenum target, GLenum attachment) | |
|
Zhenyao Mo
2015/03/06 18:35:37
I think you should fold this function into getFram
yunchao
2015/03/09 07:16:57
Agree. Considering that this validation is standal
| |
| 1200 { | |
| 1201 if (target != GL_FRAMEBUFFER && target != GL_READ_FRAMEBUFFER) { | |
|
Zhenyao Mo
2015/03/06 18:35:37
Add a comment GL_DRAW_FRAMEBUFFER == GL_FRAMEBUFFE
yunchao
2015/03/09 07:16:57
A little tricky here. GL_DRAW_FRAMEBUFFER is not e
yunchao
2015/03/09 10:00:34
GLenum GL_DRAW_FRAMEBUFFER(0x8CA9) is not equal to
| |
| 1202 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid target"); | |
| 1203 return false; | |
| 1204 } | |
| 1205 ASSERT(!m_framebufferBinding && !drawingBuffer()); | |
|
Zhenyao Mo
2015/03/06 18:35:37
This ASSERTION is incorrect. It should be ||, not
yunchao
2015/03/09 07:16:57
If binding to default FB, m_framebufferBinding wil
| |
| 1206 if (!m_framebufferBinding) { | |
|
Zhenyao Mo
2015/03/06 18:35:37
You also need to check || !m_framebufferBinding->
yunchao
2015/03/09 07:16:57
Personally, I think it is not necessary to check m
| |
| 1207 // for the default framebuffer | |
| 1208 switch (attachment) { | |
| 1209 case GL_BACK: | |
| 1210 case GL_DEPTH: | |
| 1211 case GL_STENCIL: | |
| 1212 break; | |
| 1213 default: | |
| 1214 synthesizeGLError(GL_INVALID_OPERATION, functionName, "invalid attac hment"); | |
| 1215 return false; | |
| 1216 } | |
| 1217 } else { | |
| 1218 // for the FBO | |
| 1219 switch (attachment) { | |
| 1220 case GL_COLOR_ATTACHMENT0: | |
| 1221 case GL_DEPTH_ATTACHMENT: | |
| 1222 case GL_STENCIL_ATTACHMENT: | |
| 1223 break; | |
| 1224 case GL_DEPTH_STENCIL_ATTACHMENT: | |
| 1225 if (m_framebufferBinding->getAttachmentObject(GL_DEPTH_STENCIL_ATTAC HMENT) || (m_framebufferBinding->getAttachmentObject(GL_DEPTH_ATTACHMENT) == m_f ramebufferBinding->getAttachmentObject(GL_STENCIL_ATTACHMENT))) | |
| 1226 break; | |
| 1227 default: | |
| 1228 if (attachment > GL_COLOR_ATTACHMENT0 | |
| 1229 && attachment < static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + maxCo lorAttachments())) | |
| 1230 break; | |
| 1231 synthesizeGLError(GL_INVALID_OPERATION, functionName, "invalid attac hment"); | |
| 1232 return false; | |
| 1233 } | |
| 1234 } | |
| 1235 return true; | |
| 1236 } | |
| 1237 | |
| 1238 ScriptValue WebGL2RenderingContextBase::getFramebufferAttachmentParameter(Script State* scriptState, GLenum target, GLenum attachment, GLenum pname) | |
| 1239 { | |
| 1240 if (isContextLost() || !validateGetFramebufferAttachmentParameters("getFrame bufferAttachmentParameter", target, attachment)) | |
| 1241 return ScriptValue::createNull(scriptState); | |
| 1242 | |
| 1243 if (m_framebufferBinding && !m_framebufferBinding->object()) { | |
|
Zhenyao Mo
2015/03/06 18:35:37
This is incorrect, in ES3 we allow querying the ba
yunchao
2015/03/09 07:16:57
Agree, but this is different from the original cod
| |
| 1244 synthesizeGLError(GL_INVALID_OPERATION, "getFramebufferAttachmentParamet er", "no framebuffer bound"); | |
| 1245 return ScriptValue::createNull(scriptState); | |
| 1246 } | |
| 1247 | |
| 1248 WebGLSharedObject* object = m_framebufferBinding ? m_framebufferBinding->get AttachmentObject(attachment) : 0; | |
| 1249 if (m_framebufferBinding && !object) { | |
| 1250 if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE) | |
| 1251 return WebGLAny(scriptState, GL_NONE); | |
| 1252 if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME) | |
| 1253 return WebGLAny(scriptState, 0); | |
| 1254 synthesizeGLError(GL_INVALID_OPERATION, "getFramebufferAttachmentParamet er", "invalid parameter name"); | |
| 1255 return ScriptValue::createNull(scriptState); | |
| 1256 } | |
| 1257 | |
| 1258 switch (pname) { | |
| 1259 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: | |
| 1260 if (!object) | |
| 1261 return WebGLAny(scriptState, GL_FRAMEBUFFER_DEFAULT); | |
| 1262 if (object->isTexture()) | |
| 1263 return WebGLAny(scriptState, GL_TEXTURE); | |
| 1264 if (object->isRenderbuffer()) | |
| 1265 return WebGLAny(scriptState, GL_RENDERBUFFER); | |
| 1266 break; | |
| 1267 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: | |
| 1268 if (!object) | |
| 1269 break; | |
| 1270 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(object) ); | |
| 1271 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: | |
| 1272 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER: | |
| 1273 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: | |
| 1274 if (!object || !object->isTexture()) | |
| 1275 break; | |
| 1276 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE: | |
| 1277 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE: | |
| 1278 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE: | |
| 1279 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE: | |
| 1280 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE: | |
| 1281 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE: | |
| 1282 { | |
| 1283 GLint value = 0; | |
| 1284 webContext()->getFramebufferAttachmentParameteriv(target, attachment , pname, &value); | |
| 1285 return WebGLAny(scriptState, value); | |
| 1286 } | |
| 1287 case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE: | |
| 1288 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: | |
| 1289 { | |
| 1290 GLint value = 0; | |
| 1291 webContext()->getFramebufferAttachmentParameteriv(target, attachment , pname, &value); | |
| 1292 return WebGLAny(scriptState, static_cast<unsigned>(value)); | |
| 1293 } | |
| 1294 default: | |
| 1295 break; | |
| 1296 } | |
| 1297 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParameter", "inv alid parameter name"); | |
| 1298 return ScriptValue::createNull(scriptState); | |
| 1299 } | |
| 1300 | |
| 1199 DEFINE_TRACE(WebGL2RenderingContextBase) | 1301 DEFINE_TRACE(WebGL2RenderingContextBase) |
| 1200 { | 1302 { |
| 1201 WebGLRenderingContextBase::trace(visitor); | 1303 WebGLRenderingContextBase::trace(visitor); |
| 1202 } | 1304 } |
| 1203 | 1305 |
| 1204 } // namespace blink | 1306 } // namespace blink |
| OLD | NEW |