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

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

Issue 2389363002: Move special DEPTH_STENCIL attachment logic from command buffers to WebGL1 (Closed)
Patch Set: 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
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLFramebuffer.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2510 matching lines...) Expand 10 before | Expand all | Expand 10 after
2521 } 2521 }
2522 // Don't allow the default framebuffer to be mutated; all current 2522 // Don't allow the default framebuffer to be mutated; all current
2523 // implementations use an FBO internally in place of the default 2523 // implementations use an FBO internally in place of the default
2524 // FBO. 2524 // FBO.
2525 WebGLFramebuffer* framebufferBinding = getFramebufferBinding(target); 2525 WebGLFramebuffer* framebufferBinding = getFramebufferBinding(target);
2526 if (!framebufferBinding || !framebufferBinding->object()) { 2526 if (!framebufferBinding || !framebufferBinding->object()) {
2527 synthesizeGLError(GL_INVALID_OPERATION, "framebufferRenderbuffer", 2527 synthesizeGLError(GL_INVALID_OPERATION, "framebufferRenderbuffer",
2528 "no framebuffer bound"); 2528 "no framebuffer bound");
2529 return; 2529 return;
2530 } 2530 }
2531 GLuint bufferObject = objectOrZero(buffer); 2531 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment,
2532 if (isWebGL2OrHigher() && attachment == GL_DEPTH_STENCIL_ATTACHMENT) { 2532 buffer);
2533 // On ES3, DEPTH_STENCIL_ATTACHMENT is like an alias for DEPTH_ATTACHMENT +
2534 // STENCIL_ATTACHMENT. We divide it here so in WebGLFramebuffer, we don't
2535 // have to handle DEPTH_STENCIL_ATTACHMENT in WebGL 2.
2536 contextGL()->FramebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT,
2537 renderbuffertarget, bufferObject);
2538 contextGL()->FramebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT,
2539 renderbuffertarget, bufferObject);
2540 framebufferBinding->setAttachmentForBoundFramebuffer(
2541 target, GL_DEPTH_ATTACHMENT, buffer);
2542 framebufferBinding->setAttachmentForBoundFramebuffer(
2543 target, GL_STENCIL_ATTACHMENT, buffer);
2544 } else {
2545 contextGL()->FramebufferRenderbuffer(target, attachment, renderbuffertarget,
2546 bufferObject);
2547 framebufferBinding->setAttachmentForBoundFramebuffer(target, attachment,
2548 buffer);
2549 }
2550 applyStencilTest(); 2533 applyStencilTest();
2551 } 2534 }
2552 2535
2553 void WebGLRenderingContextBase::framebufferTexture2D(GLenum target, 2536 void WebGLRenderingContextBase::framebufferTexture2D(GLenum target,
2554 GLenum attachment, 2537 GLenum attachment,
2555 GLenum textarget, 2538 GLenum textarget,
2556 WebGLTexture* texture, 2539 WebGLTexture* texture,
2557 GLint level) { 2540 GLint level) {
2558 if (isContextLost() || 2541 if (isContextLost() ||
2559 !validateFramebufferFuncParameters("framebufferTexture2D", target, 2542 !validateFramebufferFuncParameters("framebufferTexture2D", target,
2560 attachment)) 2543 attachment))
2561 return; 2544 return;
2562 if (texture && !texture->validate(contextGroup(), this)) { 2545 if (texture && !texture->validate(contextGroup(), this)) {
2563 synthesizeGLError(GL_INVALID_OPERATION, "framebufferTexture2D", 2546 synthesizeGLError(GL_INVALID_OPERATION, "framebufferTexture2D",
2564 "no texture or texture not from this context"); 2547 "no texture or texture not from this context");
2565 return; 2548 return;
2566 } 2549 }
2567 // Don't allow the default framebuffer to be mutated; all current 2550 // Don't allow the default framebuffer to be mutated; all current
2568 // implementations use an FBO internally in place of the default 2551 // implementations use an FBO internally in place of the default
2569 // FBO. 2552 // FBO.
2570 WebGLFramebuffer* framebufferBinding = getFramebufferBinding(target); 2553 WebGLFramebuffer* framebufferBinding = getFramebufferBinding(target);
2571 if (!framebufferBinding || !framebufferBinding->object()) { 2554 if (!framebufferBinding || !framebufferBinding->object()) {
2572 synthesizeGLError(GL_INVALID_OPERATION, "framebufferTexture2D", 2555 synthesizeGLError(GL_INVALID_OPERATION, "framebufferTexture2D",
2573 "no framebuffer bound"); 2556 "no framebuffer bound");
2574 return; 2557 return;
2575 } 2558 }
2576 GLuint textureObject = objectOrZero(texture); 2559 framebufferBinding->setAttachmentForBoundFramebuffer(
2577 if (isWebGL2OrHigher() && attachment == GL_DEPTH_STENCIL_ATTACHMENT) { 2560 target, attachment, textarget, texture, level, 0);
2578 // On ES3, DEPTH_STENCIL_ATTACHMENT is like an alias for DEPTH_ATTACHMENT +
2579 // STENCIL_ATTACHMENT. We divide it here so in WebGLFramebuffer, we don't
2580 // have to handle DEPTH_STENCIL_ATTACHMENT in WebGL 2.
2581 contextGL()->FramebufferTexture2D(target, GL_DEPTH_ATTACHMENT, textarget,
2582 textureObject, level);
2583 contextGL()->FramebufferTexture2D(target, GL_STENCIL_ATTACHMENT, textarget,
2584 textureObject, level);
2585 framebufferBinding->setAttachmentForBoundFramebuffer(
2586 target, GL_DEPTH_ATTACHMENT, textarget, texture, level, 0);
2587 framebufferBinding->setAttachmentForBoundFramebuffer(
2588 target, GL_STENCIL_ATTACHMENT, textarget, texture, level, 0);
2589 } else {
2590 contextGL()->FramebufferTexture2D(target, attachment, textarget,
2591 textureObject, level);
2592 framebufferBinding->setAttachmentForBoundFramebuffer(
2593 target, attachment, textarget, texture, level, 0);
2594 }
2595 applyStencilTest(); 2561 applyStencilTest();
2596 } 2562 }
2597 2563
2598 void WebGLRenderingContextBase::frontFace(GLenum mode) { 2564 void WebGLRenderingContextBase::frontFace(GLenum mode) {
2599 if (isContextLost()) 2565 if (isContextLost())
2600 return; 2566 return;
2601 contextGL()->FrontFace(mode); 2567 contextGL()->FrontFace(mode);
2602 } 2568 }
2603 2569
2604 void WebGLRenderingContextBase::generateMipmap(GLenum target) { 2570 void WebGLRenderingContextBase::generateMipmap(GLenum target) {
(...skipping 4870 matching lines...) Expand 10 before | Expand all | Expand 10 after
7475 7441
7476 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( 7442 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas(
7477 HTMLCanvasElementOrOffscreenCanvas& result) const { 7443 HTMLCanvasElementOrOffscreenCanvas& result) const {
7478 if (canvas()) 7444 if (canvas())
7479 result.setHTMLCanvasElement(canvas()); 7445 result.setHTMLCanvasElement(canvas());
7480 else 7446 else
7481 result.setOffscreenCanvas(getOffscreenCanvas()); 7447 result.setOffscreenCanvas(getOffscreenCanvas());
7482 } 7448 }
7483 7449
7484 } // namespace blink 7450 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLFramebuffer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698