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

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

Issue 981913002: update getFramebufferAttachmentParameter for WebGL 2 (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: addressed zmo@'s feedback Created 5 years, 9 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) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple 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 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 2244 matching lines...) Expand 10 before | Expand all | Expand 10 after
2255 ScriptValue WebGLRenderingContextBase::getFramebufferAttachmentParameter(ScriptS tate* scriptState, GLenum target, GLenum attachment, GLenum pname) 2255 ScriptValue WebGLRenderingContextBase::getFramebufferAttachmentParameter(ScriptS tate* scriptState, GLenum target, GLenum attachment, GLenum pname)
2256 { 2256 {
2257 if (isContextLost() || !validateFramebufferFuncParameters("getFramebufferAtt achmentParameter", target, attachment)) 2257 if (isContextLost() || !validateFramebufferFuncParameters("getFramebufferAtt achmentParameter", target, attachment))
2258 return ScriptValue::createNull(scriptState); 2258 return ScriptValue::createNull(scriptState);
2259 2259
2260 if (!m_framebufferBinding || !m_framebufferBinding->object()) { 2260 if (!m_framebufferBinding || !m_framebufferBinding->object()) {
2261 synthesizeGLError(GL_INVALID_OPERATION, "getFramebufferAttachmentParamet er", "no framebuffer bound"); 2261 synthesizeGLError(GL_INVALID_OPERATION, "getFramebufferAttachmentParamet er", "no framebuffer bound");
2262 return ScriptValue::createNull(scriptState); 2262 return ScriptValue::createNull(scriptState);
2263 } 2263 }
2264 2264
2265 WebGLSharedObject* object = m_framebufferBinding->getAttachmentObject(attach ment); 2265 WebGLSharedObject* attachmentObject = m_framebufferBinding->getAttachmentObj ect(attachment);
yunchao 2015/03/09 07:20:27 To make it clearer, rename 'object' to 'attachment
2266 if (!object) { 2266 if (!attachmentObject) {
2267 if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE) 2267 if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE)
2268 return WebGLAny(scriptState, GL_NONE); 2268 return WebGLAny(scriptState, GL_NONE);
2269 // OpenGL ES 2.0 specifies INVALID_ENUM in this case, while desktop GL 2269 // OpenGL ES 2.0 specifies INVALID_ENUM in this case, while desktop GL
2270 // specifies INVALID_OPERATION. 2270 // specifies INVALID_OPERATION.
2271 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParameter", "invalid parameter name"); 2271 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParameter", "invalid parameter name");
2272 return ScriptValue::createNull(scriptState); 2272 return ScriptValue::createNull(scriptState);
2273 } 2273 }
2274 2274
2275 ASSERT(object->isTexture() || object->isRenderbuffer()); 2275 ASSERT(attachmentObject->isTexture() || attachmentObject->isRenderbuffer());
2276 if (object->isTexture()) { 2276 if (attachmentObject->isTexture()) {
2277 switch (pname) { 2277 switch (pname) {
2278 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: 2278 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2279 return WebGLAny(scriptState, GL_TEXTURE); 2279 return WebGLAny(scriptState, GL_TEXTURE);
2280 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: 2280 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2281 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(obj ect)); 2281 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(att achmentObject));
2282 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: 2282 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
2283 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: 2283 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
2284 { 2284 {
2285 GLint value = 0; 2285 GLint value = 0;
2286 webContext()->getFramebufferAttachmentParameteriv(target, attach ment, pname, &value); 2286 webContext()->getFramebufferAttachmentParameteriv(target, attach ment, pname, &value);
2287 return WebGLAny(scriptState, value); 2287 return WebGLAny(scriptState, value);
2288 } 2288 }
2289 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT: 2289 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT:
2290 if (extensionEnabled(EXTsRGBName) || isWebGL2OrHigher()) { 2290 if (extensionEnabled(EXTsRGBName)) {
2291 GLint value = 0; 2291 GLint value = 0;
2292 webContext()->getFramebufferAttachmentParameteriv(target, attach ment, pname, &value); 2292 webContext()->getFramebufferAttachmentParameteriv(target, attach ment, pname, &value);
2293 return WebGLAny(scriptState, value); 2293 return WebGLAny(scriptState, static_cast<unsigned>(value));
2294 } 2294 }
2295 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for renderbuffer attachment"); 2295 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for renderbuffer attachment");
2296 return ScriptValue::createNull(scriptState); 2296 return ScriptValue::createNull(scriptState);
2297 default: 2297 default:
2298 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for texture attachment"); 2298 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for texture attachment");
2299 return ScriptValue::createNull(scriptState); 2299 return ScriptValue::createNull(scriptState);
2300 } 2300 }
2301 } else { 2301 } else {
2302 switch (pname) { 2302 switch (pname) {
2303 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: 2303 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2304 return WebGLAny(scriptState, GL_RENDERBUFFER); 2304 return WebGLAny(scriptState, GL_RENDERBUFFER);
2305 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: 2305 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2306 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(obj ect)); 2306 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(att achmentObject));
2307 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT: 2307 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT:
2308 if (extensionEnabled(EXTsRGBName) || isWebGL2OrHigher()) { 2308 if (extensionEnabled(EXTsRGBName) || isWebGL2OrHigher()) {
2309 GLint value = 0; 2309 GLint value = 0;
2310 webContext()->getFramebufferAttachmentParameteriv(target, attach ment, pname, &value); 2310 webContext()->getFramebufferAttachmentParameteriv(target, attach ment, pname, &value);
2311 return WebGLAny(scriptState, value); 2311 return WebGLAny(scriptState, value);
2312 } 2312 }
2313 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for renderbuffer attachment"); 2313 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for renderbuffer attachment");
2314 return ScriptValue::createNull(scriptState); 2314 return ScriptValue::createNull(scriptState);
2315 default: 2315 default:
2316 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for renderbuffer attachment"); 2316 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for renderbuffer attachment");
(...skipping 3698 matching lines...) Expand 10 before | Expand all | Expand 10 after
6015 return m_sharedWebGraphicsContext3D ? m_sharedWebGraphicsContext3D->drawingB uffer() : 0; 6015 return m_sharedWebGraphicsContext3D ? m_sharedWebGraphicsContext3D->drawingB uffer() : 0;
6016 } 6016 }
6017 #else 6017 #else
6018 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const 6018 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const
6019 { 6019 {
6020 return m_drawingBuffer.get(); 6020 return m_drawingBuffer.get();
6021 } 6021 }
6022 #endif 6022 #endif
6023 6023
6024 } // namespace blink 6024 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698