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

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 kbr@'s feedback + rebased code Created 5 years, 7 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 2290 matching lines...) Expand 10 before | Expand all | Expand 10 after
2301 ScriptValue WebGLRenderingContextBase::getFramebufferAttachmentParameter(ScriptS tate* scriptState, GLenum target, GLenum attachment, GLenum pname) 2301 ScriptValue WebGLRenderingContextBase::getFramebufferAttachmentParameter(ScriptS tate* scriptState, GLenum target, GLenum attachment, GLenum pname)
2302 { 2302 {
2303 if (isContextLost() || !validateFramebufferFuncParameters("getFramebufferAtt achmentParameter", target, attachment)) 2303 if (isContextLost() || !validateFramebufferFuncParameters("getFramebufferAtt achmentParameter", target, attachment))
2304 return ScriptValue::createNull(scriptState); 2304 return ScriptValue::createNull(scriptState);
2305 2305
2306 if (!m_framebufferBinding || !m_framebufferBinding->object()) { 2306 if (!m_framebufferBinding || !m_framebufferBinding->object()) {
2307 synthesizeGLError(GL_INVALID_OPERATION, "getFramebufferAttachmentParamet er", "no framebuffer bound"); 2307 synthesizeGLError(GL_INVALID_OPERATION, "getFramebufferAttachmentParamet er", "no framebuffer bound");
2308 return ScriptValue::createNull(scriptState); 2308 return ScriptValue::createNull(scriptState);
2309 } 2309 }
2310 2310
2311 WebGLSharedObject* object = m_framebufferBinding->getAttachmentObject(attach ment); 2311 WebGLSharedObject* attachmentObject = m_framebufferBinding->getAttachmentObj ect(attachment);
2312 if (!object) { 2312 if (!attachmentObject) {
2313 if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE) 2313 if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE)
2314 return WebGLAny(scriptState, GL_NONE); 2314 return WebGLAny(scriptState, GL_NONE);
2315 // OpenGL ES 2.0 specifies INVALID_ENUM in this case, while desktop GL 2315 // OpenGL ES 2.0 specifies INVALID_ENUM in this case, while desktop GL
2316 // specifies INVALID_OPERATION. 2316 // specifies INVALID_OPERATION.
2317 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParameter", "invalid parameter name"); 2317 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParameter", "invalid parameter name");
2318 return ScriptValue::createNull(scriptState); 2318 return ScriptValue::createNull(scriptState);
2319 } 2319 }
2320 2320
2321 ASSERT(object->isTexture() || object->isRenderbuffer()); 2321 ASSERT(attachmentObject->isTexture() || attachmentObject->isRenderbuffer());
2322 if (object->isTexture()) { 2322 if (attachmentObject->isTexture()) {
2323 switch (pname) { 2323 switch (pname) {
2324 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: 2324 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2325 return WebGLAny(scriptState, GL_TEXTURE); 2325 return WebGLAny(scriptState, GL_TEXTURE);
2326 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: 2326 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2327 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(obj ect)); 2327 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(att achmentObject));
2328 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: 2328 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
2329 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: 2329 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
2330 { 2330 {
2331 GLint value = 0; 2331 GLint value = 0;
2332 webContext()->getFramebufferAttachmentParameteriv(target, attach ment, pname, &value); 2332 webContext()->getFramebufferAttachmentParameteriv(target, attach ment, pname, &value);
2333 return WebGLAny(scriptState, value); 2333 return WebGLAny(scriptState, value);
2334 } 2334 }
2335 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT: 2335 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT:
2336 if (extensionEnabled(EXTsRGBName) || isWebGL2OrHigher()) { 2336 if (extensionEnabled(EXTsRGBName)) {
2337 GLint value = 0; 2337 GLint value = 0;
2338 webContext()->getFramebufferAttachmentParameteriv(target, attach ment, pname, &value); 2338 webContext()->getFramebufferAttachmentParameteriv(target, attach ment, pname, &value);
2339 return WebGLAny(scriptState, value); 2339 return WebGLAny(scriptState, static_cast<unsigned>(value));
2340 } 2340 }
2341 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for renderbuffer attachment"); 2341 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for renderbuffer attachment");
2342 return ScriptValue::createNull(scriptState); 2342 return ScriptValue::createNull(scriptState);
2343 default: 2343 default:
2344 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for texture attachment"); 2344 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for texture attachment");
2345 return ScriptValue::createNull(scriptState); 2345 return ScriptValue::createNull(scriptState);
2346 } 2346 }
2347 } else { 2347 } else {
2348 switch (pname) { 2348 switch (pname) {
2349 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: 2349 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2350 return WebGLAny(scriptState, GL_RENDERBUFFER); 2350 return WebGLAny(scriptState, GL_RENDERBUFFER);
2351 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: 2351 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2352 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(obj ect)); 2352 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(att achmentObject));
2353 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT: 2353 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT:
2354 if (extensionEnabled(EXTsRGBName) || isWebGL2OrHigher()) { 2354 if (extensionEnabled(EXTsRGBName) || isWebGL2OrHigher()) {
2355 GLint value = 0; 2355 GLint value = 0;
2356 webContext()->getFramebufferAttachmentParameteriv(target, attach ment, pname, &value); 2356 webContext()->getFramebufferAttachmentParameteriv(target, attach ment, pname, &value);
2357 return WebGLAny(scriptState, value); 2357 return WebGLAny(scriptState, value);
2358 } 2358 }
2359 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for renderbuffer attachment"); 2359 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for renderbuffer attachment");
2360 return ScriptValue::createNull(scriptState); 2360 return ScriptValue::createNull(scriptState);
2361 default: 2361 default:
2362 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for renderbuffer attachment"); 2362 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for renderbuffer attachment");
(...skipping 3712 matching lines...) Expand 10 before | Expand all | Expand 10 after
6075 m_backDrawBuffer = buf; 6075 m_backDrawBuffer = buf;
6076 } 6076 }
6077 6077
6078 void WebGLRenderingContextBase::setFramebuffer(GLenum target, WebGLFramebuffer* buffer) 6078 void WebGLRenderingContextBase::setFramebuffer(GLenum target, WebGLFramebuffer* buffer)
6079 { 6079 {
6080 if (buffer) 6080 if (buffer)
6081 buffer->setHasEverBeenBound(); 6081 buffer->setHasEverBeenBound();
6082 6082
6083 if (target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER) { 6083 if (target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER) {
6084 m_framebufferBinding = buffer; 6084 m_framebufferBinding = buffer;
6085 drawingBuffer()->setFramebufferBinding(objectOrZero(m_framebufferBinding .get())); 6085 applyStencilTest();
6086 }
6087 drawingBuffer()->setFramebufferBinding(objectOrZero(m_framebufferBinding.get ()));
6086 6088
6087 if (!m_framebufferBinding) { 6089 if (!buffer) {
6088 // Instead of binding fb 0, bind the drawing buffer. 6090 // Instead of binding fb 0, bind the drawing buffer.
6089 drawingBuffer()->bind(); 6091 drawingBuffer()->bind(target);
6090 } else {
6091 webContext()->bindFramebuffer(target, objectOrZero(buffer));
6092 }
6093
6094 applyStencilTest();
6095 } else { 6092 } else {
6096 webContext()->bindFramebuffer(target, objectOrZero(buffer)); 6093 webContext()->bindFramebuffer(target, buffer->object());
6097 } 6094 }
6098 } 6095 }
6099 6096
6100 void WebGLRenderingContextBase::restoreCurrentFramebuffer() 6097 void WebGLRenderingContextBase::restoreCurrentFramebuffer()
6101 { 6098 {
6102 bindFramebuffer(GL_FRAMEBUFFER, m_framebufferBinding.get()); 6099 bindFramebuffer(GL_FRAMEBUFFER, m_framebufferBinding.get());
6103 } 6100 }
6104 6101
6105 void WebGLRenderingContextBase::restoreCurrentTexture2D() 6102 void WebGLRenderingContextBase::restoreCurrentTexture2D()
6106 { 6103 {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
6197 return m_sharedWebGraphicsContext3D ? m_sharedWebGraphicsContext3D->drawingB uffer() : 0; 6194 return m_sharedWebGraphicsContext3D ? m_sharedWebGraphicsContext3D->drawingB uffer() : 0;
6198 } 6195 }
6199 #else 6196 #else
6200 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const 6197 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const
6201 { 6198 {
6202 return m_drawingBuffer.get(); 6199 return m_drawingBuffer.get();
6203 } 6200 }
6204 #endif 6201 #endif
6205 6202
6206 } // namespace blink 6203 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/html/canvas/WebGLRenderingContextBase.h ('k') | Source/platform/graphics/gpu/DrawingBuffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698