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: Source/WebCore/html/canvas/WebGLRenderingContext.cpp

Issue 10584035: Merge 120636 - Fix framebuffer-object-attachment.html failures (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1180/
Patch Set: Created 8 years, 6 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 | « Source/WebCore/html/canvas/WebGLRenderingContext.h ('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 2041 matching lines...) Expand 10 before | Expand all | Expand 10 after
2052 return; 2052 return;
2053 } 2053 }
2054 // Don't allow the default framebuffer to be mutated; all current 2054 // Don't allow the default framebuffer to be mutated; all current
2055 // implementations use an FBO internally in place of the default 2055 // implementations use an FBO internally in place of the default
2056 // FBO. 2056 // FBO.
2057 if (!m_framebufferBinding || !m_framebufferBinding->object()) { 2057 if (!m_framebufferBinding || !m_framebufferBinding->object()) {
2058 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferRend erbuffer", "no framebuffer bound"); 2058 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferRend erbuffer", "no framebuffer bound");
2059 return; 2059 return;
2060 } 2060 }
2061 Platform3DObject bufferObject = objectOrZero(buffer); 2061 Platform3DObject bufferObject = objectOrZero(buffer);
2062 bool reattachDepth = false;
2063 bool reattachStencil = false;
2064 bool reattachDepthStencilDepth = false;
2065 bool reattachDepthStencilStencil = false;
2066 switch (attachment) { 2062 switch (attachment) {
2067 case GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT: 2063 case GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT:
2068 m_context->framebufferRenderbuffer(target, GraphicsContext3D::DEPTH_ATTA CHMENT, renderbuffertarget, bufferObject); 2064 m_context->framebufferRenderbuffer(target, GraphicsContext3D::DEPTH_ATTA CHMENT, renderbuffertarget, bufferObject);
2069 m_context->framebufferRenderbuffer(target, GraphicsContext3D::STENCIL_AT TACHMENT, renderbuffertarget, bufferObject); 2065 m_context->framebufferRenderbuffer(target, GraphicsContext3D::STENCIL_AT TACHMENT, renderbuffertarget, bufferObject);
2070 if (!bufferObject) {
2071 reattachDepth = true;
2072 reattachStencil = true;
2073 }
2074 break; 2066 break;
2075 case GraphicsContext3D::DEPTH_ATTACHMENT: 2067 case GraphicsContext3D::DEPTH_ATTACHMENT:
2076 m_context->framebufferRenderbuffer(target, attachment, renderbuffertarge t, bufferObject); 2068 m_context->framebufferRenderbuffer(target, attachment, renderbuffertarge t, bufferObject);
2077 if (!bufferObject)
2078 reattachDepthStencilDepth = true;
2079 break; 2069 break;
2080 case GraphicsContext3D::STENCIL_ATTACHMENT: 2070 case GraphicsContext3D::STENCIL_ATTACHMENT:
2081 m_context->framebufferRenderbuffer(target, attachment, renderbuffertarge t, bufferObject); 2071 m_context->framebufferRenderbuffer(target, attachment, renderbuffertarge t, bufferObject);
2082 if (!bufferObject)
2083 reattachDepthStencilStencil = true;
2084 break; 2072 break;
2085 default: 2073 default:
2086 m_context->framebufferRenderbuffer(target, attachment, renderbuffertarge t, bufferObject); 2074 m_context->framebufferRenderbuffer(target, attachment, renderbuffertarge t, bufferObject);
2087 } 2075 }
2088 m_framebufferBinding->setAttachmentForBoundFramebuffer(attachment, buffer); 2076 m_framebufferBinding->setAttachmentForBoundFramebuffer(attachment, buffer);
2089 reattachDepthStencilAttachments(reattachDepth, reattachStencil, reattachDept hStencilDepth, reattachDepthStencilStencil);
2090 applyStencilTest(); 2077 applyStencilTest();
2091 cleanupAfterGraphicsCall(false); 2078 cleanupAfterGraphicsCall(false);
2092 } 2079 }
2093 2080
2094 void WebGLRenderingContext::reattachDepthStencilAttachments(bool reattachDepth, bool reattachStencil, bool reattachDepthStencilDepth, bool reattachDepthStencilS tencil)
2095 {
2096 if (reattachDepth)
2097 m_framebufferBinding->attach(GraphicsContext3D::DEPTH_ATTACHMENT, Graphi csContext3D::DEPTH_ATTACHMENT);
2098 if (reattachStencil)
2099 m_framebufferBinding->attach(GraphicsContext3D::STENCIL_ATTACHMENT, Grap hicsContext3D::STENCIL_ATTACHMENT);
2100 if (reattachDepthStencilDepth)
2101 m_framebufferBinding->attach(GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT , GraphicsContext3D::DEPTH_ATTACHMENT);
2102 if (reattachDepthStencilStencil)
2103 m_framebufferBinding->attach(GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT , GraphicsContext3D::STENCIL_ATTACHMENT);
2104 }
2105
2106 void WebGLRenderingContext::framebufferTexture2D(GC3Denum target, GC3Denum attac hment, GC3Denum textarget, WebGLTexture* texture, GC3Dint level, ExceptionCode& ec) 2081 void WebGLRenderingContext::framebufferTexture2D(GC3Denum target, GC3Denum attac hment, GC3Denum textarget, WebGLTexture* texture, GC3Dint level, ExceptionCode& ec)
2107 { 2082 {
2108 UNUSED_PARAM(ec); 2083 UNUSED_PARAM(ec);
2109 if (isContextLost() || !validateFramebufferFuncParameters("framebufferTextur e2D", target, attachment)) 2084 if (isContextLost() || !validateFramebufferFuncParameters("framebufferTextur e2D", target, attachment))
2110 return; 2085 return;
2111 if (level) { 2086 if (level) {
2112 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "framebufferTexture2 D", "level not 0"); 2087 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "framebufferTexture2 D", "level not 0");
2113 return; 2088 return;
2114 } 2089 }
2115 if (texture && !texture->validate(contextGroup(), this)) { 2090 if (texture && !texture->validate(contextGroup(), this)) {
2116 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferText ure2D", "no texture or texture not from this context"); 2091 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferText ure2D", "no texture or texture not from this context");
2117 return; 2092 return;
2118 } 2093 }
2119 // Don't allow the default framebuffer to be mutated; all current 2094 // Don't allow the default framebuffer to be mutated; all current
2120 // implementations use an FBO internally in place of the default 2095 // implementations use an FBO internally in place of the default
2121 // FBO. 2096 // FBO.
2122 if (!m_framebufferBinding || !m_framebufferBinding->object()) { 2097 if (!m_framebufferBinding || !m_framebufferBinding->object()) {
2123 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferText ure2D", "no framebuffer bound"); 2098 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "framebufferText ure2D", "no framebuffer bound");
2124 return; 2099 return;
2125 } 2100 }
2126 Platform3DObject textureObject = objectOrZero(texture); 2101 Platform3DObject textureObject = objectOrZero(texture);
2127 bool reattachDepth = false;
2128 bool reattachStencil = false;
2129 bool reattachDepthStencilDepth = false;
2130 bool reattachDepthStencilStencil = false;
2131 switch (attachment) { 2102 switch (attachment) {
2132 case GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT: 2103 case GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT:
2133 m_context->framebufferTexture2D(target, GraphicsContext3D::DEPTH_ATTACHM ENT, textarget, textureObject, level); 2104 m_context->framebufferTexture2D(target, GraphicsContext3D::DEPTH_ATTACHM ENT, textarget, textureObject, level);
2134 m_context->framebufferTexture2D(target, GraphicsContext3D::STENCIL_ATTAC HMENT, textarget, textureObject, level); 2105 m_context->framebufferTexture2D(target, GraphicsContext3D::STENCIL_ATTAC HMENT, textarget, textureObject, level);
2135 if (!textureObject) {
2136 reattachDepth = true;
2137 reattachStencil = true;
2138 }
2139 break; 2106 break;
2140 case GraphicsContext3D::DEPTH_ATTACHMENT: 2107 case GraphicsContext3D::DEPTH_ATTACHMENT:
2141 m_context->framebufferTexture2D(target, attachment, textarget, textureOb ject, level); 2108 m_context->framebufferTexture2D(target, attachment, textarget, textureOb ject, level);
2142 if (!textureObject)
2143 reattachDepthStencilDepth = true;
2144 break; 2109 break;
2145 case GraphicsContext3D::STENCIL_ATTACHMENT: 2110 case GraphicsContext3D::STENCIL_ATTACHMENT:
2146 m_context->framebufferTexture2D(target, attachment, textarget, textureOb ject, level); 2111 m_context->framebufferTexture2D(target, attachment, textarget, textureOb ject, level);
2147 if (!textureObject)
2148 reattachDepthStencilStencil = true;
2149 break; 2112 break;
2150 default: 2113 default:
2151 m_context->framebufferTexture2D(target, attachment, textarget, textureOb ject, level); 2114 m_context->framebufferTexture2D(target, attachment, textarget, textureOb ject, level);
2152 } 2115 }
2153 m_framebufferBinding->setAttachmentForBoundFramebuffer(attachment, textarget , texture, level); 2116 m_framebufferBinding->setAttachmentForBoundFramebuffer(attachment, textarget , texture, level);
2154 reattachDepthStencilAttachments(reattachDepth, reattachStencil, reattachDept hStencilDepth, reattachDepthStencilStencil);
2155 applyStencilTest(); 2117 applyStencilTest();
2156 cleanupAfterGraphicsCall(false); 2118 cleanupAfterGraphicsCall(false);
2157 } 2119 }
2158 2120
2159 void WebGLRenderingContext::frontFace(GC3Denum mode) 2121 void WebGLRenderingContext::frontFace(GC3Denum mode)
2160 { 2122 {
2161 if (isContextLost()) 2123 if (isContextLost())
2162 return; 2124 return;
2163 m_context->frontFace(mode); 2125 m_context->frontFace(mode);
2164 cleanupAfterGraphicsCall(false); 2126 cleanupAfterGraphicsCall(false);
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
2463 return getBooleanArrayParameter(pname); 2425 return getBooleanArrayParameter(pname);
2464 case GraphicsContext3D::COMPRESSED_TEXTURE_FORMATS: 2426 case GraphicsContext3D::COMPRESSED_TEXTURE_FORMATS:
2465 return WebGLGetInfo(Uint32Array::create(m_compressedTextureFormats.data( ), m_compressedTextureFormats.size())); 2427 return WebGLGetInfo(Uint32Array::create(m_compressedTextureFormats.data( ), m_compressedTextureFormats.size()));
2466 case GraphicsContext3D::CULL_FACE: 2428 case GraphicsContext3D::CULL_FACE:
2467 return getBooleanParameter(pname); 2429 return getBooleanParameter(pname);
2468 case GraphicsContext3D::CULL_FACE_MODE: 2430 case GraphicsContext3D::CULL_FACE_MODE:
2469 return getUnsignedIntParameter(pname); 2431 return getUnsignedIntParameter(pname);
2470 case GraphicsContext3D::CURRENT_PROGRAM: 2432 case GraphicsContext3D::CURRENT_PROGRAM:
2471 return WebGLGetInfo(PassRefPtr<WebGLProgram>(m_currentProgram)); 2433 return WebGLGetInfo(PassRefPtr<WebGLProgram>(m_currentProgram));
2472 case GraphicsContext3D::DEPTH_BITS: 2434 case GraphicsContext3D::DEPTH_BITS:
2473 if (!m_attributes.depth) 2435 if (!m_framebufferBinding && !m_attributes.depth)
2474 return WebGLGetInfo(intZero); 2436 return WebGLGetInfo(intZero);
2475 return getIntParameter(pname); 2437 return getIntParameter(pname);
2476 case GraphicsContext3D::DEPTH_CLEAR_VALUE: 2438 case GraphicsContext3D::DEPTH_CLEAR_VALUE:
2477 return getFloatParameter(pname); 2439 return getFloatParameter(pname);
2478 case GraphicsContext3D::DEPTH_FUNC: 2440 case GraphicsContext3D::DEPTH_FUNC:
2479 return getUnsignedIntParameter(pname); 2441 return getUnsignedIntParameter(pname);
2480 case GraphicsContext3D::DEPTH_RANGE: 2442 case GraphicsContext3D::DEPTH_RANGE:
2481 return getWebGLFloatArrayParameter(pname); 2443 return getWebGLFloatArrayParameter(pname);
2482 case GraphicsContext3D::DEPTH_TEST: 2444 case GraphicsContext3D::DEPTH_TEST:
2483 return getBooleanParameter(pname); 2445 return getBooleanParameter(pname);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
2558 return getUnsignedIntParameter(pname); 2520 return getUnsignedIntParameter(pname);
2559 case GraphicsContext3D::STENCIL_BACK_PASS_DEPTH_PASS: 2521 case GraphicsContext3D::STENCIL_BACK_PASS_DEPTH_PASS:
2560 return getUnsignedIntParameter(pname); 2522 return getUnsignedIntParameter(pname);
2561 case GraphicsContext3D::STENCIL_BACK_REF: 2523 case GraphicsContext3D::STENCIL_BACK_REF:
2562 return getIntParameter(pname); 2524 return getIntParameter(pname);
2563 case GraphicsContext3D::STENCIL_BACK_VALUE_MASK: 2525 case GraphicsContext3D::STENCIL_BACK_VALUE_MASK:
2564 return getUnsignedIntParameter(pname); 2526 return getUnsignedIntParameter(pname);
2565 case GraphicsContext3D::STENCIL_BACK_WRITEMASK: 2527 case GraphicsContext3D::STENCIL_BACK_WRITEMASK:
2566 return getUnsignedIntParameter(pname); 2528 return getUnsignedIntParameter(pname);
2567 case GraphicsContext3D::STENCIL_BITS: 2529 case GraphicsContext3D::STENCIL_BITS:
2568 if (!m_attributes.stencil) 2530 if (!m_framebufferBinding && !m_attributes.stencil)
2569 return WebGLGetInfo(intZero); 2531 return WebGLGetInfo(intZero);
2570 return getIntParameter(pname); 2532 return getIntParameter(pname);
2571 case GraphicsContext3D::STENCIL_CLEAR_VALUE: 2533 case GraphicsContext3D::STENCIL_CLEAR_VALUE:
2572 return getIntParameter(pname); 2534 return getIntParameter(pname);
2573 case GraphicsContext3D::STENCIL_FAIL: 2535 case GraphicsContext3D::STENCIL_FAIL:
2574 return getUnsignedIntParameter(pname); 2536 return getUnsignedIntParameter(pname);
2575 case GraphicsContext3D::STENCIL_FUNC: 2537 case GraphicsContext3D::STENCIL_FUNC:
2576 return getUnsignedIntParameter(pname); 2538 return getUnsignedIntParameter(pname);
2577 case GraphicsContext3D::STENCIL_PASS_DEPTH_FAIL: 2539 case GraphicsContext3D::STENCIL_PASS_DEPTH_FAIL:
2578 return getUnsignedIntParameter(pname); 2540 return getUnsignedIntParameter(pname);
(...skipping 3015 matching lines...) Expand 10 before | Expand all | Expand 10 after
5594 { 5556 {
5595 if (enable) 5557 if (enable)
5596 m_context->enable(capability); 5558 m_context->enable(capability);
5597 else 5559 else
5598 m_context->disable(capability); 5560 m_context->disable(capability);
5599 } 5561 }
5600 5562
5601 } // namespace WebCore 5563 } // namespace WebCore
5602 5564
5603 #endif // ENABLE(WEBGL) 5565 #endif // ENABLE(WEBGL)
OLDNEW
« no previous file with comments | « Source/WebCore/html/canvas/WebGLRenderingContext.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698