summaryrefslogtreecommitdiff
path: root/Source/WebCore/html/canvas/WebGLRenderingContext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/html/canvas/WebGLRenderingContext.cpp')
-rw-r--r--Source/WebCore/html/canvas/WebGLRenderingContext.cpp46
1 files changed, 32 insertions, 14 deletions
diff --git a/Source/WebCore/html/canvas/WebGLRenderingContext.cpp b/Source/WebCore/html/canvas/WebGLRenderingContext.cpp
index c0abf0fba..1ee6215fd 100644
--- a/Source/WebCore/html/canvas/WebGLRenderingContext.cpp
+++ b/Source/WebCore/html/canvas/WebGLRenderingContext.cpp
@@ -548,6 +548,7 @@ void WebGLRenderingContext::setupFlags()
m_isGLES2NPOTStrict = !m_context->getExtensions()->isEnabled("GL_ARB_texture_non_power_of_two");
m_isDepthStencilSupported = m_context->getExtensions()->isEnabled("GL_EXT_packed_depth_stencil");
}
+ m_isRobustnessEXTSupported = m_context->getExtensions()->isEnabled("GL_EXT_robustness");
}
bool WebGLRenderingContext::allowPrivilegedExtensions() const
@@ -2975,21 +2976,30 @@ WebGLGetInfo WebGLRenderingContext::getUniform(WebGLProgram* program, const WebG
switch (baseType) {
case GraphicsContext3D::FLOAT: {
GC3Dfloat value[16] = {0};
- m_context->getUniformfv(objectOrZero(program), location, value);
+ if (m_isRobustnessEXTSupported)
+ m_context->getExtensions()->getnUniformfvEXT(objectOrZero(program), location, 16, value);
+ else
+ m_context->getUniformfv(objectOrZero(program), location, value);
if (length == 1)
return WebGLGetInfo(value[0]);
return WebGLGetInfo(Float32Array::create(value, length));
}
case GraphicsContext3D::INT: {
GC3Dint value[4] = {0};
- m_context->getUniformiv(objectOrZero(program), location, value);
+ if (m_isRobustnessEXTSupported)
+ m_context->getExtensions()->getnUniformivEXT(objectOrZero(program), location, 4, value);
+ else
+ m_context->getUniformiv(objectOrZero(program), location, value);
if (length == 1)
return WebGLGetInfo(value[0]);
return WebGLGetInfo(Int32Array::create(value, length));
}
case GraphicsContext3D::BOOL: {
GC3Dint value[4] = {0};
- m_context->getUniformiv(objectOrZero(program), location, value);
+ if (m_isRobustnessEXTSupported)
+ m_context->getExtensions()->getnUniformivEXT(objectOrZero(program), location, 4, value);
+ else
+ m_context->getUniformiv(objectOrZero(program), location, value);
if (length > 1) {
bool boolValue[16] = {0};
for (unsigned j = 0; j < length; j++)
@@ -3290,26 +3300,34 @@ void WebGLRenderingContext::readPixels(GC3Dint x, GC3Dint y, GC3Dsizei width, GC
return;
}
// Calculate array size, taking into consideration of PACK_ALIGNMENT.
- unsigned int totalBytesRequired;
- unsigned int padding;
- GC3Denum error = m_context->computeImageSizeInBytes(format, type, width, height, m_packAlignment, &totalBytesRequired, &padding);
- if (error != GraphicsContext3D::NO_ERROR) {
- synthesizeGLError(error, "readPixels", "invalid dimensions");
- return;
- }
- if (pixels->byteLength() < totalBytesRequired) {
- synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "readPixels", "ArrayBufferView not large enough for dimensions");
- return;
+ unsigned int totalBytesRequired = 0;
+ unsigned int padding = 0;
+ if (!m_isRobustnessEXTSupported) {
+ GC3Denum error = m_context->computeImageSizeInBytes(format, type, width, height, m_packAlignment, &totalBytesRequired, &padding);
+ if (error != GraphicsContext3D::NO_ERROR) {
+ synthesizeGLError(error, "readPixels", "invalid dimensions");
+ return;
+ }
+ if (pixels->byteLength() < totalBytesRequired) {
+ synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "readPixels", "ArrayBufferView not large enough for dimensions");
+ return;
+ }
}
+
clearIfComposited();
void* data = pixels->baseAddress();
{
ScopedDrawingBufferBinder binder(m_drawingBuffer.get(), m_framebufferBinding.get());
- m_context->readPixels(x, y, width, height, format, type, data);
+ if (m_isRobustnessEXTSupported)
+ m_context->getExtensions()->readnPixelsEXT(x, y, width, height, format, type, pixels->byteLength(), data);
+ else
+ m_context->readPixels(x, y, width, height, format, type, data);
}
#if OS(DARWIN) || OS(QNX)
+ if (m_isRobustnessEXTSupported) // we haven't computed padding
+ m_context->computeImageSizeInBytes(format, type, width, height, m_packAlignment, &totalBytesRequired, &padding);
// FIXME: remove this section when GL driver bug on Mac AND the GLES driver bug
// on QC & Imagination QNX is fixed, i.e., when alpha is off, readPixels should
// set alpha to 255 instead of 0.