summaryrefslogtreecommitdiffstats
path: root/WebCore/html/canvas/WebGLRenderingContext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/html/canvas/WebGLRenderingContext.cpp')
-rw-r--r--WebCore/html/canvas/WebGLRenderingContext.cpp207
1 files changed, 174 insertions, 33 deletions
diff --git a/WebCore/html/canvas/WebGLRenderingContext.cpp b/WebCore/html/canvas/WebGLRenderingContext.cpp
index 54ba17f..fe192a6 100644
--- a/WebCore/html/canvas/WebGLRenderingContext.cpp
+++ b/WebCore/html/canvas/WebGLRenderingContext.cpp
@@ -39,7 +39,7 @@
#include "RenderBox.h"
#include "RenderLayer.h"
#include "WebGLActiveInfo.h"
-#include "WebGLUnsignedShortArray.h"
+#include "Uint16Array.h"
#include "WebGLBuffer.h"
#include "WebGLContextAttributes.h"
#include "WebGLFramebuffer.h"
@@ -102,6 +102,8 @@ WebGLRenderingContext::WebGLRenderingContext(HTMLCanvasElement* passedCanvas, Pa
int implementationColorReadType = GraphicsContext3D::UNSIGNED_BYTE;
m_context->getIntegerv(GraphicsContext3D::IMPLEMENTATION_COLOR_READ_TYPE, &implementationColorReadType);
m_implementationColorReadType = implementationColorReadType;
+ if (!isGLES2Compliant())
+ createFallbackBlackTextures1x1();
m_context->reshape(canvas()->width(), canvas()->height());
m_context->viewport(0, 0, canvas()->width(), canvas()->height());
}
@@ -272,6 +274,8 @@ void WebGLRenderingContext::bindTexture(unsigned long target, WebGLTexture* text
return;
}
m_context->bindTexture(target, texture);
+ if (!isGLES2Compliant() && texture)
+ texture->setTarget(target);
cleanupAfterGraphicsCall(false);
}
@@ -328,7 +332,7 @@ void WebGLRenderingContext::bufferData(unsigned long target, int size, unsigned
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::bufferData(unsigned long target, WebGLArray* data, unsigned long usage, ExceptionCode& ec)
+void WebGLRenderingContext::bufferData(unsigned long target, ArrayBufferView* data, unsigned long usage, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
if (target == GraphicsContext3D::ELEMENT_ARRAY_BUFFER && m_boundElementArrayBuffer) {
@@ -350,7 +354,7 @@ void WebGLRenderingContext::bufferData(unsigned long target, WebGLArray* data, u
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::bufferSubData(unsigned long target, long offset, WebGLArray* data, ExceptionCode& ec)
+void WebGLRenderingContext::bufferSubData(unsigned long target, long offset, ArrayBufferView* data, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
if (target == GraphicsContext3D::ELEMENT_ARRAY_BUFFER && m_boundElementArrayBuffer) {
@@ -427,6 +431,28 @@ void WebGLRenderingContext::compileShader(WebGLShader* shader, ExceptionCode& ec
void WebGLRenderingContext::copyTexImage2D(unsigned long target, long level, unsigned long internalformat, long x, long y, unsigned long width, unsigned long height, long border)
{
+ if (!isGLES2Compliant()) {
+ if (level && WebGLTexture::isNPOT(width, height)) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ return;
+ }
+ RefPtr<WebGLTexture> tex = 0;
+ switch (target) {
+ case GraphicsContext3D::TEXTURE_2D:
+ tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding;
+ break;
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_X:
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_X:
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Y:
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Z:
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Z:
+ tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding;
+ break;
+ }
+ if (tex && !level) // only for level 0
+ tex->setSize(target, width, height);
+ }
m_context->copyTexImage2D(target, level, internalformat, x, y, width, height, border);
cleanupAfterGraphicsCall(false);
}
@@ -737,8 +763,10 @@ void WebGLRenderingContext::drawArrays(unsigned long mode, long first, long coun
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
return;
}
-
+
+ handleNPOTTextures(true);
m_context->drawArrays(mode, first, count);
+ handleNPOTTextures(false);
cleanupAfterGraphicsCall(true);
}
@@ -758,8 +786,10 @@ void WebGLRenderingContext::drawElements(unsigned long mode, unsigned long count
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
return;
}
-
+
+ handleNPOTTextures(true);
m_context->drawElements(mode, count, type, offset);
+ handleNPOTTextures(false);
cleanupAfterGraphicsCall(true);
}
@@ -882,6 +912,17 @@ void WebGLRenderingContext::frontFace(unsigned long mode)
void WebGLRenderingContext::generateMipmap(unsigned long target)
{
+ if (!isGLES2Compliant()) {
+ RefPtr<WebGLTexture> tex = 0;
+ if (target == GraphicsContext3D::TEXTURE_2D)
+ tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding;
+ else if (target == GraphicsContext3D::TEXTURE_CUBE_MAP)
+ tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding;
+ if (tex && tex->isNPOT()) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
+ return;
+ }
+ }
m_context->generateMipmap(target);
cleanupAfterGraphicsCall(false);
}
@@ -1410,7 +1451,7 @@ WebGLGetInfo WebGLRenderingContext::getUniform(WebGLProgram* program, const WebG
if (length == 1)
return WebGLGetInfo(value[0]);
else
- return WebGLGetInfo(WebGLFloatArray::create(value, length));
+ return WebGLGetInfo(FloatArray::create(value, length));
}
case GraphicsContext3D::INT: {
int value[16] = {0};
@@ -1418,7 +1459,7 @@ WebGLGetInfo WebGLRenderingContext::getUniform(WebGLProgram* program, const WebG
if (length == 1)
return WebGLGetInfo(static_cast<long>(value[0]));
else
- return WebGLGetInfo(WebGLIntArray::create(value, length));
+ return WebGLGetInfo(Int32Array::create(value, length));
}
case GraphicsContext3D::BOOL: {
int value[16] = {0};
@@ -1429,7 +1470,7 @@ WebGLGetInfo WebGLRenderingContext::getUniform(WebGLProgram* program, const WebG
unsigned char boolValue[16] = {0};
for (unsigned j = 0; j < length; j++)
boolValue[j] = static_cast<bool>(value[j]);
- return WebGLGetInfo(WebGLUnsignedByteArray::create(boolValue, length));
+ return WebGLGetInfo(Uint8Array::create(boolValue, length));
}
}
default:
@@ -1488,7 +1529,7 @@ WebGLGetInfo WebGLRenderingContext::getVertexAttrib(unsigned long index, unsigne
case GraphicsContext3D::CURRENT_VERTEX_ATTRIB: {
float value[4] = {0};
m_context->getVertexAttribfv(index, pname, value);
- return WebGLGetInfo(WebGLFloatArray::create(value, 4));
+ return WebGLGetInfo(FloatArray::create(value, 4));
}
default: {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
@@ -1601,7 +1642,7 @@ void WebGLRenderingContext::polygonOffset(double factor, double units)
cleanupAfterGraphicsCall(false);
}
-PassRefPtr<WebGLArray> WebGLRenderingContext::readPixels(long x, long y, unsigned long width, unsigned long height, unsigned long format, unsigned long type)
+PassRefPtr<ArrayBufferView> WebGLRenderingContext::readPixels(long x, long y, unsigned long width, unsigned long height, unsigned long format, unsigned long type)
{
// Validate enums.
unsigned long componentsPerPixel = 0;
@@ -1649,11 +1690,11 @@ PassRefPtr<WebGLArray> WebGLRenderingContext::readPixels(long x, long y, unsigne
// The last row needs no padding.
unsigned long totalBytes = bytesPerRow * height - padding;
unsigned long num = totalBytes / bytesPerComponent;
- RefPtr<WebGLArray> array;
+ RefPtr<ArrayBufferView> array;
if (type == GraphicsContext3D::UNSIGNED_BYTE)
- array = WebGLUnsignedByteArray::create(num);
+ array = Uint8Array::create(num);
else
- array = WebGLUnsignedShortArray::create(num);
+ array = Uint16Array::create(num);
void* data = array->baseAddress();
m_context->readPixels(x, y, width, height, format, type, data);
#if PLATFORM(CG)
@@ -1765,6 +1806,28 @@ void WebGLRenderingContext::texImage2DBase(unsigned target, unsigned level, unsi
{
// FIXME: For now we ignore any errors returned
ec = 0;
+ if (!isGLES2Compliant()) {
+ if (level && WebGLTexture::isNPOT(width, height)) {
+ m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
+ return;
+ }
+ RefPtr<WebGLTexture> tex = 0;
+ switch (target) {
+ case GraphicsContext3D::TEXTURE_2D:
+ tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding;
+ break;
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_X:
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_X:
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Y:
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Z:
+ case GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Z:
+ tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding;
+ break;
+ }
+ if (tex && !level) // only for level 0
+ tex->setSize(target, width, height);
+ }
m_context->texImage2D(target, level, internalformat, width, height,
border, format, type, pixels);
cleanupAfterGraphicsCall(false);
@@ -1786,7 +1849,7 @@ void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, Image* i
void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, unsigned internalformat,
unsigned width, unsigned height, unsigned border,
- unsigned format, unsigned type, WebGLArray* pixels, ExceptionCode& ec)
+ unsigned format, unsigned type, ArrayBufferView* pixels, ExceptionCode& ec)
{
// FIXME: Need to make sure passed buffer has enough bytes to define the texture
texImage2DBase(target, level, internalformat, width, height, border,
@@ -1894,12 +1957,30 @@ void WebGLRenderingContext::texImage2D(unsigned target, unsigned level, HTMLVide
void WebGLRenderingContext::texParameterf(unsigned target, unsigned pname, float param)
{
m_context->texParameterf(target, pname, param);
+ if (!isGLES2Compliant()) {
+ RefPtr<WebGLTexture> tex = 0;
+ if (target == GraphicsContext3D::TEXTURE_2D)
+ tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding;
+ else if (target == GraphicsContext3D::TEXTURE_CUBE_MAP)
+ tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding;
+ if (tex)
+ tex->setParameterf(pname, param);
+ }
cleanupAfterGraphicsCall(false);
}
void WebGLRenderingContext::texParameteri(unsigned target, unsigned pname, int param)
{
m_context->texParameteri(target, pname, param);
+ if (!isGLES2Compliant()) {
+ RefPtr<WebGLTexture> tex = 0;
+ if (target == GraphicsContext3D::TEXTURE_2D)
+ tex = m_textureUnits[m_activeTextureUnit].m_texture2DBinding;
+ else if (target == GraphicsContext3D::TEXTURE_CUBE_MAP)
+ tex = m_textureUnits[m_activeTextureUnit].m_textureCubeMapBinding;
+ if (tex)
+ tex->setParameteri(pname, param);
+ }
cleanupAfterGraphicsCall(false);
}
@@ -1929,7 +2010,7 @@ void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, unsig
void WebGLRenderingContext::texSubImage2D(unsigned target, unsigned level, unsigned xoffset, unsigned yoffset,
unsigned width, unsigned height,
- unsigned format, unsigned type, WebGLArray* pixels, ExceptionCode& ec)
+ unsigned format, unsigned type, ArrayBufferView* pixels, ExceptionCode& ec)
{
// FIXME: Need to make sure passed buffer has enough bytes to define the texture
texSubImage2DBase(target, level, xoffset, yoffset, width, height, format, type, pixels ? pixels->baseAddress() : 0, ec);
@@ -2052,7 +2133,7 @@ void WebGLRenderingContext::uniform1f(const WebGLUniformLocation* location, floa
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::uniform1fv(const WebGLUniformLocation* location, WebGLFloatArray* v, ExceptionCode& ec)
+void WebGLRenderingContext::uniform1fv(const WebGLUniformLocation* location, FloatArray* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
if (!location) {
@@ -2111,7 +2192,7 @@ void WebGLRenderingContext::uniform1i(const WebGLUniformLocation* location, int
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::uniform1iv(const WebGLUniformLocation* location, WebGLIntArray* v, ExceptionCode& ec)
+void WebGLRenderingContext::uniform1iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
if (!location) {
@@ -2170,7 +2251,7 @@ void WebGLRenderingContext::uniform2f(const WebGLUniformLocation* location, floa
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::uniform2fv(const WebGLUniformLocation* location, WebGLFloatArray* v, ExceptionCode& ec)
+void WebGLRenderingContext::uniform2fv(const WebGLUniformLocation* location, FloatArray* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
if (!location) {
@@ -2231,7 +2312,7 @@ void WebGLRenderingContext::uniform2i(const WebGLUniformLocation* location, int
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::uniform2iv(const WebGLUniformLocation* location, WebGLIntArray* v, ExceptionCode& ec)
+void WebGLRenderingContext::uniform2iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
if (!location) {
@@ -2292,7 +2373,7 @@ void WebGLRenderingContext::uniform3f(const WebGLUniformLocation* location, floa
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::uniform3fv(const WebGLUniformLocation* location, WebGLFloatArray* v, ExceptionCode& ec)
+void WebGLRenderingContext::uniform3fv(const WebGLUniformLocation* location, FloatArray* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
if (!location) {
@@ -2353,7 +2434,7 @@ void WebGLRenderingContext::uniform3i(const WebGLUniformLocation* location, int
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::uniform3iv(const WebGLUniformLocation* location, WebGLIntArray* v, ExceptionCode& ec)
+void WebGLRenderingContext::uniform3iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
if (!location) {
@@ -2414,7 +2495,7 @@ void WebGLRenderingContext::uniform4f(const WebGLUniformLocation* location, floa
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::uniform4fv(const WebGLUniformLocation* location, WebGLFloatArray* v, ExceptionCode& ec)
+void WebGLRenderingContext::uniform4fv(const WebGLUniformLocation* location, FloatArray* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
if (!location) {
@@ -2475,7 +2556,7 @@ void WebGLRenderingContext::uniform4i(const WebGLUniformLocation* location, int
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::uniform4iv(const WebGLUniformLocation* location, WebGLIntArray* v, ExceptionCode& ec)
+void WebGLRenderingContext::uniform4iv(const WebGLUniformLocation* location, Int32Array* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
if (!location) {
@@ -2519,7 +2600,7 @@ void WebGLRenderingContext::uniform4iv(const WebGLUniformLocation* location, int
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::uniformMatrix2fv(const WebGLUniformLocation* location, bool transpose, WebGLFloatArray* v, ExceptionCode& ec)
+void WebGLRenderingContext::uniformMatrix2fv(const WebGLUniformLocation* location, bool transpose, FloatArray* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
if (!location) {
@@ -2563,7 +2644,7 @@ void WebGLRenderingContext::uniformMatrix2fv(const WebGLUniformLocation* locatio
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::uniformMatrix3fv(const WebGLUniformLocation* location, bool transpose, WebGLFloatArray* v, ExceptionCode& ec)
+void WebGLRenderingContext::uniformMatrix3fv(const WebGLUniformLocation* location, bool transpose, FloatArray* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
if (!location) {
@@ -2607,7 +2688,7 @@ void WebGLRenderingContext::uniformMatrix3fv(const WebGLUniformLocation* locatio
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::uniformMatrix4fv(const WebGLUniformLocation* location, bool transpose, WebGLFloatArray* v, ExceptionCode& ec)
+void WebGLRenderingContext::uniformMatrix4fv(const WebGLUniformLocation* location, bool transpose, FloatArray* v, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
if (!location) {
@@ -2682,7 +2763,7 @@ void WebGLRenderingContext::vertexAttrib1f(unsigned long indx, float v0)
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::vertexAttrib1fv(unsigned long indx, WebGLFloatArray* v)
+void WebGLRenderingContext::vertexAttrib1fv(unsigned long indx, FloatArray* v)
{
// FIXME: Need to make sure array is big enough for attribute being set
m_context->vertexAttrib1fv(indx, v->data());
@@ -2704,7 +2785,7 @@ void WebGLRenderingContext::vertexAttrib2f(unsigned long indx, float v0, float v
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::vertexAttrib2fv(unsigned long indx, WebGLFloatArray* v)
+void WebGLRenderingContext::vertexAttrib2fv(unsigned long indx, FloatArray* v)
{
// FIXME: Need to make sure array is big enough for attribute being set
m_context->vertexAttrib2fv(indx, v->data());
@@ -2726,7 +2807,7 @@ void WebGLRenderingContext::vertexAttrib3f(unsigned long indx, float v0, float v
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::vertexAttrib3fv(unsigned long indx, WebGLFloatArray* v)
+void WebGLRenderingContext::vertexAttrib3fv(unsigned long indx, FloatArray* v)
{
// FIXME: Need to make sure array is big enough for attribute being set
m_context->vertexAttrib3fv(indx, v->data());
@@ -2748,7 +2829,7 @@ void WebGLRenderingContext::vertexAttrib4f(unsigned long indx, float v0, float v
cleanupAfterGraphicsCall(false);
}
-void WebGLRenderingContext::vertexAttrib4fv(unsigned long indx, WebGLFloatArray* v)
+void WebGLRenderingContext::vertexAttrib4fv(unsigned long indx, FloatArray* v)
{
// FIXME: Need to make sure array is big enough for attribute being set
m_context->vertexAttrib4fv(indx, v->data());
@@ -2911,7 +2992,7 @@ WebGLGetInfo WebGLRenderingContext::getWebGLFloatArrayParameter(unsigned long pn
default:
notImplemented();
}
- return WebGLGetInfo(WebGLFloatArray::create(value, length));
+ return WebGLGetInfo(FloatArray::create(value, length));
}
WebGLGetInfo WebGLRenderingContext::getWebGLIntArrayParameter(unsigned long pname)
@@ -2930,7 +3011,7 @@ WebGLGetInfo WebGLRenderingContext::getWebGLIntArrayParameter(unsigned long pnam
default:
notImplemented();
}
- return WebGLGetInfo(WebGLIntArray::create(value, length));
+ return WebGLGetInfo(Int32Array::create(value, length));
}
WebGLGetInfo WebGLRenderingContext::getWebGLUnsignedByteArrayParameter(unsigned long pname)
@@ -2945,7 +3026,7 @@ WebGLGetInfo WebGLRenderingContext::getWebGLUnsignedByteArrayParameter(unsigned
default:
notImplemented();
}
- return WebGLGetInfo(WebGLUnsignedByteArray::create(value, length));
+ return WebGLGetInfo(Uint8Array::create(value, length));
}
bool WebGLRenderingContext::isGLES2Compliant()
@@ -2953,6 +3034,66 @@ bool WebGLRenderingContext::isGLES2Compliant()
return m_context->isGLES2Compliant();
}
+void WebGLRenderingContext::handleNPOTTextures(bool prepareToDraw)
+{
+ if (isGLES2Compliant())
+ return;
+ bool resetActiveUnit = false;
+ // FIXME: active texture unit limits should be queries instead of 32.
+ for (unsigned long ii = 0; ii < 32; ++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 (ii != m_activeTextureUnit) {
+ m_context->activeTexture(ii);
+ resetActiveUnit = true;
+ } else if (resetActiveUnit) {
+ m_context->activeTexture(ii);
+ resetActiveUnit = false;
+ }
+ WebGLTexture* tex2D;
+ WebGLTexture* texCubeMap;
+ if (prepareToDraw) {
+ tex2D = m_blackTexture2D.get();
+ texCubeMap = m_blackTextureCubeMap.get();
+ } else {
+ 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())
+ m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, tex2D);
+ if (m_textureUnits[ii].m_textureCubeMapBinding && m_textureUnits[ii].m_textureCubeMapBinding->needToUseBlackTexture())
+ m_context->bindTexture(GraphicsContext3D::TEXTURE_CUBE_MAP, texCubeMap);
+ }
+ }
+ if (resetActiveUnit)
+ m_context->activeTexture(m_activeTextureUnit);
+}
+
+void WebGLRenderingContext::createFallbackBlackTextures1x1()
+{
+ unsigned char black[] = {0, 0, 0, 255};
+ m_blackTexture2D = createTexture();
+ m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_blackTexture2D.get());
+ m_context->texImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, 1, 1,
+ 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, black);
+ m_context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0);
+ m_blackTextureCubeMap = createTexture();
+ m_context->bindTexture(GraphicsContext3D::TEXTURE_CUBE_MAP, m_blackTextureCubeMap.get());
+ m_context->texImage2D(GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_X, 0, GraphicsContext3D::RGBA, 1, 1,
+ 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, black);
+ m_context->texImage2D(GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GraphicsContext3D::RGBA, 1, 1,
+ 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, black);
+ m_context->texImage2D(GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GraphicsContext3D::RGBA, 1, 1,
+ 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, black);
+ m_context->texImage2D(GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GraphicsContext3D::RGBA, 1, 1,
+ 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, black);
+ m_context->texImage2D(GraphicsContext3D::TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GraphicsContext3D::RGBA, 1, 1,
+ 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, black);
+ m_context->texImage2D(GraphicsContext3D::TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GraphicsContext3D::RGBA, 1, 1,
+ 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, black);
+ m_context->bindTexture(GraphicsContext3D::TEXTURE_CUBE_MAP, 0);
+}
+
} // namespace WebCore
#endif // ENABLE(3D_CANVAS)