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::validateGetFramebufferAttachmentParameterFunc(c onst char* functionName, GLenum target, GLenum attachment) | |
| 1200 { | |
| 1201 if (target != GL_FRAMEBUFFER && target != GL_READ_FRAMEBUFFER && target != G L_DRAW_FRAMEBUFFER) { | |
| 1202 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid target"); | |
| 1203 return false; | |
| 1204 } | |
| 1205 ASSERT(m_framebufferBinding || drawingBuffer()); | |
| 1206 if (!m_framebufferBinding) { | |
| 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_ENUM, functionName, "invalid attachment "); | |
| 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_ENUM, functionName, "invalid attachment "); | |
| 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() || !validateGetFramebufferAttachmentParameterFunc("getFr amebufferAttachmentParameter", target, attachment)) | |
| 1241 return ScriptValue::createNull(scriptState); | |
| 1242 | |
| 1243 ASSERT(!m_framebufferBinding || m_framebufferBinding->object()); | |
|
Zhenyao Mo
2015/03/10 17:03:12
Now this ASSERTION is wrong. I think you can just
Zhenyao Mo
2015/03/10 17:05:58
Never mind. It is correct.
| |
| 1244 | |
| 1245 WebGLSharedObject* attachmentObject = m_framebufferBinding ? m_framebufferBi nding->getAttachmentObject(attachment) : 0; | |
| 1246 if (m_framebufferBinding && !attachmentObject) { | |
| 1247 if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE) | |
| 1248 return WebGLAny(scriptState, GL_NONE); | |
| 1249 if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME) | |
| 1250 return WebGLAny(scriptState, 0); | |
| 1251 synthesizeGLError(GL_INVALID_OPERATION, "getFramebufferAttachmentParamet er", "invalid parameter name"); | |
| 1252 return ScriptValue::createNull(scriptState); | |
| 1253 } | |
| 1254 | |
| 1255 switch (pname) { | |
| 1256 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: | |
| 1257 if (!attachmentObject) { | |
| 1258 ASSERT(!m_framebufferBinding); | |
| 1259 return WebGLAny(scriptState, GL_FRAMEBUFFER_DEFAULT); | |
| 1260 } | |
| 1261 ASSERT(attachmentObject->isTexture() || attachmentObject->isRenderbuffer ()); | |
| 1262 if (attachmentObject->isTexture()) | |
| 1263 return WebGLAny(scriptState, GL_TEXTURE); | |
| 1264 if (attachmentObject->isRenderbuffer()) | |
| 1265 return WebGLAny(scriptState, GL_RENDERBUFFER); | |
| 1266 break; | |
| 1267 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: | |
| 1268 if (!attachmentObject) | |
| 1269 break; | |
| 1270 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(attachm entObject)); | |
| 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 (!attachmentObject || !attachmentObject->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 |