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

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: get the 'correct' framebuffer bound to the given target 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 2278 matching lines...) Expand 10 before | Expand all | Expand 10 after
2289 ScriptValue WebGLRenderingContextBase::getFramebufferAttachmentParameter(ScriptS tate* scriptState, GLenum target, GLenum attachment, GLenum pname) 2289 ScriptValue WebGLRenderingContextBase::getFramebufferAttachmentParameter(ScriptS tate* scriptState, GLenum target, GLenum attachment, GLenum pname)
2290 { 2290 {
2291 if (isContextLost() || !validateFramebufferFuncParameters("getFramebufferAtt achmentParameter", target, attachment)) 2291 if (isContextLost() || !validateFramebufferFuncParameters("getFramebufferAtt achmentParameter", target, attachment))
2292 return ScriptValue::createNull(scriptState); 2292 return ScriptValue::createNull(scriptState);
2293 2293
2294 if (!m_framebufferBinding || !m_framebufferBinding->object()) { 2294 if (!m_framebufferBinding || !m_framebufferBinding->object()) {
2295 synthesizeGLError(GL_INVALID_OPERATION, "getFramebufferAttachmentParamet er", "no framebuffer bound"); 2295 synthesizeGLError(GL_INVALID_OPERATION, "getFramebufferAttachmentParamet er", "no framebuffer bound");
2296 return ScriptValue::createNull(scriptState); 2296 return ScriptValue::createNull(scriptState);
2297 } 2297 }
2298 2298
2299 WebGLSharedObject* object = m_framebufferBinding->getAttachmentObject(attach ment); 2299 WebGLSharedObject* attachmentObject = m_framebufferBinding->getAttachmentObj ect(attachment);
2300 if (!object) { 2300 if (!attachmentObject) {
2301 if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE) 2301 if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE)
2302 return WebGLAny(scriptState, GL_NONE); 2302 return WebGLAny(scriptState, GL_NONE);
2303 // OpenGL ES 2.0 specifies INVALID_ENUM in this case, while desktop GL 2303 // OpenGL ES 2.0 specifies INVALID_ENUM in this case, while desktop GL
2304 // specifies INVALID_OPERATION. 2304 // specifies INVALID_OPERATION.
2305 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParameter", "invalid parameter name"); 2305 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParameter", "invalid parameter name");
2306 return ScriptValue::createNull(scriptState); 2306 return ScriptValue::createNull(scriptState);
2307 } 2307 }
2308 2308
2309 ASSERT(object->isTexture() || object->isRenderbuffer()); 2309 ASSERT(attachmentObject->isTexture() || attachmentObject->isRenderbuffer());
2310 if (object->isTexture()) { 2310 if (attachmentObject->isTexture()) {
2311 switch (pname) { 2311 switch (pname) {
2312 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: 2312 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2313 return WebGLAny(scriptState, GL_TEXTURE); 2313 return WebGLAny(scriptState, GL_TEXTURE);
2314 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: 2314 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2315 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(obj ect)); 2315 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(att achmentObject));
2316 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: 2316 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
2317 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: 2317 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
2318 { 2318 {
2319 GLint value = 0; 2319 GLint value = 0;
2320 webContext()->getFramebufferAttachmentParameteriv(target, attach ment, pname, &value); 2320 webContext()->getFramebufferAttachmentParameteriv(target, attach ment, pname, &value);
2321 return WebGLAny(scriptState, value); 2321 return WebGLAny(scriptState, value);
2322 } 2322 }
2323 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT: 2323 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT:
2324 if (extensionEnabled(EXTsRGBName) || isWebGL2OrHigher()) { 2324 if (extensionEnabled(EXTsRGBName)) {
2325 GLint value = 0; 2325 GLint value = 0;
2326 webContext()->getFramebufferAttachmentParameteriv(target, attach ment, pname, &value); 2326 webContext()->getFramebufferAttachmentParameteriv(target, attach ment, pname, &value);
2327 return WebGLAny(scriptState, value); 2327 return WebGLAny(scriptState, static_cast<unsigned>(value));
2328 } 2328 }
2329 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for renderbuffer attachment"); 2329 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for renderbuffer attachment");
2330 return ScriptValue::createNull(scriptState); 2330 return ScriptValue::createNull(scriptState);
2331 default: 2331 default:
2332 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for texture attachment"); 2332 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for texture attachment");
2333 return ScriptValue::createNull(scriptState); 2333 return ScriptValue::createNull(scriptState);
2334 } 2334 }
2335 } else { 2335 } else {
2336 switch (pname) { 2336 switch (pname) {
2337 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: 2337 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
2338 return WebGLAny(scriptState, GL_RENDERBUFFER); 2338 return WebGLAny(scriptState, GL_RENDERBUFFER);
2339 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: 2339 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
2340 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(obj ect)); 2340 return WebGLAny(scriptState, PassRefPtrWillBeRawPtr<WebGLObject>(att achmentObject));
2341 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT: 2341 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT:
2342 if (extensionEnabled(EXTsRGBName) || isWebGL2OrHigher()) { 2342 if (extensionEnabled(EXTsRGBName) || isWebGL2OrHigher()) {
2343 GLint value = 0; 2343 GLint value = 0;
2344 webContext()->getFramebufferAttachmentParameteriv(target, attach ment, pname, &value); 2344 webContext()->getFramebufferAttachmentParameteriv(target, attach ment, pname, &value);
2345 return WebGLAny(scriptState, value); 2345 return WebGLAny(scriptState, value);
2346 } 2346 }
2347 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for renderbuffer attachment"); 2347 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for renderbuffer attachment");
2348 return ScriptValue::createNull(scriptState); 2348 return ScriptValue::createNull(scriptState);
2349 default: 2349 default:
2350 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for renderbuffer attachment"); 2350 synthesizeGLError(GL_INVALID_ENUM, "getFramebufferAttachmentParamete r", "invalid parameter name for renderbuffer attachment");
(...skipping 3712 matching lines...) Expand 10 before | Expand all | Expand 10 after
6063 m_backDrawBuffer = buf; 6063 m_backDrawBuffer = buf;
6064 } 6064 }
6065 6065
6066 void WebGLRenderingContextBase::setFramebuffer(GLenum target, WebGLFramebuffer* buffer) 6066 void WebGLRenderingContextBase::setFramebuffer(GLenum target, WebGLFramebuffer* buffer)
6067 { 6067 {
6068 if (buffer) 6068 if (buffer)
6069 buffer->setHasEverBeenBound(); 6069 buffer->setHasEverBeenBound();
6070 6070
6071 if (target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER) { 6071 if (target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER) {
6072 m_framebufferBinding = buffer; 6072 m_framebufferBinding = buffer;
6073 drawingBuffer()->setFramebufferBinding(objectOrZero(m_framebufferBinding .get())); 6073 applyStencilTest();
6074 }
6075 drawingBuffer()->setFramebufferBinding(objectOrZero(m_framebufferBinding.get ()));
Ken Russell (switch to Gerrit) 2015/04/30 02:28:26 Looking more deeply at the DrawingBuffer code, it
6074 6076
6075 if (!m_framebufferBinding) { 6077 if (!buffer) {
6076 // Instead of binding fb 0, bind the drawing buffer. 6078 // Instead of binding fb 0, bind the drawing buffer.
6077 drawingBuffer()->bind(); 6079 drawingBuffer()->bind(target);
6078 } else {
6079 webContext()->bindFramebuffer(target, objectOrZero(buffer));
6080 }
6081
6082 applyStencilTest();
6083 } else { 6080 } else {
6084 webContext()->bindFramebuffer(target, objectOrZero(buffer)); 6081 webContext()->bindFramebuffer(target, buffer->object());
6085 } 6082 }
6086 } 6083 }
6087 6084
6088 void WebGLRenderingContextBase::restoreCurrentFramebuffer() 6085 void WebGLRenderingContextBase::restoreCurrentFramebuffer()
6089 { 6086 {
6090 bindFramebuffer(GL_FRAMEBUFFER, m_framebufferBinding.get()); 6087 bindFramebuffer(GL_FRAMEBUFFER, m_framebufferBinding.get());
6091 } 6088 }
6092 6089
6093 void WebGLRenderingContextBase::restoreCurrentTexture2D() 6090 void WebGLRenderingContextBase::restoreCurrentTexture2D()
6094 { 6091 {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
6185 return m_sharedWebGraphicsContext3D ? m_sharedWebGraphicsContext3D->drawingB uffer() : 0; 6182 return m_sharedWebGraphicsContext3D ? m_sharedWebGraphicsContext3D->drawingB uffer() : 0;
6186 } 6183 }
6187 #else 6184 #else
6188 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const 6185 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const
6189 { 6186 {
6190 return m_drawingBuffer.get(); 6187 return m_drawingBuffer.get();
6191 } 6188 }
6192 #endif 6189 #endif
6193 6190
6194 } // namespace blink 6191 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698