[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
kbr at google.com
kbr at google.com
Wed Dec 22 11:42:40 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 3fac0262b2d217bd467c55bc1b1d0efad06281f4
Author: kbr at google.com <kbr at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Aug 4 18:39:02 2010 +0000
2010-08-03 Kenneth Russell <kbr at google.com>
Reviewed by Nate Chapin.
Move WebGL-specific code out of GraphicsContext3D so that G3D can be used as a generic accelerated drawing API
https://bugs.webkit.org/show_bug.cgi?id=43221
Added a helper function to extract the contents of WebGL objects
to reduce duplicated code and fix a couple of potential crashes
introduced in the previous refactoring.
No new tests; ran existing WebGL tests.
* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::attachShader):
(WebCore::WebGLRenderingContext::bindAttribLocation):
(WebCore::WebGLRenderingContext::bindBuffer):
(WebCore::WebGLRenderingContext::bindFramebuffer):
(WebCore::WebGLRenderingContext::bindRenderbuffer):
(WebCore::WebGLRenderingContext::bindTexture):
(WebCore::WebGLRenderingContext::compileShader):
(WebCore::WebGLRenderingContext::detachShader):
(WebCore::WebGLRenderingContext::framebufferRenderbuffer):
(WebCore::WebGLRenderingContext::framebufferTexture2D):
(WebCore::WebGLRenderingContext::getActiveAttrib):
(WebCore::WebGLRenderingContext::getActiveUniform):
(WebCore::WebGLRenderingContext::getAttachedShaders):
(WebCore::WebGLRenderingContext::getAttribLocation):
(WebCore::WebGLRenderingContext::getProgramParameter):
(WebCore::WebGLRenderingContext::getProgramInfoLog):
(WebCore::WebGLRenderingContext::getShaderParameter):
(WebCore::WebGLRenderingContext::getShaderInfoLog):
(WebCore::WebGLRenderingContext::getShaderSource):
(WebCore::WebGLRenderingContext::getUniform):
(WebCore::WebGLRenderingContext::getUniformLocation):
(WebCore::WebGLRenderingContext::linkProgram):
(WebCore::WebGLRenderingContext::shaderSource):
(WebCore::WebGLRenderingContext::useProgram):
(WebCore::WebGLRenderingContext::validateProgram):
(WebCore::WebGLRenderingContext::handleNPOTTextures):
(WebCore::WebGLRenderingContext::restoreStatesAfterVertexAttrib0Simulation):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64660 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 89e80b9..bff0980 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,45 @@
+2010-08-03 Kenneth Russell <kbr at google.com>
+
+ Reviewed by Nate Chapin.
+
+ Move WebGL-specific code out of GraphicsContext3D so that G3D can be used as a generic accelerated drawing API
+ https://bugs.webkit.org/show_bug.cgi?id=43221
+
+ Added a helper function to extract the contents of WebGL objects
+ to reduce duplicated code and fix a couple of potential crashes
+ introduced in the previous refactoring.
+
+ No new tests; ran existing WebGL tests.
+
+ * html/canvas/WebGLRenderingContext.cpp:
+ (WebCore::WebGLRenderingContext::attachShader):
+ (WebCore::WebGLRenderingContext::bindAttribLocation):
+ (WebCore::WebGLRenderingContext::bindBuffer):
+ (WebCore::WebGLRenderingContext::bindFramebuffer):
+ (WebCore::WebGLRenderingContext::bindRenderbuffer):
+ (WebCore::WebGLRenderingContext::bindTexture):
+ (WebCore::WebGLRenderingContext::compileShader):
+ (WebCore::WebGLRenderingContext::detachShader):
+ (WebCore::WebGLRenderingContext::framebufferRenderbuffer):
+ (WebCore::WebGLRenderingContext::framebufferTexture2D):
+ (WebCore::WebGLRenderingContext::getActiveAttrib):
+ (WebCore::WebGLRenderingContext::getActiveUniform):
+ (WebCore::WebGLRenderingContext::getAttachedShaders):
+ (WebCore::WebGLRenderingContext::getAttribLocation):
+ (WebCore::WebGLRenderingContext::getProgramParameter):
+ (WebCore::WebGLRenderingContext::getProgramInfoLog):
+ (WebCore::WebGLRenderingContext::getShaderParameter):
+ (WebCore::WebGLRenderingContext::getShaderInfoLog):
+ (WebCore::WebGLRenderingContext::getShaderSource):
+ (WebCore::WebGLRenderingContext::getUniform):
+ (WebCore::WebGLRenderingContext::getUniformLocation):
+ (WebCore::WebGLRenderingContext::linkProgram):
+ (WebCore::WebGLRenderingContext::shaderSource):
+ (WebCore::WebGLRenderingContext::useProgram):
+ (WebCore::WebGLRenderingContext::validateProgram):
+ (WebCore::WebGLRenderingContext::handleNPOTTextures):
+ (WebCore::WebGLRenderingContext::restoreStatesAfterVertexAttrib0Simulation):
+
2010-08-04 Mario Sanchez Prada <msanchez at igalia.com>
Reviewed by Jeremy Orlow.
diff --git a/WebCore/html/canvas/WebGLRenderingContext.cpp b/WebCore/html/canvas/WebGLRenderingContext.cpp
index 235a500..80dd282 100644
--- a/WebCore/html/canvas/WebGLRenderingContext.cpp
+++ b/WebCore/html/canvas/WebGLRenderingContext.cpp
@@ -57,6 +57,11 @@
namespace WebCore {
+static inline Platform3DObject objectOrZero(CanvasObject* object)
+{
+ return object ? object->object() : 0;
+}
+
class WebGLStateRestorer {
public:
WebGLStateRestorer(WebGLRenderingContext* context,
@@ -220,7 +225,7 @@ void WebGLRenderingContext::attachShader(WebGLProgram* program, WebGLShader* sha
UNUSED_PARAM(ec);
if (!validateWebGLObject(program) || !validateWebGLObject(shader))
return;
- m_context->attachShader(program ? program->object() : 0, shader ? shader->object() : 0);
+ m_context->attachShader(objectOrZero(program), objectOrZero(shader));
cleanupAfterGraphicsCall(false);
}
@@ -229,7 +234,7 @@ void WebGLRenderingContext::bindAttribLocation(WebGLProgram* program, unsigned l
UNUSED_PARAM(ec);
if (!validateWebGLObject(program))
return;
- m_context->bindAttribLocation(program ? program->object() : 0, index, name);
+ m_context->bindAttribLocation(objectOrZero(program), index, name);
cleanupAfterGraphicsCall(false);
}
@@ -254,7 +259,7 @@ void WebGLRenderingContext::bindBuffer(unsigned long target, WebGLBuffer* buffer
return;
}
- m_context->bindBuffer(target, buffer ? buffer->object() : 0);
+ m_context->bindBuffer(target, objectOrZero(buffer));
if (buffer)
buffer->setTarget(target);
cleanupAfterGraphicsCall(false);
@@ -273,7 +278,7 @@ void WebGLRenderingContext::bindFramebuffer(unsigned long target, WebGLFramebuff
return;
}
m_framebufferBinding = buffer;
- m_context->bindFramebuffer(target, buffer ? buffer->object() : 0);
+ m_context->bindFramebuffer(target, objectOrZero(buffer));
if (m_framebufferBinding)
m_framebufferBinding->onBind();
cleanupAfterGraphicsCall(false);
@@ -291,7 +296,7 @@ void WebGLRenderingContext::bindRenderbuffer(unsigned long target, WebGLRenderbu
return;
}
m_renderbufferBinding = renderBuffer;
- m_context->bindRenderbuffer(target, renderBuffer ? renderBuffer->object() : 0);
+ m_context->bindRenderbuffer(target, objectOrZero(renderBuffer));
cleanupAfterGraphicsCall(false);
}
@@ -314,7 +319,7 @@ void WebGLRenderingContext::bindTexture(unsigned long target, WebGLTexture* text
m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
return;
}
- m_context->bindTexture(target, texture ? texture->object() : 0);
+ m_context->bindTexture(target, objectOrZero(texture));
if (!isGLES2Compliant() && texture)
texture->setTarget(target, maxLevel);
@@ -516,7 +521,7 @@ void WebGLRenderingContext::compileShader(WebGLShader* shader, ExceptionCode& ec
UNUSED_PARAM(ec);
if (!validateWebGLObject(shader))
return;
- m_context->compileShader(shader ? shader->object() : 0);
+ m_context->compileShader(objectOrZero(shader));
cleanupAfterGraphicsCall(false);
}
@@ -706,7 +711,7 @@ void WebGLRenderingContext::detachShader(WebGLProgram* program, WebGLShader* sha
UNUSED_PARAM(ec);
if (!validateWebGLObject(program) || !validateWebGLObject(shader))
return;
- m_context->detachShader(program ? program->object() : 0, shader ? shader->object() : 0);
+ m_context->detachShader(objectOrZero(program), objectOrZero(shader));
cleanupAfterGraphicsCall(false);
}
@@ -1075,7 +1080,7 @@ void WebGLRenderingContext::framebufferRenderbuffer(unsigned long target, unsign
return;
}
}
- m_context->framebufferRenderbuffer(target, attachment, renderbuffertarget, buffer ? buffer->object() : 0);
+ m_context->framebufferRenderbuffer(target, attachment, renderbuffertarget, objectOrZero(buffer));
m_framebufferBinding->setAttachment(attachment, buffer);
cleanupAfterGraphicsCall(false);
}
@@ -1100,7 +1105,7 @@ void WebGLRenderingContext::framebufferTexture2D(unsigned long target, unsigned
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
return;
}
- m_context->framebufferTexture2D(target, attachment, textarget, texture ? texture->object() : 0, level);
+ m_context->framebufferTexture2D(target, attachment, textarget, objectOrZero(texture), level);
m_framebufferBinding->setAttachment(attachment, texture);
cleanupAfterGraphicsCall(false);
}
@@ -1138,7 +1143,7 @@ PassRefPtr<WebGLActiveInfo> WebGLRenderingContext::getActiveAttrib(WebGLProgram*
ActiveInfo info;
if (!validateWebGLObject(program))
return 0;
- if (!m_context->getActiveAttrib(program ? program->object() : 0, index, info)) {
+ if (!m_context->getActiveAttrib(objectOrZero(program), index, info)) {
return 0;
}
return WebGLActiveInfo::create(info.name, info.type, info.size);
@@ -1150,7 +1155,7 @@ PassRefPtr<WebGLActiveInfo> WebGLRenderingContext::getActiveUniform(WebGLProgram
ActiveInfo info;
if (!validateWebGLObject(program))
return 0;
- if (!m_context->getActiveUniform(program ? program->object() : 0, index, info)) {
+ if (!m_context->getActiveUniform(objectOrZero(program), index, info)) {
return 0;
}
if (!isGLES2Compliant()) {
@@ -1167,11 +1172,11 @@ bool WebGLRenderingContext::getAttachedShaders(WebGLProgram* program, Vector<Web
if (!validateWebGLObject(program))
return false;
int numShaders = 0;
- m_context->getProgramiv(program ? program->object() : 0, GraphicsContext3D::ATTACHED_SHADERS, &numShaders);
+ m_context->getProgramiv(objectOrZero(program), GraphicsContext3D::ATTACHED_SHADERS, &numShaders);
if (numShaders) {
OwnArrayPtr<unsigned int> shaders(new unsigned int[numShaders]);
int count;
- m_context->getAttachedShaders(program ? program->object() : 0, numShaders, &count, shaders.get());
+ m_context->getAttachedShaders(objectOrZero(program), numShaders, &count, shaders.get());
if (count != numShaders)
return false;
shaderObjects.resize(numShaders);
@@ -1189,7 +1194,7 @@ bool WebGLRenderingContext::getAttachedShaders(WebGLProgram* program, Vector<Web
int WebGLRenderingContext::getAttribLocation(WebGLProgram* program, const String& name)
{
- return m_context->getAttribLocation(program ? program->object() : 0, name);
+ return m_context->getAttribLocation(objectOrZero(program), name);
}
WebGLGetInfo WebGLRenderingContext::getBufferParameter(unsigned long target, unsigned long pname, ExceptionCode& ec)
@@ -1467,12 +1472,12 @@ WebGLGetInfo WebGLRenderingContext::getProgramParameter(WebGLProgram* program, u
switch (pname) {
case GraphicsContext3D::DELETE_STATUS:
case GraphicsContext3D::VALIDATE_STATUS:
- m_context->getProgramiv(program ? program->object() : 0, pname, &value);
+ m_context->getProgramiv(objectOrZero(program), pname, &value);
return WebGLGetInfo(static_cast<bool>(value));
case GraphicsContext3D::LINK_STATUS:
if (program->isLinkFailureFlagSet())
return WebGLGetInfo(false);
- m_context->getProgramiv(program ? program->object() : 0, pname, &value);
+ m_context->getProgramiv(objectOrZero(program), pname, &value);
return WebGLGetInfo(static_cast<bool>(value));
case GraphicsContext3D::INFO_LOG_LENGTH:
case GraphicsContext3D::ATTACHED_SHADERS:
@@ -1480,7 +1485,7 @@ WebGLGetInfo WebGLRenderingContext::getProgramParameter(WebGLProgram* program, u
case GraphicsContext3D::ACTIVE_ATTRIBUTE_MAX_LENGTH:
case GraphicsContext3D::ACTIVE_UNIFORMS:
case GraphicsContext3D::ACTIVE_UNIFORM_MAX_LENGTH:
- m_context->getProgramiv(program ? program->object() : 0, pname, &value);
+ m_context->getProgramiv(objectOrZero(program), pname, &value);
return WebGLGetInfo(static_cast<long>(value));
default:
m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
@@ -1494,7 +1499,7 @@ String WebGLRenderingContext::getProgramInfoLog(WebGLProgram* program, Exception
if (!validateWebGLObject(program))
return "";
WebGLStateRestorer(this, false);
- return m_context->getProgramInfoLog(program ? program->object() : 0);
+ return m_context->getProgramInfoLog(objectOrZero(program));
}
WebGLGetInfo WebGLRenderingContext::getRenderbufferParameter(unsigned long target, unsigned long pname, ExceptionCode& ec)
@@ -1540,14 +1545,14 @@ WebGLGetInfo WebGLRenderingContext::getShaderParameter(WebGLShader* shader, unsi
switch (pname) {
case GraphicsContext3D::DELETE_STATUS:
case GraphicsContext3D::COMPILE_STATUS:
- m_context->getShaderiv(shader ? shader->object() : 0, pname, &value);
+ m_context->getShaderiv(objectOrZero(shader), pname, &value);
return WebGLGetInfo(static_cast<bool>(value));
case GraphicsContext3D::SHADER_TYPE:
- m_context->getShaderiv(shader ? shader->object() : 0, pname, &value);
+ m_context->getShaderiv(objectOrZero(shader), pname, &value);
return WebGLGetInfo(static_cast<unsigned long>(value));
case GraphicsContext3D::INFO_LOG_LENGTH:
case GraphicsContext3D::SHADER_SOURCE_LENGTH:
- m_context->getShaderiv(shader ? shader->object() : 0, pname, &value);
+ m_context->getShaderiv(objectOrZero(shader), pname, &value);
return WebGLGetInfo(static_cast<long>(value));
default:
m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
@@ -1561,7 +1566,7 @@ String WebGLRenderingContext::getShaderInfoLog(WebGLShader* shader, ExceptionCod
if (!validateWebGLObject(shader))
return "";
WebGLStateRestorer(this, false);
- return m_context->getShaderInfoLog(shader ? shader->object() : 0);
+ return m_context->getShaderInfoLog(objectOrZero(shader));
}
String WebGLRenderingContext::getShaderSource(WebGLShader* shader, ExceptionCode& ec)
@@ -1570,7 +1575,7 @@ String WebGLRenderingContext::getShaderSource(WebGLShader* shader, ExceptionCode
if (!validateWebGLObject(shader))
return "";
WebGLStateRestorer(this, false);
- return m_context->getShaderSource(shader ? shader->object() : 0);
+ return m_context->getShaderSource(objectOrZero(shader));
}
String WebGLRenderingContext::getString(unsigned long name)
@@ -1620,10 +1625,10 @@ WebGLGetInfo WebGLRenderingContext::getUniform(WebGLProgram* program, const WebG
WebGLStateRestorer(this, false);
// FIXME: make this more efficient using WebGLUniformLocation and caching types in it
int activeUniforms = 0;
- m_context->getProgramiv(program ? program->object() : 0, GraphicsContext3D::ACTIVE_UNIFORMS, &activeUniforms);
+ m_context->getProgramiv(objectOrZero(program), GraphicsContext3D::ACTIVE_UNIFORMS, &activeUniforms);
for (int i = 0; i < activeUniforms; i++) {
ActiveInfo info;
- if (!m_context->getActiveUniform(program ? program->object() : 0, i, info))
+ if (!m_context->getActiveUniform(objectOrZero(program), i, info))
return WebGLGetInfo();
// Strip "[0]" from the name if it's an array.
if (info.size > 1)
@@ -1637,7 +1642,7 @@ WebGLGetInfo WebGLRenderingContext::getUniform(WebGLProgram* program, const WebG
name.append(']');
}
// Now need to look this up by name again to find its location
- long loc = m_context->getUniformLocation(program ? program->object() : 0, name);
+ long loc = m_context->getUniformLocation(objectOrZero(program), name);
if (loc == location) {
// Found it. Use the type in the ActiveInfo to determine the return type.
GraphicsContext3D::WebGLEnumType baseType;
@@ -1712,21 +1717,21 @@ WebGLGetInfo WebGLRenderingContext::getUniform(WebGLProgram* program, const WebG
switch (baseType) {
case GraphicsContext3D::FLOAT: {
float value[16] = {0};
- m_context->getUniformfv(program ? program->object() : 0, location, value);
+ m_context->getUniformfv(objectOrZero(program), location, value);
if (length == 1)
return WebGLGetInfo(value[0]);
return WebGLGetInfo(Float32Array::create(value, length));
}
case GraphicsContext3D::INT: {
int value[16] = {0};
- m_context->getUniformiv(program ? program->object() : 0, location, value);
+ m_context->getUniformiv(objectOrZero(program), location, value);
if (length == 1)
return WebGLGetInfo(static_cast<long>(value[0]));
return WebGLGetInfo(Int32Array::create(value, length));
}
case GraphicsContext3D::BOOL: {
int value[16] = {0};
- m_context->getUniformiv(program ? program->object() : 0, location, value);
+ m_context->getUniformiv(objectOrZero(program), location, value);
if (length > 1) {
unsigned char boolValue[16] = {0};
for (unsigned j = 0; j < length; j++)
@@ -1752,7 +1757,7 @@ PassRefPtr<WebGLUniformLocation> WebGLRenderingContext::getUniformLocation(WebGL
if (!validateWebGLObject(program))
return 0;
WebGLStateRestorer(this, false);
- long uniformLocation = m_context->getUniformLocation(program ? program->object() : 0, name);
+ long uniformLocation = m_context->getUniformLocation(objectOrZero(program), name);
if (uniformLocation == -1)
return 0;
return WebGLUniformLocation::create(program, uniformLocation);
@@ -1915,7 +1920,7 @@ void WebGLRenderingContext::linkProgram(WebGLProgram* program, ExceptionCode& ec
program->setLinkFailureFlag(false);
}
- m_context->linkProgram(program ? program->object() : 0);
+ m_context->linkProgram(objectOrZero(program));
program->cacheActiveAttribLocations();
cleanupAfterGraphicsCall(false);
}
@@ -2060,7 +2065,7 @@ void WebGLRenderingContext::shaderSource(WebGLShader* shader, const String& stri
UNUSED_PARAM(ec);
if (!validateWebGLObject(shader))
return;
- m_context->shaderSource(shader ? shader->object() : 0, string);
+ m_context->shaderSource(objectOrZero(shader), string);
cleanupAfterGraphicsCall(false);
}
@@ -2949,7 +2954,7 @@ void WebGLRenderingContext::useProgram(WebGLProgram* program, ExceptionCode& ec)
return;
}
m_currentProgram = program;
- m_context->useProgram(program ? program->object() : 0);
+ m_context->useProgram(objectOrZero(program));
cleanupAfterGraphicsCall(false);
}
@@ -2958,7 +2963,7 @@ void WebGLRenderingContext::validateProgram(WebGLProgram* program, ExceptionCode
UNUSED_PARAM(ec);
if (!validateWebGLObject(program))
return;
- m_context->validateProgram(program ? program->object() : 0);
+ m_context->validateProgram(objectOrZero(program));
cleanupAfterGraphicsCall(false);
}
@@ -3261,9 +3266,9 @@ void WebGLRenderingContext::handleNPOTTextures(bool prepareToDraw)
texCubeMap = m_textureUnits[ii].m_textureCubeMapBinding.get();
}
if (m_textureUnits[ii].m_texture2DBinding && m_textureUnits[ii].m_texture2DBinding->needToUseBlackTexture())
- m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, tex2D->object());
+ m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, objectOrZero(tex2D));
if (m_textureUnits[ii].m_textureCubeMapBinding && m_textureUnits[ii].m_textureCubeMapBinding->needToUseBlackTexture())
- m_context->bindTexture(GraphicsContext3D::TEXTURE_CUBE_MAP, texCubeMap->object());
+ m_context->bindTexture(GraphicsContext3D::TEXTURE_CUBE_MAP, objectOrZero(texCubeMap));
}
}
if (resetActiveUnit)
@@ -3783,10 +3788,10 @@ void WebGLRenderingContext::restoreStatesAfterVertexAttrib0Simulation()
{
const VertexAttribState& state = m_vertexAttribState[0];
if (state.bufferBinding != m_vertexAttrib0Buffer) {
- m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, state.bufferBinding->object());
+ m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, objectOrZero(state.bufferBinding.get()));
m_context->vertexAttribPointer(0, state.size, state.type, state.normalized, state.originalStride, state.offset);
}
- m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, m_boundArrayBuffer->object());
+ m_context->bindBuffer(GraphicsContext3D::ARRAY_BUFFER, objectOrZero(m_boundArrayBuffer.get()));
}
} // namespace WebCore
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list