Implement OES_texture_float_linear and OES_texture_half_float_linear extensions in WebGL.
BUG=238237
Review URL: https://chromiumcodereview.appspot.com/14860016
git-svn-id: svn://svn.chromium.org/blink/trunk@150722 bbb929c8-8fbe-4397-9dbb-9b2b20218538
diff --git a/LayoutTests/webgl/conformance/extensions/oes-texture-float-linear-expected.txt b/LayoutTests/webgl/conformance/extensions/oes-texture-float-linear-expected.txt
new file mode 100644
index 0000000..2d4ee9e
--- /dev/null
+++ b/LayoutTests/webgl/conformance/extensions/oes-texture-float-linear-expected.txt
@@ -0,0 +1,5 @@
+This test runs the WebGL Test listed below in an iframe and reports PASS or FAIL.
+
+Test: ../../resources/webgl_test_files/conformance/extensions/oes-texture-float-linear.html
+PASS
+
diff --git a/LayoutTests/webgl/conformance/extensions/oes-texture-float-linear.html b/LayoutTests/webgl/conformance/extensions/oes-texture-float-linear.html
new file mode 100644
index 0000000..176b196
--- /dev/null
+++ b/LayoutTests/webgl/conformance/extensions/oes-texture-float-linear.html
@@ -0,0 +1,18 @@
+<!-- This file is auto-generated by generate-webgl-tests.py. DO NOT EDIT -->
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL Conformance Test Wrapper for oes-texture-float-linear.html</title>
+<script type="text/javascript" src="../../../fast/js/resources/js-test-pre.js"></script>
+<script type="text/javascript" src="../../resources/webkit-webgl-test-harness.js"></script>
+</head>
+<body>
+<p>This test runs the WebGL Test listed below in an iframe and reports PASS or FAIL.</p>
+Test: <a href="../../resources/webgl_test_files/conformance/extensions/oes-texture-float-linear.html">../../resources/webgl_test_files/conformance/extensions/oes-texture-float-linear.html</a>
+<div id="result"></div>
+<div id="iframe">
+<iframe src="../../resources/webgl_test_files/conformance/extensions/oes-texture-float-linear.html" width="800" height="600"></iframe>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/webgl/conformance/extensions/oes-texture-half-float-linear-expected.txt b/LayoutTests/webgl/conformance/extensions/oes-texture-half-float-linear-expected.txt
new file mode 100644
index 0000000..239006c
--- /dev/null
+++ b/LayoutTests/webgl/conformance/extensions/oes-texture-half-float-linear-expected.txt
@@ -0,0 +1,5 @@
+This test runs the WebGL Test listed below in an iframe and reports PASS or FAIL.
+
+Test: ../../resources/webgl_test_files/conformance/extensions/oes-texture-half-float-linear.html
+PASS
+
diff --git a/LayoutTests/webgl/conformance/extensions/oes-texture-half-float-linear.html b/LayoutTests/webgl/conformance/extensions/oes-texture-half-float-linear.html
new file mode 100644
index 0000000..de448b8
--- /dev/null
+++ b/LayoutTests/webgl/conformance/extensions/oes-texture-half-float-linear.html
@@ -0,0 +1,18 @@
+<!-- This file is auto-generated by generate-webgl-tests.py. DO NOT EDIT -->
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL Conformance Test Wrapper for oes-texture-half-float-linear.html</title>
+<script type="text/javascript" src="../../../fast/js/resources/js-test-pre.js"></script>
+<script type="text/javascript" src="../../resources/webkit-webgl-test-harness.js"></script>
+</head>
+<body>
+<p>This test runs the WebGL Test listed below in an iframe and reports PASS or FAIL.</p>
+Test: <a href="../../resources/webgl_test_files/conformance/extensions/oes-texture-half-float-linear.html">../../resources/webgl_test_files/conformance/extensions/oes-texture-half-float-linear.html</a>
+<div id="result"></div>
+<div id="iframe">
+<iframe src="../../resources/webgl_test_files/conformance/extensions/oes-texture-half-float-linear.html" width="800" height="600"></iframe>
+</div>
+</body>
+</html>
diff --git a/LayoutTests/webgl/resources/webgl_test_files/conformance/extensions/oes-texture-float-linear.html b/LayoutTests/webgl/resources/webgl_test_files/conformance/extensions/oes-texture-float-linear.html
new file mode 100644
index 0000000..3008091
--- /dev/null
+++ b/LayoutTests/webgl/resources/webgl_test_files/conformance/extensions/oes-texture-float-linear.html
@@ -0,0 +1,54 @@
+<!--
+
+/*
+** Copyright (c) 2013 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+<script src="../resources/oes-texture-float-and-half-float-linear.js"></script>
+<script>
+"use strict";
+function testPrologue(gl, extensionTypeName) {
+ if (!gl.getExtension(extensionTypeName)) {
+ testPassed("No " + extensionTypeName + " support -- this is legal");
+ return false;
+ }
+ testPassed("Successfully enabled " + extensionTypeName + " extension");
+ return true;
+}
+</script>
+</head>
+<body onload='generateTest("OES_texture_float", "OES_texture_float_linear", "FLOAT", testPrologue)()'>
+<div id="description"></div>
+<canvas id="canvas" style="width: 50px; height: 50px;"> </canvas>
+<div id="console"></div>
+</body>
+</html>
diff --git a/LayoutTests/webgl/resources/webgl_test_files/conformance/extensions/oes-texture-half-float-linear.html b/LayoutTests/webgl/resources/webgl_test_files/conformance/extensions/oes-texture-half-float-linear.html
new file mode 100644
index 0000000..a24a918
--- /dev/null
+++ b/LayoutTests/webgl/resources/webgl_test_files/conformance/extensions/oes-texture-half-float-linear.html
@@ -0,0 +1,57 @@
+<!--
+
+/*
+** Copyright (c) 2013 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../resources/js-test-pre.js"></script>
+<script src="../resources/webgl-test.js"></script>
+<script src="../resources/webgl-test-utils.js"></script>
+<script src="../resources/oes-texture-float-and-half-float-linear.js"></script>
+<script>
+"use strict";
+function testPrologue(gl, extensionTypeName) {
+ var ext = null;
+ if (!(ext = gl.getExtension(extensionTypeName))) {
+ testPassed("No " + extensionTypeName + " support -- this is legal");
+ return false;
+ }
+ // Required by the test harness.
+ gl.HALF_FLOAT_OES = ext.HALF_FLOAT_OES;
+ testPassed("Successfully enabled " + extensionTypeName + " extension");
+ return true;
+}
+</script>
+</head>
+<body onload='generateTest("OES_texture_half_float", "OES_texture_half_float_linear", "HALF_FLOAT_OES", testPrologue)()'>
+<div id="description"></div>
+<canvas id="canvas" style="width: 50px; height: 50px;"> </canvas>
+<div id="console"></div>
+</body>
+</html>
diff --git a/LayoutTests/webgl/resources/webgl_test_files/conformance/resources/oes-texture-float-and-half-float-linear.js b/LayoutTests/webgl/resources/webgl_test_files/conformance/resources/oes-texture-float-and-half-float-linear.js
new file mode 100644
index 0000000..c2f0c7d
--- /dev/null
+++ b/LayoutTests/webgl/resources/webgl_test_files/conformance/resources/oes-texture-float-and-half-float-linear.js
@@ -0,0 +1,173 @@
+/*
+** Copyright (c) 2013 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+function generateTest(extensionTypeName, extensionName, pixelType, prologue) {
+ var wtu = WebGLTestUtils;
+ var gl = null;
+ var successfullyParsed = false;
+
+ var init = function()
+ {
+ initTestingHarnessWaitUntilDone();
+ description("This test verifies the functionality of the " + extensionName + " extension, if it is available.");
+
+ var canvas = document.getElementById("canvas");
+ gl = wtu.create3DContext(canvas);
+
+ if (!prologue(gl, extensionTypeName)) {
+ finishTest();
+ return;
+ }
+
+ // Before the extension is enabled
+ var extensionEnabled = false;
+ runTestSuite(extensionEnabled);
+
+ if (!gl.getExtension(extensionName))
+ testPassed("No " + extensionName + " support -- this is legal");
+ else {
+ // After the extension is enabled
+ extensionEnabled = true;
+ runTestSuite(extensionEnabled);
+ }
+
+ finishTest();
+ }
+
+ function runTestSuite(extensionEnabled)
+ {
+ var magF = [gl.NEAREST, gl.LINEAR];
+ var minF = [gl.NEAREST, gl.LINEAR, gl.NEAREST_MIPMAP_NEAREST, gl.NEAREST_MIPMAP_LINEAR, gl.LINEAR_MIPMAP_NEAREST, gl.LINEAR_MIPMAP_LINEAR];
+ var tex2DFShader = [
+ 'uniform sampler2D tex;',
+ 'void main() {',
+ ' gl_FragData[0] = texture2D(tex, vec2(0.5, 0.5)) * vec4(4.0, 2.0, 2.0, 1);',
+ '}'].join('\n');
+
+ var positionVertexShader = [
+ 'attribute vec4 vPosition;',
+ 'void main() {',
+ ' gl_Position = vPosition;',
+ '}'].join('\n');
+
+ var texCubeFShader = [
+ 'uniform samplerCube tex;',
+ 'void main() {',
+ ' gl_FragColor = textureCube(tex, normalize(vec3(0.5, 0.5, 1))) * vec4(4.0, 2.0, 2.0, 1);',
+ '}'].join('\n');
+
+ var vs = wtu.loadShader(gl, positionVertexShader, gl.VERTEX_SHADER);
+ var fs_2d = wtu.loadShader(gl, tex2DFShader, gl.FRAGMENT_SHADER);
+ var fs_cube = wtu.loadShader(gl, texCubeFShader, gl.FRAGMENT_SHADER);
+
+ // TEXTURE_2D
+ var program = wtu.setupProgram(gl, [vs, fs_2d]);
+ gl.useProgram(program);
+ wtu.setupUnitQuad(gl);
+ for (var kk = 0; kk < 2; ++kk) {
+ for (var ii = 0; ii < 6; ++ii) {
+ var linear = false;
+ if (magF[kk] == gl.LINEAR || (minF[ii] != gl.NEAREST && minF[ii] != gl.NEAREST_MIPMAP_NEAREST))
+ linear = true;
+ var color = (!extensionEnabled && linear) ? [0, 0, 0, 255] : [255, 255, 255, 255];
+ runEachTest(gl.TEXTURE_2D, magF[kk], minF[ii], linear, extensionEnabled, color);
+ }
+ }
+
+ // TEXTURE_CUBE_MAP
+ var programCube = wtu.setupProgram(gl, [vs, fs_cube]);
+ gl.useProgram(programCube);
+ wtu.setupUnitQuad(gl);
+ for (var kk = 0; kk < 2; ++kk) {
+ for (var ii = 0; ii < 6; ++ii) {
+ var linear = false;
+ if (magF[kk] == gl.LINEAR || (minF[ii] != gl.NEAREST && minF[ii] != gl.NEAREST_MIPMAP_NEAREST))
+ linear = true;
+ var color = (!extensionEnabled && linear) ? [0, 0, 0, 255] : [255, 255, 255, 255];
+ runEachTest(gl.TEXTURE_CUBE_MAP, magF[kk], minF[ii], linear, extensionEnabled, color);
+ }
+ }
+ }
+
+ function runEachTest(textureTarget, magFilter, minFilter, linear, extensionEnabled, expected)
+ {
+ var format = gl.RGBA;
+ var numberOfChannels = 4;
+ debug("");
+ debug("testing target: " + wtu.glEnumToString(gl,textureTarget) +
+ ", testing format: " + wtu.glEnumToString(gl, format) +
+ ", magFilter is: " + wtu.glEnumToString(gl, magFilter) +
+ ", minFilter is: " + wtu.glEnumToString(gl, minFilter) +
+ ", " + extensionName + " is " + (extensionEnabled ? "enabled": "not enabled")
+ );
+
+ // Generate data.
+ var width = 4;
+ var height = 4;
+ var canvas2d = document.createElement('canvas');
+ canvas2d.width = width;
+ canvas2d.height = height;
+ var ctx2d = canvas2d.getContext('2d');
+ var color = [64, 128, 128, 255];
+ ctx2d.fillStyle = "rgba(" + color[0] + "," + color[1] + "," + color[2] + "," + color[3] + ")";
+ ctx2d.fillRect(0, 0, width, height);
+
+ var texture = gl.createTexture();
+ gl.bindTexture(textureTarget, texture);
+ gl.texParameteri(textureTarget, gl.TEXTURE_MAG_FILTER, magFilter);
+ gl.texParameteri(textureTarget, gl.TEXTURE_MIN_FILTER, minFilter);
+ gl.texParameteri(textureTarget, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
+ gl.texParameteri(textureTarget, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
+
+ if (textureTarget == gl.TEXTURE_2D) {
+ gl.texImage2D(gl.TEXTURE_2D, 0, format, format, gl[pixelType], canvas2d);
+ if (minFilter != gl.NEAREST && minFilter != gl.LINEAR)
+ gl.generateMipmap(gl.TEXTURE_2D);
+ }
+ else if (textureTarget == gl.TEXTURE_CUBE_MAP) {
+ var targets = [
+ gl.TEXTURE_CUBE_MAP_POSITIVE_X,
+ gl.TEXTURE_CUBE_MAP_NEGATIVE_X,
+ gl.TEXTURE_CUBE_MAP_POSITIVE_Y,
+ gl.TEXTURE_CUBE_MAP_NEGATIVE_Y,
+ gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
+ gl.TEXTURE_CUBE_MAP_NEGATIVE_Z];
+ for (var tt = 0; tt < targets.length; ++tt)
+ gl.texImage2D(targets[tt], 0, format, format, gl[pixelType], canvas2d);
+ if (minFilter != gl.NEAREST && minFilter != gl.LINEAR)
+ gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
+ }
+ wtu.drawQuad(gl);
+ if (!linear) {
+ glErrorShouldBe(gl, gl.NO_ERROR, extensionTypeName + " texture with non-Linear filter should succeed with NO_ERROR no matter whether " + extensionName + " is enabled or not");
+ } else if (!extensionEnabled) {
+ glErrorShouldBe(gl, gl.NO_ERROR, extensionTypeName + " texture with Linear filter should produce [0, 0, 0, 1.0] with NO_ERROR if " + extensionName + " isn't enabled");
+ } else {
+ glErrorShouldBe(gl, gl.NO_ERROR, extensionTypeName + " texture with Linear filter should succeed with NO_ERROR if " + extensionTypeName + " is enabled");
+ }
+
+ wtu.checkCanvas(gl, expected, "should be " + expected[0] + "," + expected[1] + "," + expected[2] + "," + expected[3]);
+ }
+
+ return init;
+}
diff --git a/Source/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp b/Source/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
index af9dbca..c1a1600 100644
--- a/Source/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
+++ b/Source/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp
@@ -46,7 +46,9 @@
#include "V8OESElementIndexUint.h"
#include "V8OESStandardDerivatives.h"
#include "V8OESTextureFloat.h"
+#include "V8OESTextureFloatLinear.h"
#include "V8OESTextureHalfFloat.h"
+#include "V8OESTextureHalfFloatLinear.h"
#include "V8OESVertexArrayObject.h"
#include "V8Uint16Array.h"
#include "V8Uint32Array.h"
@@ -195,10 +197,18 @@
extensionObject = toV8(static_cast<OESTextureFloat*>(extension), contextObject, isolate);
referenceName = "oesTextureFloatName";
break;
+ case WebGLExtension::OESTextureFloatLinearName:
+ extensionObject = toV8(static_cast<OESTextureFloatLinear*>(extension), contextObject, isolate);
+ referenceName = "oesTextureFloatLinearName";
+ break;
case WebGLExtension::OESTextureHalfFloatName:
extensionObject = toV8(static_cast<OESTextureHalfFloat*>(extension), contextObject, isolate);
referenceName = "oesTextureHalfFloatName";
break;
+ case WebGLExtension::OESTextureHalfFloatLinearName:
+ extensionObject = toV8(static_cast<OESTextureHalfFloatLinear*>(extension), contextObject, isolate);
+ referenceName = "oesTextureHalfFloatLinearName";
+ break;
case WebGLExtension::OESVertexArrayObjectName:
extensionObject = toV8(static_cast<OESVertexArrayObject*>(extension), contextObject, isolate);
referenceName = "oesVertexArrayObjectName";
diff --git a/Source/core/core.gypi b/Source/core/core.gypi
index 456fa9d..857032b 100644
--- a/Source/core/core.gypi
+++ b/Source/core/core.gypi
@@ -219,7 +219,9 @@
'html/canvas/Int8Array.idl',
'html/canvas/OESStandardDerivatives.idl',
'html/canvas/OESTextureFloat.idl',
+ 'html/canvas/OESTextureFloatLinear.idl',
'html/canvas/OESTextureHalfFloat.idl',
+ 'html/canvas/OESTextureHalfFloatLinear.idl',
'html/canvas/OESVertexArrayObject.idl',
'html/canvas/OESElementIndexUint.idl',
'html/canvas/Path.idl',
@@ -2222,8 +2224,12 @@
'html/canvas/OESStandardDerivatives.h',
'html/canvas/OESTextureFloat.cpp',
'html/canvas/OESTextureFloat.h',
+ 'html/canvas/OESTextureFloatLinear.cpp',
+ 'html/canvas/OESTextureFloatLinear.h',
'html/canvas/OESTextureHalfFloat.cpp',
'html/canvas/OESTextureHalfFloat.h',
+ 'html/canvas/OESTextureHalfFloatLinear.cpp',
+ 'html/canvas/OESTextureHalfFloatLinear.h',
'html/canvas/OESVertexArrayObject.cpp',
'html/canvas/OESVertexArrayObject.h',
'html/canvas/OESElementIndexUint.cpp',
diff --git a/Source/core/html/canvas/OESTextureFloatLinear.cpp b/Source/core/html/canvas/OESTextureFloatLinear.cpp
new file mode 100644
index 0000000..454df1f
--- /dev/null
+++ b/Source/core/html/canvas/OESTextureFloatLinear.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "core/html/canvas/OESTextureFloatLinear.h"
+
+#include "core/platform/graphics/Extensions3D.h"
+
+namespace WebCore {
+
+OESTextureFloatLinear::OESTextureFloatLinear(WebGLRenderingContext* context)
+ : WebGLExtension(context)
+{
+ context->graphicsContext3D()->getExtensions()->ensureEnabled("GL_OES_texture_float_linear");
+}
+
+OESTextureFloatLinear::~OESTextureFloatLinear()
+{
+}
+
+WebGLExtension::ExtensionName OESTextureFloatLinear::getName() const
+{
+ return OESTextureFloatLinearName;
+}
+
+PassOwnPtr<OESTextureFloatLinear> OESTextureFloatLinear::create(WebGLRenderingContext* context)
+{
+ return adoptPtr(new OESTextureFloatLinear(context));
+}
+
+bool OESTextureFloatLinear::supported(WebGLRenderingContext* context)
+{
+ Extensions3D* extensions = context->graphicsContext3D()->getExtensions();
+ return extensions->supports("GL_OES_texture_float_linear");
+}
+
+const char* OESTextureFloatLinear::getExtensionName()
+{
+ return "OES_texture_float_linear";
+}
+
+} // namespace WebCore
diff --git a/Source/core/html/canvas/OESTextureFloatLinear.h b/Source/core/html/canvas/OESTextureFloatLinear.h
new file mode 100644
index 0000000..7d9145d
--- /dev/null
+++ b/Source/core/html/canvas/OESTextureFloatLinear.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef OESTextureFloatLinear_h
+#define OESTextureFloatLinear_h
+
+#include "core/html/canvas/WebGLExtension.h"
+#include "wtf/PassOwnPtr.h"
+
+namespace WebCore {
+
+class OESTextureFloatLinear : public WebGLExtension {
+public:
+ static PassOwnPtr<OESTextureFloatLinear> create(WebGLRenderingContext*);
+ static bool supported(WebGLRenderingContext*);
+ static const char* getExtensionName();
+
+ virtual ~OESTextureFloatLinear();
+ virtual ExtensionName getName() const;
+
+private:
+ OESTextureFloatLinear(WebGLRenderingContext*);
+};
+
+} // namespace WebCore
+
+#endif // OESTextureFloatLinear_h
diff --git a/Source/core/html/canvas/OESTextureFloatLinear.idl b/Source/core/html/canvas/OESTextureFloatLinear.idl
new file mode 100644
index 0000000..a4ae046
--- /dev/null
+++ b/Source/core/html/canvas/OESTextureFloatLinear.idl
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+ NoInterfaceObject,
+ Conditional=WEBGL,
+] interface OESTextureFloatLinear {
+};
diff --git a/Source/core/html/canvas/OESTextureHalfFloatLinear.cpp b/Source/core/html/canvas/OESTextureHalfFloatLinear.cpp
new file mode 100644
index 0000000..4b222ec
--- /dev/null
+++ b/Source/core/html/canvas/OESTextureHalfFloatLinear.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "core/html/canvas/OESTextureHalfFloatLinear.h"
+
+#include "core/platform/graphics/Extensions3D.h"
+
+namespace WebCore {
+
+OESTextureHalfFloatLinear::OESTextureHalfFloatLinear(WebGLRenderingContext* context)
+ : WebGLExtension(context)
+{
+ context->graphicsContext3D()->getExtensions()->ensureEnabled("GL_OES_texture_half_float_linear");
+}
+
+OESTextureHalfFloatLinear::~OESTextureHalfFloatLinear()
+{
+}
+
+WebGLExtension::ExtensionName OESTextureHalfFloatLinear::getName() const
+{
+ return OESTextureHalfFloatLinearName;
+}
+
+PassOwnPtr<OESTextureHalfFloatLinear> OESTextureHalfFloatLinear::create(WebGLRenderingContext* context)
+{
+ return adoptPtr(new OESTextureHalfFloatLinear(context));
+}
+
+bool OESTextureHalfFloatLinear::supported(WebGLRenderingContext* context)
+{
+ Extensions3D* extensions = context->graphicsContext3D()->getExtensions();
+ return extensions->supports("GL_OES_texture_half_float_linear");
+}
+
+const char* OESTextureHalfFloatLinear::getExtensionName()
+{
+ return "OES_texture_half_float_linear";
+}
+
+} // namespace WebCore
diff --git a/Source/core/html/canvas/OESTextureHalfFloatLinear.h b/Source/core/html/canvas/OESTextureHalfFloatLinear.h
new file mode 100644
index 0000000..d2b0e50
--- /dev/null
+++ b/Source/core/html/canvas/OESTextureHalfFloatLinear.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef OESTextureHalfFloatLinear_h
+#define OESTextureHalfFloatLinear_h
+
+#include "core/html/canvas/WebGLExtension.h"
+#include "wtf/PassOwnPtr.h"
+
+namespace WebCore {
+
+class OESTextureHalfFloatLinear : public WebGLExtension {
+public:
+ static PassOwnPtr<OESTextureHalfFloatLinear> create(WebGLRenderingContext*);
+ static bool supported(WebGLRenderingContext*);
+ static const char* getExtensionName();
+
+ virtual ~OESTextureHalfFloatLinear();
+ virtual ExtensionName getName() const;
+
+private:
+ OESTextureHalfFloatLinear(WebGLRenderingContext*);
+};
+
+} // namespace WebCore
+
+#endif // OESTextureHalfFloatLinear_h
diff --git a/Source/core/html/canvas/OESTextureHalfFloatLinear.idl b/Source/core/html/canvas/OESTextureHalfFloatLinear.idl
new file mode 100644
index 0000000..701e456
--- /dev/null
+++ b/Source/core/html/canvas/OESTextureHalfFloatLinear.idl
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+ NoInterfaceObject,
+ Conditional=WEBGL,
+] interface OESTextureHalfFloatLinear {
+};
diff --git a/Source/core/html/canvas/WebGLExtension.h b/Source/core/html/canvas/WebGLExtension.h
index 2a481e0..2e03b8e 100644
--- a/Source/core/html/canvas/WebGLExtension.h
+++ b/Source/core/html/canvas/WebGLExtension.h
@@ -49,6 +49,8 @@
OESElementIndexUintName,
WebGLCompressedTextureATCName,
WebGLCompressedTexturePVRTCName,
+ OESTextureFloatLinearName,
+ OESTextureHalfFloatLinearName,
};
void ref() { m_context->ref(); }
diff --git a/Source/core/html/canvas/WebGLRenderingContext.cpp b/Source/core/html/canvas/WebGLRenderingContext.cpp
index fe98e61..6df31ca 100644
--- a/Source/core/html/canvas/WebGLRenderingContext.cpp
+++ b/Source/core/html/canvas/WebGLRenderingContext.cpp
@@ -38,7 +38,9 @@
#include "core/html/canvas/OESElementIndexUint.h"
#include "core/html/canvas/OESStandardDerivatives.h"
#include "core/html/canvas/OESTextureFloat.h"
+#include "core/html/canvas/OESTextureFloatLinear.h"
#include "core/html/canvas/OESTextureHalfFloat.h"
+#include "core/html/canvas/OESTextureHalfFloatLinear.h"
#include "core/html/canvas/OESVertexArrayObject.h"
#include "core/html/canvas/WebGLActiveInfo.h"
#include "core/html/canvas/WebGLBuffer.h"
@@ -634,8 +636,7 @@
m_vertexAttribValue.resize(m_maxVertexAttribs);
- if (!isGLES2NPOTStrict())
- createFallbackBlackTextures1x1();
+ createFallbackBlackTextures1x1();
IntSize canvasSize = clampedCanvasSize();
m_drawingBuffer->reset(canvasSize);
@@ -1748,12 +1749,9 @@
clearIfComposited();
- bool vertexAttrib0Simulated = false;
- if (!isGLES2NPOTStrict())
- handleNPOTTextures("drawArrays", true);
+ handleTextureCompleteness("drawArrays", true);
m_context->drawArrays(mode, first, count);
- if (!isGLES2NPOTStrict())
- handleNPOTTextures("drawArrays", false);
+ handleTextureCompleteness("drawArrays", false);
markContextChanged();
}
@@ -1809,11 +1807,9 @@
}
clearIfComposited();
- if (!isGLES2NPOTStrict())
- handleNPOTTextures("drawElements", true);
+ handleTextureCompleteness("drawElements", true);
m_context->drawElements(mode, count, type, static_cast<GC3Dintptr>(offset));
- if (!isGLES2NPOTStrict())
- handleNPOTTextures("drawElements", false);
+ handleTextureCompleteness("drawElements", false);
markContextChanged();
}
@@ -2133,6 +2129,10 @@
return extension;
if (getExtensionIfMatch<EXTDrawBuffers>(name, m_extDrawBuffers, unprefixed, extension))
return extension;
+ if (getExtensionIfMatch<OESTextureFloatLinear>(name, m_oesTextureFloatLinear, unprefixed, extension))
+ return extension;
+ if (getExtensionIfMatch<OESTextureHalfFloatLinear>(name, m_oesTextureHalfFloatLinear, unprefixed, extension))
+ return extension;
if (allowPrivilegedExtensions()) {
if (getExtensionIfMatch<WebGLDebugRendererInfo>(name, m_webglDebugRendererInfo, unprefixed, extension))
return extension;
@@ -2619,6 +2619,9 @@
appendIfSupported<OESElementIndexUint>(result, false);
appendIfSupported<OESStandardDerivatives>(result, false);
appendIfSupported<OESTextureFloat>(result, false);
+ appendIfSupported<OESTextureFloatLinear>(result, false);
+ appendIfSupported<OESTextureHalfFloat>(result, false);
+ appendIfSupported<OESTextureHalfFloatLinear>(result, false);
appendIfSupported<OESVertexArrayObject>(result, false);
appendIfSupported<WebGLCompressedTextureATC>(result, true);
appendIfSupported<WebGLCompressedTexturePVRTC>(result, true);
@@ -4341,13 +4344,15 @@
return WebGLGetInfo(Int32Array::create(value, length));
}
-void WebGLRenderingContext::handleNPOTTextures(const char* functionName, bool prepareToDraw)
+void WebGLRenderingContext::handleTextureCompleteness(const char* functionName, bool prepareToDraw)
{
// All calling functions check isContextLost, so a duplicate check is not needed here.
bool resetActiveUnit = false;
+ WebGLTexture::TextureExtensionFlag flag = static_cast<WebGLTexture::TextureExtensionFlag>((m_oesTextureFloatLinear ? WebGLTexture::TextureFloatLinearExtensionEnabled : 0)
+ | (m_oesTextureHalfFloatLinear ? WebGLTexture::TextureHalfFloatLinearExtensionEnabled : 0));
for (unsigned ii = 0; ii < m_textureUnits.size(); ++ii) {
- if ((m_textureUnits[ii].m_texture2DBinding && m_textureUnits[ii].m_texture2DBinding->needToUseBlackTexture())
- || (m_textureUnits[ii].m_textureCubeMapBinding && m_textureUnits[ii].m_textureCubeMapBinding->needToUseBlackTexture())) {
+ if ((m_textureUnits[ii].m_texture2DBinding.get() && m_textureUnits[ii].m_texture2DBinding->needToUseBlackTexture(flag))
+ || (m_textureUnits[ii].m_textureCubeMapBinding.get() && m_textureUnits[ii].m_textureCubeMapBinding->needToUseBlackTexture(flag))) {
if (ii != m_activeTextureUnit) {
m_context->activeTexture(ii);
resetActiveUnit = true;
@@ -4359,7 +4364,8 @@
WebGLTexture* texCubeMap;
if (prepareToDraw) {
String msg(String("texture bound to texture unit ") + String::number(ii)
- + " is not renderable. It maybe non-power-of-2 and have incompatible texture filtering or is not 'texture complete'");
+ + " is not renderable. It maybe non-power-of-2 and have incompatible texture filtering or is not 'texture complete'."
+ + " Or the texture is Float or Half Float type with linear filtering while OES_float_linear or OES_half_float_linear extension is not enabled.");
printGLWarningToConsole(functionName, msg.utf8().data());
tex2D = m_blackTexture2D.get();
texCubeMap = m_blackTextureCubeMap.get();
@@ -4367,9 +4373,9 @@
tex2D = m_textureUnits[ii].m_texture2DBinding.get();
texCubeMap = m_textureUnits[ii].m_textureCubeMapBinding.get();
}
- if (m_textureUnits[ii].m_texture2DBinding && m_textureUnits[ii].m_texture2DBinding->needToUseBlackTexture())
+ if (m_textureUnits[ii].m_texture2DBinding && m_textureUnits[ii].m_texture2DBinding->needToUseBlackTexture(flag))
m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, objectOrZero(tex2D));
- if (m_textureUnits[ii].m_textureCubeMapBinding && m_textureUnits[ii].m_textureCubeMapBinding->needToUseBlackTexture())
+ if (m_textureUnits[ii].m_textureCubeMapBinding && m_textureUnits[ii].m_textureCubeMapBinding->needToUseBlackTexture(flag))
m_context->bindTexture(GraphicsContext3D::TEXTURE_CUBE_MAP, objectOrZero(texCubeMap));
}
}
diff --git a/Source/core/html/canvas/WebGLRenderingContext.h b/Source/core/html/canvas/WebGLRenderingContext.h
index 16c7fb7..368e5e2 100644
--- a/Source/core/html/canvas/WebGLRenderingContext.h
+++ b/Source/core/html/canvas/WebGLRenderingContext.h
@@ -53,6 +53,8 @@
class OESStandardDerivatives;
class OESTextureFloat;
class OESTextureHalfFloat;
+class OESTextureFloatLinear;
+class OESTextureHalfFloatLinear;
class OESVertexArrayObject;
class OESElementIndexUint;
class WebGLActiveInfo;
@@ -523,7 +525,9 @@
OwnPtr<EXTDrawBuffers> m_extDrawBuffers;
OwnPtr<EXTTextureFilterAnisotropic> m_extTextureFilterAnisotropic;
OwnPtr<OESTextureFloat> m_oesTextureFloat;
+ OwnPtr<OESTextureFloatLinear> m_oesTextureFloatLinear;
OwnPtr<OESTextureHalfFloat> m_oesTextureHalfFloat;
+ OwnPtr<OESTextureHalfFloatLinear> m_oesTextureHalfFloatLinear;
OwnPtr<OESStandardDerivatives> m_oesStandardDerivatives;
OwnPtr<OESVertexArrayObject> m_oesVertexArrayObject;
OwnPtr<OESElementIndexUint> m_oesElementIndexUint;
@@ -560,8 +564,7 @@
void texSubImage2DBase(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Dsizei width, GC3Dsizei height, GC3Denum format, GC3Denum type, const void* pixels, ExceptionCode&);
void texSubImage2DImpl(GC3Denum target, GC3Dint level, GC3Dint xoffset, GC3Dint yoffset, GC3Denum format, GC3Denum type, Image*, GraphicsContext3D::ImageHtmlDomSource, bool flipY, bool premultiplyAlpha, ExceptionCode&);
- void handleNPOTTextures(const char*, bool);
-
+ void handleTextureCompleteness(const char*, bool);
void createFallbackBlackTextures1x1();
// Helper function for copyTex{Sub}Image, check whether the internalformat
diff --git a/Source/core/html/canvas/WebGLTexture.cpp b/Source/core/html/canvas/WebGLTexture.cpp
index c8c23bd..c5d2bff 100644
--- a/Source/core/html/canvas/WebGLTexture.cpp
+++ b/Source/core/html/canvas/WebGLTexture.cpp
@@ -48,6 +48,8 @@
, m_isNPOT(false)
, m_isComplete(false)
, m_needToUseBlackTexture(false)
+ , m_isFloatType(false)
+ , m_isHalfFloatType(false)
{
setObject(ctx->graphicsContext3D()->createTexture());
}
@@ -230,11 +232,17 @@
return m_isNPOT;
}
-bool WebGLTexture::needToUseBlackTexture() const
+bool WebGLTexture::needToUseBlackTexture(TextureExtensionFlag flag) const
{
if (!object())
return false;
- return m_needToUseBlackTexture;
+ if (m_needToUseBlackTexture)
+ return true;
+ if ((m_isFloatType && !(flag & TextureFloatLinearExtensionEnabled)) || (m_isHalfFloatType && !(flag && TextureHalfFloatLinearExtensionEnabled))) {
+ if (m_magFilter != GraphicsContext3D::NEAREST || (m_minFilter != GraphicsContext3D::NEAREST && m_minFilter != GraphicsContext3D::NEAREST_MIPMAP_NEAREST))
+ return true;
+ }
+ return false;
}
void WebGLTexture::deleteObjectImpl(GraphicsContext3D* context3d, Platform3DObject object)
@@ -340,6 +348,28 @@
}
}
}
+ m_isFloatType = false;
+ if (m_isComplete)
+ m_isFloatType = m_info[0][0].type == GraphicsContext3D::FLOAT;
+ else {
+ for (size_t ii = 0; ii < m_info.size(); ++ii) {
+ if (m_info[ii][0].type == GraphicsContext3D::FLOAT) {
+ m_isFloatType = true;
+ break;
+ }
+ }
+ }
+ m_isHalfFloatType = false;
+ if (m_isComplete)
+ m_isHalfFloatType = m_info[0][0].type == GraphicsContext3D::HALF_FLOAT_OES;
+ else {
+ for (size_t ii = 0; ii < m_info.size(); ++ii) {
+ if (m_info[ii][0].type == GraphicsContext3D::HALF_FLOAT_OES) {
+ m_isHalfFloatType = true;
+ break;
+ }
+ }
+ }
m_needToUseBlackTexture = false;
// NPOT
diff --git a/Source/core/html/canvas/WebGLTexture.h b/Source/core/html/canvas/WebGLTexture.h
index d766c3f..cc1c8f2 100644
--- a/Source/core/html/canvas/WebGLTexture.h
+++ b/Source/core/html/canvas/WebGLTexture.h
@@ -36,6 +36,11 @@
class WebGLTexture : public WebGLSharedObject {
public:
+ enum TextureExtensionFlag {
+ NoTextureExtensionEnabled = 0,
+ TextureFloatLinearExtensionEnabled = 1 << 0,
+ TextureHalfFloatLinearExtensionEnabled = 1 << 1
+ };
virtual ~WebGLTexture();
static PassRefPtr<WebGLTexture> create(WebGLRenderingContext*);
@@ -65,7 +70,7 @@
bool isNPOT() const;
// Determine if texture sampling should always return [0, 0, 0, 1] (OpenGL ES 2.0 Sec 3.8.2).
- bool needToUseBlackTexture() const;
+ bool needToUseBlackTexture(TextureExtensionFlag) const;
bool hasEverBeenBound() const { return object() && m_target; }
@@ -124,6 +129,8 @@
bool m_isNPOT;
bool m_isComplete;
bool m_needToUseBlackTexture;
+ bool m_isFloatType;
+ bool m_isHalfFloatType;
};
} // namespace WebCore
diff --git a/Source/core/platform/graphics/Extensions3D.h b/Source/core/platform/graphics/Extensions3D.h
index 954d955..8b4da8e 100644
--- a/Source/core/platform/graphics/Extensions3D.h
+++ b/Source/core/platform/graphics/Extensions3D.h
@@ -52,7 +52,9 @@
// GL_EXT_packed_depth_stencil / GL_OES_packed_depth_stencil
// GL_ANGLE_framebuffer_blit / GL_ANGLE_framebuffer_multisample
// GL_OES_texture_float
+ // GL_OES_texture_float_linear
// GL_OES_texture_half_float
+ // GL_OES_texture_half_float_linear
// GL_OES_standard_derivatives
// GL_OES_rgb8_rgba8
// GL_OES_vertex_array_object