OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "core/html/canvas/WebGL2RenderingContextBase.h" | 6 #include "core/html/canvas/WebGL2RenderingContextBase.h" |
7 | 7 |
8 #include "bindings/core/v8/WebGLAny.h" | 8 #include "bindings/core/v8/WebGLAny.h" |
9 #include "core/html/HTMLCanvasElement.h" | 9 #include "core/html/HTMLCanvasElement.h" |
10 #include "core/html/HTMLImageElement.h" | 10 #include "core/html/HTMLImageElement.h" |
(...skipping 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1444 m_readFramebufferBinding = buffer; | 1444 m_readFramebufferBinding = buffer; |
1445 break; | 1445 break; |
1446 default: | 1446 default: |
1447 synthesizeGLError(GL_INVALID_ENUM, "bindFramebuffer", "invalid target"); | 1447 synthesizeGLError(GL_INVALID_ENUM, "bindFramebuffer", "invalid target"); |
1448 return; | 1448 return; |
1449 } | 1449 } |
1450 | 1450 |
1451 setFramebuffer(target, buffer); | 1451 setFramebuffer(target, buffer); |
1452 } | 1452 } |
1453 | 1453 |
| 1454 void WebGL2RenderingContextBase::deleteFramebuffer(WebGLFramebuffer* framebuffer
) |
| 1455 { |
| 1456 if (!deleteObject(framebuffer)) |
| 1457 return; |
| 1458 GLenum target = 0; |
| 1459 if (framebuffer == m_framebufferBinding) { |
| 1460 if (framebuffer == m_readFramebufferBinding) { |
| 1461 target = GL_FRAMEBUFFER; |
| 1462 m_framebufferBinding = nullptr; |
| 1463 m_readFramebufferBinding = nullptr; |
| 1464 } else { |
| 1465 target = GL_DRAW_FRAMEBUFFER; |
| 1466 m_framebufferBinding = nullptr; |
| 1467 } |
| 1468 } else if (framebuffer == m_readFramebufferBinding) { |
| 1469 target = GL_READ_FRAMEBUFFER; |
| 1470 m_readFramebufferBinding = nullptr; |
| 1471 } |
| 1472 if (target) { |
| 1473 drawingBuffer()->setFramebufferBinding(target, 0); |
| 1474 // Have to call drawingBuffer()->bind() here to bind back to internal fb
o. |
| 1475 drawingBuffer()->bind(target); |
| 1476 } |
| 1477 } |
| 1478 |
1454 ScriptValue WebGL2RenderingContextBase::getParameter(ScriptState* scriptState, G
Lenum pname) | 1479 ScriptValue WebGL2RenderingContextBase::getParameter(ScriptState* scriptState, G
Lenum pname) |
1455 { | 1480 { |
1456 if (isContextLost()) | 1481 if (isContextLost()) |
1457 return ScriptValue::createNull(scriptState); | 1482 return ScriptValue::createNull(scriptState); |
1458 switch (pname) { | 1483 switch (pname) { |
1459 case GL_SHADING_LANGUAGE_VERSION: | 1484 case GL_SHADING_LANGUAGE_VERSION: |
1460 return WebGLAny(scriptState, "WebGL GLSL ES 3.00 (" + String(webContext(
)->getString(GL_SHADING_LANGUAGE_VERSION)) + ")"); | 1485 return WebGLAny(scriptState, "WebGL GLSL ES 3.00 (" + String(webContext(
)->getString(GL_SHADING_LANGUAGE_VERSION)) + ")"); |
1461 case GL_VERSION: | 1486 case GL_VERSION: |
1462 return WebGLAny(scriptState, "WebGL 2.0 (" + String(webContext()->getStr
ing(GL_VERSION)) + ")"); | 1487 return WebGLAny(scriptState, "WebGL 2.0 (" + String(webContext()->getStr
ing(GL_VERSION)) + ")"); |
1463 | 1488 |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1831 { | 1856 { |
1832 GLfloat value = 0.f; | 1857 GLfloat value = 0.f; |
1833 webContext()->getTexParameterfv(target, pname, &value); | 1858 webContext()->getTexParameterfv(target, pname, &value); |
1834 return WebGLAny(scriptState, value); | 1859 return WebGLAny(scriptState, value); |
1835 } | 1860 } |
1836 default: | 1861 default: |
1837 return WebGLRenderingContextBase::getTexParameter(scriptState, target, p
name); | 1862 return WebGLRenderingContextBase::getTexParameter(scriptState, target, p
name); |
1838 } | 1863 } |
1839 } | 1864 } |
1840 | 1865 |
| 1866 void WebGL2RenderingContextBase::restoreCurrentFramebuffer() |
| 1867 { |
| 1868 bindFramebuffer(GL_DRAW_FRAMEBUFFER, m_framebufferBinding.get()); |
| 1869 bindFramebuffer(GL_READ_FRAMEBUFFER, m_readFramebufferBinding.get()); |
| 1870 } |
| 1871 |
| 1872 GLenum WebGL2RenderingContextBase::boundFramebufferColorFormat() |
| 1873 { |
| 1874 if (m_readFramebufferBinding && m_readFramebufferBinding->object()) |
| 1875 return m_readFramebufferBinding->colorBufferFormat(); |
| 1876 if (m_requestedAttributes.alpha()) |
| 1877 return GL_RGBA; |
| 1878 return GL_RGB; |
| 1879 } |
| 1880 |
| 1881 GLenum WebGL2RenderingContextBase::getDrawFramebufferTarget() |
| 1882 { |
| 1883 return GL_DRAW_FRAMEBUFFER; |
| 1884 } |
| 1885 |
1841 } // namespace blink | 1886 } // namespace blink |
OLD | NEW |