Commit 4cdc9803 authored by zmo@google.com's avatar zmo@google.com

2011-01-26 Zhenyao Mo <zmo@google.com>

        Reviewed by Kenneth Russell.

        shaderSource needs to preserve original source
        https://bugs.webkit.org/show_bug.cgi?id=52833

        * fast/canvas/webgl/gl-getshadersource-expected.txt: Added.
        * fast/canvas/webgl/gl-getshadersource.html: Added.
2011-01-26  Zhenyao Mo  <zmo@google.com>

        Reviewed by Kenneth Russell.

        shaderSource needs to preserve original source
        https://bugs.webkit.org/show_bug.cgi?id=52833

        Test: fast/canvas/webgl/gl-getshadersource.html

        * html/canvas/WebGLRenderingContext.cpp:
        (WebCore::WebGLRenderingContext::getShaderParameter): Intercept SHADER_SOURCE_LENGTH.
        (WebCore::WebGLRenderingContext::getShaderSource): Intercept the call.
        (WebCore::WebGLRenderingContext::shaderSource): Cache the source.
        * html/canvas/WebGLShader.cpp: Cache shader source.
        (WebCore::WebGLShader::WebGLShader):
        * html/canvas/WebGLShader.h: Ditto.
        (WebCore::WebGLShader::getSource):
        (WebCore::WebGLShader::setSource):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76814 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent da9d0ea6
2011-01-26 Zhenyao Mo <zmo@google.com>
Reviewed by Kenneth Russell.
shaderSource needs to preserve original source
https://bugs.webkit.org/show_bug.cgi?id=52833
* fast/canvas/webgl/gl-getshadersource-expected.txt: Added.
* fast/canvas/webgl/gl-getshadersource.html: Added.
2011-01-27 Philippe Normand <pnormand@igalia.com>
Unreviewed, skip flaky test, needs further investigation on the failure.
Tests that the source that goes into a shader is what comes out.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS sourceLength is 0
PASS source is original
PASS sourceLength is 17
PASS getError was expected value: NO_ERROR : Should be no errors.
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type'/>
<title>WebGL getShaderSource conformance test.</title>
<link rel="stylesheet" href="../../js/resources/js-test-style.css"/>
<script src="../../js/resources/js-test-pre.js"></script>
<script src="resources/webgl-test.js"> </script>
<script src="resources/webgl-test-utils.js"> </script>
</head>
<body>
<canvas id="example" width="4" height="4" style="width: 40px; height: 30px;"></canvas>
<div id="description"></div>
<div id="console"></div>
<script id="vshader" type="x-shader/x-vertex">abc//defNOTASCII</script>
<script>
description("Tests that the source that goes into a shader is what comes out.");
var wtu = WebGLTestUtils;
var canvas = document.getElementById("example");
var gl = wtu.create3DContext(canvas);
var original = document.getElementById("vshader").text;
var shader = gl.createShader(gl.VERTEX_SHADER);
var sourceLength = gl.getShaderParameter(shader, gl.SHADER_SOURCE_LENGTH);
shouldBe("sourceLength", "0");
gl.shaderSource(shader, original);
var source = gl.getShaderSource(shader);
shouldBe("source", "original");
sourceLength = gl.getShaderParameter(shader, gl.SHADER_SOURCE_LENGTH);
shouldBe("sourceLength", "17");
successfullyParsed = true;
glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors.");
</script>
</body>
</body>
<script src="../../js/resources/js-test-post.js"></script>
<script>
</script>
</body>
</html>
2011-01-26 Zhenyao Mo <zmo@google.com>
Reviewed by Kenneth Russell.
shaderSource needs to preserve original source
https://bugs.webkit.org/show_bug.cgi?id=52833
Test: fast/canvas/webgl/gl-getshadersource.html
* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::getShaderParameter): Intercept SHADER_SOURCE_LENGTH.
(WebCore::WebGLRenderingContext::getShaderSource): Intercept the call.
(WebCore::WebGLRenderingContext::shaderSource): Cache the source.
* html/canvas/WebGLShader.cpp: Cache shader source.
(WebCore::WebGLShader::WebGLShader):
* html/canvas/WebGLShader.h: Ditto.
(WebCore::WebGLShader::getSource):
(WebCore::WebGLShader::setSource):
2011-01-27 Patrick Gansterer <paroga@webkit.org>
Unreviewed WinCE build fix for r76743.
......@@ -2164,9 +2164,13 @@ WebGLGetInfo WebGLRenderingContext::getShaderParameter(WebGLShader* shader, GC3D
m_context->getShaderiv(objectOrZero(shader), pname, &value);
return WebGLGetInfo(static_cast<unsigned int>(value));
case GraphicsContext3D::INFO_LOG_LENGTH:
case GraphicsContext3D::SHADER_SOURCE_LENGTH:
m_context->getShaderiv(objectOrZero(shader), pname, &value);
return WebGLGetInfo(value);
case GraphicsContext3D::SHADER_SOURCE_LENGTH:
value = static_cast<GC3Dint>(shader->getSource().length());
if (value > 0)
value++; // Includes the null termination character.
return WebGLGetInfo(value);
default:
m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
return WebGLGetInfo();
......@@ -2191,8 +2195,7 @@ String WebGLRenderingContext::getShaderSource(WebGLShader* shader, ExceptionCode
return String();
if (!validateWebGLObject(shader))
return "";
WebGLStateRestorer(this, false);
return m_context->getShaderSource(objectOrZero(shader));
return shader->getSource();
}
Vector<String> WebGLRenderingContext::getSupportedExtensions()
......@@ -2772,6 +2775,7 @@ void WebGLRenderingContext::shaderSource(WebGLShader* shader, const String& stri
String stringWithoutComments = StripComments(string).result();
if (!validateString(stringWithoutComments))
return;
shader->setSource(string);
m_context->shaderSource(objectOrZero(shader), stringWithoutComments);
cleanupAfterGraphicsCall(false);
}
......
......@@ -41,6 +41,7 @@ PassRefPtr<WebGLShader> WebGLShader::create(WebGLRenderingContext* ctx, GC3Denum
WebGLShader::WebGLShader(WebGLRenderingContext* ctx, GC3Denum type)
: WebGLObject(ctx)
, m_type(type)
, m_source("")
{
setObject(context()->graphicsContext3D()->createShader(type));
}
......
......@@ -40,6 +40,9 @@ public:
static PassRefPtr<WebGLShader> create(WebGLRenderingContext*, GC3Denum);
GC3Denum getType() const { return m_type; }
const String& getSource() const { return m_source; }
void setSource(const String& source) { m_source = source; }
private:
WebGLShader(WebGLRenderingContext*, GC3Denum);
......@@ -49,6 +52,7 @@ private:
virtual bool isShader() const { return true; }
GC3Denum m_type;
String m_source;
};
} // namespace WebCore
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment