Commit 85f90658 authored by cmarrin@apple.com's avatar cmarrin@apple.com
Browse files

Changed mallocs to fastMallocs and frees to fastFrees in...

        Changed mallocs to fastMallocs and frees to fastFrees in GraphicsContext3D. Also added error returns
        https://bugs.webkit.org/show_bug.cgi?id=30778



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51537 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ac15d211
2009-12-01 Chris Marrin <cmarrin@apple.com>
Reviewed by Adam Roben.
Added tests for getProgramInfoLog, getShaderInfoLog and getShaderSource to WebGL tests
https://bugs.webkit.org/show_bug.cgi?id=30778
* fast/canvas/webgl/gl-object-get-calls-expected.txt:
* fast/canvas/webgl/script-tests/gl-object-get-calls.js:
2009-12-01 Chris Marrin <cmarrin@apple.com>
 
Reviewed by Oliver Hunt.
......@@ -2,6 +2,11 @@ Test of get calls against GL objects like getBufferParameter, etc.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS gl.getProgramInfoLog(standardProgram) is ""
PASS gl.getShaderInfoLog(errorVert) is parseError
PASS gl.getShaderInfoLog(errorFrag) is parseError
PASS gl.getShaderSource(errorVert) is errorVertString
PASS gl.getShaderSource(errorFrag) is errorFragString
PASS gl.getBufferParameter(gl.ARRAY_BUFFER, gl.BUFFER_SIZE) is 16
PASS gl.getBufferParameter(gl.ARRAY_BUFFER, gl.BUFFER_USAGE) is gl.DYNAMIC_DRAW
PASS gl.getError() is 0
......
description("Test of get calls against GL objects like getBufferParameter, etc.");
var gl = create3DContext();
var errorVert = gl.createShader(gl.VERTEX_SHADER);
gl.shaderSource(errorVert, "I am a bad vertex shader");
gl.compileShader(errorVert);
var errorFrag = gl.createShader(gl.FRAGMENT_SHADER);
gl.shaderSource(errorFrag, "I am a bad fragment shader");
gl.compileShader(errorFrag);
var standardVert = loadStandardVertexShader(gl);
var standardFrag = loadStandardFragmentShader(gl);
var standardProgram = gl.createProgram();
......@@ -8,6 +17,16 @@ gl.attachShader(standardProgram, standardVert);
gl.attachShader(standardProgram, standardFrag);
gl.linkProgram(standardProgram);
// Test program and shader gets
var parseError = "ERROR: 0:1: 'I' : syntax error syntax error\nERROR: Parser found no code to compile in source strings.\n";
var errorVertString = "I am a bad vertex shader\n";
var errorFragString = "I am a bad fragment shader\n";
shouldBe('gl.getProgramInfoLog(standardProgram)', '""');
shouldBe('gl.getShaderInfoLog(errorVert)', 'parseError');
shouldBe('gl.getShaderInfoLog(errorFrag)', 'parseError');
shouldBe('gl.getShaderSource(errorVert)', 'errorVertString');
shouldBe('gl.getShaderSource(errorFrag)', 'errorFragString');
// Test getBufferParameter
var buffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
......
2009-12-01 Chris Marrin <cmarrin@apple.com>
Reviewed by Adam Roben.
Changed mallocs to fastMallocs and frees to fastFrees in GraphicsContext3D. Also added error returns
https://bugs.webkit.org/show_bug.cgi?id=30778
* platform/graphics/mac/GraphicsContext3DMac.cpp:
(WebCore::GraphicsContext3D::getProgramInfoLog):
(WebCore::GraphicsContext3D::getShaderInfoLog):
(WebCore::GraphicsContext3D::getShaderSource):
(WebCore::imageToTexture):
2009-12-01 Mads Ager <ager@chromium.org>
 
Reviewed by Eric Seidel.
......@@ -997,10 +997,13 @@ String GraphicsContext3D::getProgramInfoLog(WebGLProgram* program)
::glGetProgramiv((GLuint) program->object(), GL_INFO_LOG_LENGTH, &length);
GLsizei size;
GLchar* info = (GLchar*) malloc(length);
GLchar* info = (GLchar*) fastMalloc(length);
if (!info)
return "";
::glGetProgramInfoLog((GLuint) program->object(), length, &size, info);
String s(info);
free(info);
fastFree(info);
return s;
}
......@@ -1027,10 +1030,13 @@ String GraphicsContext3D::getShaderInfoLog(WebGLShader* shader)
::glGetShaderiv((GLuint) shader->object(), GL_INFO_LOG_LENGTH, &length);
GLsizei size;
GLchar* info = (GLchar*) malloc(length);
GLchar* info = (GLchar*) fastMalloc(length);
if (!info)
return "";
::glGetShaderInfoLog((GLuint) shader->object(), length, &size, info);
String s(info);
free(info);
fastFree(info);
return s;
}
......@@ -1043,10 +1049,13 @@ String GraphicsContext3D::getShaderSource(WebGLShader* shader)
::glGetShaderiv((GLuint) shader->object(), GL_SHADER_SOURCE_LENGTH, &length);
GLsizei size;
GLchar* info = (GLchar*) malloc(length);
GLchar* info = (GLchar*) fastMalloc(length);
if (!info)
return "";
::glGetShaderSource((GLuint) shader->object(), length, &size, info);
String s(info);
free(info);
fastFree(info);
return s;
}
......@@ -1117,7 +1126,10 @@ static void imageToTexture(Image* image, unsigned target, unsigned level)
size_t textureWidth = CGImageGetWidth(textureImage);
size_t textureHeight = CGImageGetHeight(textureImage);
GLubyte* textureData = (GLubyte*) malloc(textureWidth * textureHeight * 4);
GLubyte* textureData = (GLubyte*) fastMalloc(textureWidth * textureHeight * 4);
if (!textureData)
return;
CGContextRef textureContext = CGBitmapContextCreate(textureData, textureWidth, textureHeight, 8, textureWidth * 4,
CGImageGetColorSpace(textureImage), kCGImageAlphaPremultipliedLast);
......@@ -1125,7 +1137,7 @@ static void imageToTexture(Image* image, unsigned target, unsigned level)
CGContextRelease(textureContext);
::glTexImage2D(target, level, GL_RGBA, textureWidth, textureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureData);
free(textureData);
fastFree(textureData);
}
int GraphicsContext3D::texImage2D(unsigned target, unsigned level, unsigned internalformat, unsigned width, unsigned height, unsigned border, unsigned format, unsigned type, WebGLArray* pixels)
......
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