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

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp

Issue 2372953002: Move special DEPTH_STENCIL attachment logic from command buffers to WebGL1 (Closed)
Patch Set: add more tests Created 4 years, 2 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 2349 matching lines...) Expand 10 before | Expand all | Expand 10 after
2360 return; 2360 return;
2361 } 2361 }
2362 // Don't allow the default framebuffer to be mutated; all current 2362 // Don't allow the default framebuffer to be mutated; all current
2363 // implementations use an FBO internally in place of the default 2363 // implementations use an FBO internally in place of the default
2364 // FBO. 2364 // FBO.
2365 WebGLFramebuffer* framebufferBinding = getFramebufferBinding(target); 2365 WebGLFramebuffer* framebufferBinding = getFramebufferBinding(target);
2366 if (!framebufferBinding || !framebufferBinding->object()) { 2366 if (!framebufferBinding || !framebufferBinding->object()) {
2367 synthesizeGLError(GL_INVALID_OPERATION, "framebufferRenderbuffer", "no f ramebuffer bound"); 2367 synthesizeGLError(GL_INVALID_OPERATION, "framebufferRenderbuffer", "no f ramebuffer bound");
2368 return; 2368 return;
2369 } 2369 }
2370 GLuint bufferObject = objectOrZero(buffer); 2370 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment, buf fer);
2371 if (isWebGL2OrHigher() && attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
2372 // On ES3, DEPTH_STENCIL_ATTACHMENT is like an alias for DEPTH_ATTACHMEN T + STENCIL_ATTACHMENT.
2373 // We divide it here so in WebGLFramebuffer, we don't have to handle DEP TH_STENCIL_ATTACHMENT in WebGL 2.
2374 contextGL()->FramebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, render buffertarget, bufferObject);
2375 contextGL()->FramebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT, rend erbuffertarget, bufferObject);
2376 framebufferBinding->setAttachmentForBoundFramebuffer(target, GL_DEPTH_AT TACHMENT, buffer);
2377 framebufferBinding->setAttachmentForBoundFramebuffer(target, GL_STENCIL_ ATTACHMENT, buffer);
2378 } else {
2379 contextGL()->FramebufferRenderbuffer(target, attachment, renderbuffertar get, bufferObject);
2380 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment, buffer);
2381 }
2382 applyStencilTest(); 2371 applyStencilTest();
2383 } 2372 }
2384 2373
2385 void WebGLRenderingContextBase::framebufferTexture2D(GLenum target, GLenum attac hment, GLenum textarget, WebGLTexture* texture, GLint level) 2374 void WebGLRenderingContextBase::framebufferTexture2D(GLenum target, GLenum attac hment, GLenum textarget, WebGLTexture* texture, GLint level)
2386 { 2375 {
2387 if (isContextLost() || !validateFramebufferFuncParameters("framebufferTextur e2D", target, attachment)) 2376 if (isContextLost() || !validateFramebufferFuncParameters("framebufferTextur e2D", target, attachment))
2388 return; 2377 return;
2389 if (texture && !texture->validate(contextGroup(), this)) { 2378 if (texture && !texture->validate(contextGroup(), this)) {
2390 synthesizeGLError(GL_INVALID_OPERATION, "framebufferTexture2D", "no text ure or texture not from this context"); 2379 synthesizeGLError(GL_INVALID_OPERATION, "framebufferTexture2D", "no text ure or texture not from this context");
2391 return; 2380 return;
2392 } 2381 }
2393 // Don't allow the default framebuffer to be mutated; all current 2382 // Don't allow the default framebuffer to be mutated; all current
2394 // implementations use an FBO internally in place of the default 2383 // implementations use an FBO internally in place of the default
2395 // FBO. 2384 // FBO.
2396 WebGLFramebuffer* framebufferBinding = getFramebufferBinding(target); 2385 WebGLFramebuffer* framebufferBinding = getFramebufferBinding(target);
2397 if (!framebufferBinding || !framebufferBinding->object()) { 2386 if (!framebufferBinding || !framebufferBinding->object()) {
2398 synthesizeGLError(GL_INVALID_OPERATION, "framebufferTexture2D", "no fram ebuffer bound"); 2387 synthesizeGLError(GL_INVALID_OPERATION, "framebufferTexture2D", "no fram ebuffer bound");
2399 return; 2388 return;
2400 } 2389 }
2401 GLuint textureObject = objectOrZero(texture); 2390 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment, tex target, texture, level, 0);
2402 if (isWebGL2OrHigher() && attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
2403 // On ES3, DEPTH_STENCIL_ATTACHMENT is like an alias for DEPTH_ATTACHMEN T + STENCIL_ATTACHMENT.
2404 // We divide it here so in WebGLFramebuffer, we don't have to handle DEP TH_STENCIL_ATTACHMENT in WebGL 2.
2405 contextGL()->FramebufferTexture2D(target, GL_DEPTH_ATTACHMENT, textarget , textureObject, level);
2406 contextGL()->FramebufferTexture2D(target, GL_STENCIL_ATTACHMENT, textarg et, textureObject, level);
2407 framebufferBinding->setAttachmentForBoundFramebuffer(target, GL_DEPTH_AT TACHMENT, textarget, texture, level, 0);
2408 framebufferBinding->setAttachmentForBoundFramebuffer(target, GL_STENCIL_ ATTACHMENT, textarget, texture, level, 0);
2409 } else {
2410 contextGL()->FramebufferTexture2D(target, attachment, textarget, texture Object, level);
2411 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment, textarget, texture, level, 0);
2412 }
2413 applyStencilTest(); 2391 applyStencilTest();
2414 } 2392 }
2415 2393
2416 void WebGLRenderingContextBase::frontFace(GLenum mode) 2394 void WebGLRenderingContextBase::frontFace(GLenum mode)
2417 { 2395 {
2418 if (isContextLost()) 2396 if (isContextLost())
2419 return; 2397 return;
2420 contextGL()->FrontFace(mode); 2398 contextGL()->FrontFace(mode);
2421 } 2399 }
2422 2400
(...skipping 4050 matching lines...) Expand 10 before | Expand all | Expand 10 after
6473 6451
6474 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas(HTMLCanvasElementOrOffs creenCanvas& result) const 6452 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas(HTMLCanvasElementOrOffs creenCanvas& result) const
6475 { 6453 {
6476 if (canvas()) 6454 if (canvas())
6477 result.setHTMLCanvasElement(canvas()); 6455 result.setHTMLCanvasElement(canvas());
6478 else 6456 else
6479 result.setOffscreenCanvas(getOffscreenCanvas()); 6457 result.setOffscreenCanvas(getOffscreenCanvas());
6480 } 6458 }
6481 6459
6482 } // namespace blink 6460 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698