OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 1870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1881 | 1881 |
1882 if (!validateTexFuncLevel("compressedTexImage2D", target, level)) | 1882 if (!validateTexFuncLevel("compressedTexImage2D", target, level)) |
1883 return; | 1883 return; |
1884 | 1884 |
1885 if (!validateCompressedTexFormat("compressedTexImage2D", internalformat)) | 1885 if (!validateCompressedTexFormat("compressedTexImage2D", internalformat)) |
1886 return; | 1886 return; |
1887 if (border) { | 1887 if (border) { |
1888 synthesizeGLError(GL_INVALID_VALUE, "compressedTexImage2D", "border not
0"); | 1888 synthesizeGLError(GL_INVALID_VALUE, "compressedTexImage2D", "border not
0"); |
1889 return; | 1889 return; |
1890 } | 1890 } |
1891 if (!validateCompressedTexDimensions("compressedTexImage2D", NotTexSubImage2
D, target, level, width, height, 1, internalformat)) | 1891 if (!validateCompressedTexDimensions("compressedTexImage2D", NotTexSubImage,
target, level, width, height, 1, internalformat)) |
1892 return; | 1892 return; |
1893 if (!validateCompressedTexFuncData("compressedTexImage2D", width, height, 1,
internalformat, data)) | 1893 if (!validateCompressedTexFuncData("compressedTexImage2D", width, height, 1,
internalformat, data)) |
1894 return; | 1894 return; |
1895 | 1895 |
1896 if (tex->isImmutable()) { | 1896 if (tex->isImmutable()) { |
1897 synthesizeGLError(GL_INVALID_OPERATION, "compressedTexImage2D", "attempt
ed to modify immutable texture"); | 1897 synthesizeGLError(GL_INVALID_OPERATION, "compressedTexImage2D", "attempt
ed to modify immutable texture"); |
1898 return; | 1898 return; |
1899 } | 1899 } |
1900 if (isNPOTStrict() && level && WebGLTexture::isNPOT(width, height)) { | 1900 if (isNPOTStrict() && level && WebGLTexture::isNPOT(width, height)) { |
1901 synthesizeGLError(GL_INVALID_VALUE, "compressedTexImage2D", "level > 0 n
ot power of 2"); | 1901 synthesizeGLError(GL_INVALID_VALUE, "compressedTexImage2D", "level > 0 n
ot power of 2"); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1940 } | 1940 } |
1941 return true; | 1941 return true; |
1942 } | 1942 } |
1943 | 1943 |
1944 void WebGLRenderingContextBase::copyTexImage2D(GLenum target, GLint level, GLenu
m internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) | 1944 void WebGLRenderingContextBase::copyTexImage2D(GLenum target, GLint level, GLenu
m internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) |
1945 { | 1945 { |
1946 if (isContextLost()) | 1946 if (isContextLost()) |
1947 return; | 1947 return; |
1948 if (!validateTexFuncLevel("copyTexImage2D", target, level)) | 1948 if (!validateTexFuncLevel("copyTexImage2D", target, level)) |
1949 return; | 1949 return; |
1950 if (!validateTexFuncParameters("copyTexImage2D", NotTexSubImage2D, target, l
evel, internalformat, width, height, 1, border, internalformat, GL_UNSIGNED_BYTE
)) | 1950 if (!validateTexFuncParameters("copyTexImage2D", NotTexSubImage, target, lev
el, internalformat, width, height, 1, border, internalformat, GL_UNSIGNED_BYTE)) |
1951 return; | 1951 return; |
1952 if (!validateSettableTexFormat("copyTexImage2D", internalformat)) | 1952 if (!validateSettableTexFormat("copyTexImage2D", internalformat)) |
1953 return; | 1953 return; |
1954 WebGLTexture* tex = validateTextureBinding("copyTexImage2D", target, true); | 1954 WebGLTexture* tex = validateTextureBinding("copyTexImage2D", target, true); |
1955 if (!tex) | 1955 if (!tex) |
1956 return; | 1956 return; |
1957 if (tex->isImmutable()) { | 1957 if (tex->isImmutable()) { |
1958 synthesizeGLError(GL_INVALID_OPERATION, "copyTexImage2D", "attempted to
modify immutable texture"); | 1958 synthesizeGLError(GL_INVALID_OPERATION, "copyTexImage2D", "attempted to
modify immutable texture"); |
1959 return; | 1959 return; |
1960 } | 1960 } |
(...skipping 2251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4212 } | 4212 } |
4213 | 4213 |
4214 bool WebGLRenderingContextBase::validateTexFunc(const char* functionName, TexIma
geFunctionType functionType, TexFuncValidationSourceType sourceType, GLenum targ
et, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei d
epth, GLint border, GLenum format, GLenum type, GLint xoffset, GLint yoffset, GL
int zoffset) | 4214 bool WebGLRenderingContextBase::validateTexFunc(const char* functionName, TexIma
geFunctionType functionType, TexFuncValidationSourceType sourceType, GLenum targ
et, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei d
epth, GLint border, GLenum format, GLenum type, GLint xoffset, GLint yoffset, GL
int zoffset) |
4215 { | 4215 { |
4216 if (!validateTexFuncLevel(functionName, target, level)) | 4216 if (!validateTexFuncLevel(functionName, target, level)) |
4217 return false; | 4217 return false; |
4218 WebGLTexture* texture = validateTextureBinding(functionName, target, true); | 4218 WebGLTexture* texture = validateTextureBinding(functionName, target, true); |
4219 if (!texture) | 4219 if (!texture) |
4220 return false; | 4220 return false; |
4221 | 4221 |
4222 if (functionType == TexSubImage2D) { | 4222 if (functionType == TexSubImage) { |
4223 if (!texture->isValid(target, level)) { | 4223 if (!texture->isValid(target, level)) { |
4224 synthesizeGLError(GL_INVALID_OPERATION, "texSubImage2D", "no previou
sly defined texture image"); | 4224 synthesizeGLError(GL_INVALID_OPERATION, functionName, "no previously
defined texture image"); |
4225 return false; | 4225 return false; |
4226 } | 4226 } |
4227 } | 4227 } |
4228 | 4228 |
4229 if (internalformat == 0) | 4229 if (internalformat == 0) |
4230 internalformat = texture->getInternalFormat(target, level); | 4230 internalformat = texture->getInternalFormat(target, level); |
4231 if (!validateTexFuncParameters(functionName, functionType, target, level, in
ternalformat, width, height, depth, border, format, type)) | 4231 if (!validateTexFuncParameters(functionName, functionType, target, level, in
ternalformat, width, height, depth, border, format, type)) |
4232 return false; | 4232 return false; |
4233 | 4233 |
4234 if (functionType == NotTexSubImage2D) { | 4234 if (functionType == NotTexSubImage) { |
4235 if (texture->isImmutable()) { | 4235 if (texture->isImmutable()) { |
4236 synthesizeGLError(GL_INVALID_OPERATION, functionName, "attempted to
modify immutable texture"); | 4236 synthesizeGLError(GL_INVALID_OPERATION, functionName, "attempted to
modify immutable texture"); |
4237 return false; | 4237 return false; |
4238 } | 4238 } |
4239 | 4239 |
4240 // Depth is for WebGL 2.0 only where iSNPOTStrict() is always false. | 4240 // Depth is for WebGL 2.0 only where iSNPOTStrict() is always false. |
4241 if (isNPOTStrict() && level && WebGLTexture::isNPOT(width, height)) { | 4241 if (isNPOTStrict() && level && WebGLTexture::isNPOT(width, height)) { |
4242 synthesizeGLError(GL_INVALID_VALUE, functionName, "level > 0 not pow
er of 2"); | 4242 synthesizeGLError(GL_INVALID_VALUE, functionName, "level > 0 not pow
er of 2"); |
4243 return false; | 4243 return false; |
4244 } | 4244 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4311 IntRect destRect(0, 0, size.width(), size.height()); | 4311 IntRect destRect(0, 0, size.width(), size.height()); |
4312 SkPaint paint; | 4312 SkPaint paint; |
4313 image->draw(buf->canvas(), paint, destRect, srcRect, DoNotRespectImageOrient
ation, Image::DoNotClampImageToSourceRect); | 4313 image->draw(buf->canvas(), paint, destRect, srcRect, DoNotRespectImageOrient
ation, Image::DoNotClampImageToSourceRect); |
4314 return buf->newImageSnapshot(); | 4314 return buf->newImageSnapshot(); |
4315 } | 4315 } |
4316 | 4316 |
4317 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in
ternalformat, | 4317 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in
ternalformat, |
4318 GLsizei width, GLsizei height, GLint border, | 4318 GLsizei width, GLsizei height, GLint border, |
4319 GLenum format, GLenum type, DOMArrayBufferView* pixels) | 4319 GLenum format, GLenum type, DOMArrayBufferView* pixels) |
4320 { | 4320 { |
4321 if (isContextLost() || !validateTexFunc("texImage2D", NotTexSubImage2D, Sour
ceArrayBufferView, target, level, internalformat, width, height, 1, border, form
at, type, 0, 0, 0) | 4321 if (isContextLost() || !validateTexFunc("texImage2D", NotTexSubImage, Source
ArrayBufferView, target, level, internalformat, width, height, 1, border, format
, type, 0, 0, 0) |
4322 || !validateTexFuncData("texImage2D", level, width, height, 1, format, t
ype, pixels, NullAllowed)) | 4322 || !validateTexFuncData("texImage2D", level, width, height, 1, format, t
ype, pixels, NullAllowed)) |
4323 return; | 4323 return; |
4324 void* data = pixels ? pixels->baseAddress() : 0; | 4324 void* data = pixels ? pixels->baseAddress() : 0; |
4325 Vector<uint8_t> tempData; | 4325 Vector<uint8_t> tempData; |
4326 bool changeUnpackAlignment = false; | 4326 bool changeUnpackAlignment = false; |
4327 if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) { | 4327 if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) { |
4328 if (!WebGLImageConversion::extractTextureData(width, height, format, typ
e, m_unpackAlignment, m_unpackFlipY, m_unpackPremultiplyAlpha, data, tempData)) | 4328 if (!WebGLImageConversion::extractTextureData(width, height, format, typ
e, m_unpackAlignment, m_unpackFlipY, m_unpackPremultiplyAlpha, data, tempData)) |
4329 return; | 4329 return; |
4330 data = tempData.data(); | 4330 data = tempData.data(); |
4331 changeUnpackAlignment = true; | 4331 changeUnpackAlignment = true; |
4332 } | 4332 } |
4333 if (changeUnpackAlignment) | 4333 if (changeUnpackAlignment) |
4334 resetUnpackParameters(); | 4334 resetUnpackParameters(); |
4335 texImage2DBase(target, level, internalformat, width, height, border, format,
type, data); | 4335 texImage2DBase(target, level, internalformat, width, height, border, format,
type, data); |
4336 if (changeUnpackAlignment) | 4336 if (changeUnpackAlignment) |
4337 restoreUnpackParameters(); | 4337 restoreUnpackParameters(); |
4338 } | 4338 } |
4339 | 4339 |
4340 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in
ternalformat, | 4340 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in
ternalformat, |
4341 GLenum format, GLenum type, ImageData* pixels) | 4341 GLenum format, GLenum type, ImageData* pixels) |
4342 { | 4342 { |
4343 if (!pixels) { | 4343 if (!pixels) { |
4344 synthesizeGLError(GL_INVALID_VALUE, "texImage2D", "no image data"); | 4344 synthesizeGLError(GL_INVALID_VALUE, "texImage2D", "no image data"); |
4345 return; | 4345 return; |
4346 } | 4346 } |
4347 if (pixels->data()->bufferBase()->isNeutered()) { | 4347 if (pixels->data()->bufferBase()->isNeutered()) { |
4348 synthesizeGLError(GL_INVALID_VALUE, "texImage2D", "The source data has b
een neutered."); | 4348 synthesizeGLError(GL_INVALID_VALUE, "texImage2D", "The source data has b
een neutered."); |
4349 return; | 4349 return; |
4350 } | 4350 } |
4351 if (isContextLost() || !validateTexFunc("texImage2D", NotTexSubImage2D, Sour
ceImageData, target, level, internalformat, pixels->width(), pixels->height(), 1
, 0, format, type, 0, 0, 0)) | 4351 if (isContextLost() || !validateTexFunc("texImage2D", NotTexSubImage, Source
ImageData, target, level, internalformat, pixels->width(), pixels->height(), 1,
0, format, type, 0, 0, 0)) |
4352 return; | 4352 return; |
4353 if (type == GL_UNSIGNED_INT_10F_11F_11F_REV) { | 4353 if (type == GL_UNSIGNED_INT_10F_11F_11F_REV) { |
4354 // The UNSIGNED_INT_10F_11F_11F_REV type pack/unpack isn't implemented. | 4354 // The UNSIGNED_INT_10F_11F_11F_REV type pack/unpack isn't implemented. |
4355 type = GL_FLOAT; | 4355 type = GL_FLOAT; |
4356 } | 4356 } |
4357 Vector<uint8_t> data; | 4357 Vector<uint8_t> data; |
4358 bool needConversion = true; | 4358 bool needConversion = true; |
4359 // The data from ImageData is always of format RGBA8. | 4359 // The data from ImageData is always of format RGBA8. |
4360 // No conversion is needed if destination format is RGBA and type is USIGNED
_BYTE and no Flip or Premultiply operation is required. | 4360 // No conversion is needed if destination format is RGBA and type is USIGNED
_BYTE and no Flip or Premultiply operation is required. |
4361 if (!m_unpackFlipY && !m_unpackPremultiplyAlpha && format == GL_RGBA && type
== GL_UNSIGNED_BYTE) { | 4361 if (!m_unpackFlipY && !m_unpackPremultiplyAlpha && format == GL_RGBA && type
== GL_UNSIGNED_BYTE) { |
(...skipping 16 matching lines...) Expand all Loading... |
4378 return; | 4378 return; |
4379 if (type == GL_UNSIGNED_INT_10F_11F_11F_REV) { | 4379 if (type == GL_UNSIGNED_INT_10F_11F_11F_REV) { |
4380 // The UNSIGNED_INT_10F_11F_11F_REV type pack/unpack isn't implemented. | 4380 // The UNSIGNED_INT_10F_11F_11F_REV type pack/unpack isn't implemented. |
4381 type = GL_FLOAT; | 4381 type = GL_FLOAT; |
4382 } | 4382 } |
4383 | 4383 |
4384 RefPtr<Image> imageForRender = image->cachedImage()->image(); | 4384 RefPtr<Image> imageForRender = image->cachedImage()->image(); |
4385 if (imageForRender && imageForRender->isSVGImage()) | 4385 if (imageForRender && imageForRender->isSVGImage()) |
4386 imageForRender = drawImageIntoBuffer(imageForRender.release(), image->wi
dth(), image->height(), "texImage2D"); | 4386 imageForRender = drawImageIntoBuffer(imageForRender.release(), image->wi
dth(), image->height(), "texImage2D"); |
4387 | 4387 |
4388 if (!imageForRender || !validateTexFunc("texImage2D", NotTexSubImage2D, Sour
ceHTMLImageElement, target, level, internalformat, imageForRender->width(), imag
eForRender->height(), 1, 0, format, type, 0, 0, 0)) | 4388 if (!imageForRender || !validateTexFunc("texImage2D", NotTexSubImage, Source
HTMLImageElement, target, level, internalformat, imageForRender->width(), imageF
orRender->height(), 1, 0, format, type, 0, 0, 0)) |
4389 return; | 4389 return; |
4390 | 4390 |
4391 texImage2DImpl(target, level, internalformat, format, type, imageForRender.g
et(), WebGLImageConversion::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlph
a); | 4391 texImage2DImpl(target, level, internalformat, format, type, imageForRender.g
et(), WebGLImageConversion::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlph
a); |
4392 } | 4392 } |
4393 | 4393 |
4394 bool WebGLRenderingContextBase::canUseTexImageCanvasByGPU(GLenum internalformat,
GLenum type) | 4394 bool WebGLRenderingContextBase::canUseTexImageCanvasByGPU(GLenum internalformat,
GLenum type) |
4395 { | 4395 { |
4396 if (isFloatType(type) || isIntegerFormat(internalformat) || isSRGBFormat(int
ernalformat)) | 4396 if (isFloatType(type) || isIntegerFormat(internalformat) || isSRGBFormat(int
ernalformat)) |
4397 return false; | 4397 return false; |
4398 return true; | 4398 return true; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4457 webContext()->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, 0, 0); | 4457 webContext()->framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, 0, 0); |
4458 restoreCurrentFramebuffer(); | 4458 restoreCurrentFramebuffer(); |
4459 webContext()->deleteFramebuffer(tmpFBO); | 4459 webContext()->deleteFramebuffer(tmpFBO); |
4460 webContext()->deleteTexture(targetTexture); | 4460 webContext()->deleteTexture(targetTexture); |
4461 } | 4461 } |
4462 } | 4462 } |
4463 | 4463 |
4464 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in
ternalformat, | 4464 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in
ternalformat, |
4465 GLenum format, GLenum type, HTMLCanvasElement* canvas, ExceptionState& excep
tionState) | 4465 GLenum format, GLenum type, HTMLCanvasElement* canvas, ExceptionState& excep
tionState) |
4466 { | 4466 { |
4467 if (isContextLost() || !validateHTMLCanvasElement("texImage2D", canvas, exce
ptionState) || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLCanvas
Element, target, level, internalformat, canvas->width(), canvas->height(), 1, 0,
format, type, 0, 0, 0)) | 4467 if (isContextLost() || !validateHTMLCanvasElement("texImage2D", canvas, exce
ptionState) || !validateTexFunc("texImage2D", NotTexSubImage, SourceHTMLCanvasEl
ement, target, level, internalformat, canvas->width(), canvas->height(), 1, 0, f
ormat, type, 0, 0, 0)) |
4468 return; | 4468 return; |
4469 | 4469 |
4470 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); | 4470 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); |
4471 ASSERT(texture); | 4471 ASSERT(texture); |
4472 | 4472 |
4473 // texImageCanvasByGPU relies on copyTextureCHROMIUM which doesn't support f
loat/integer/sRGB internal format. | 4473 // texImageCanvasByGPU relies on copyTextureCHROMIUM which doesn't support f
loat/integer/sRGB internal format. |
4474 // FIXME: relax the constrains if copyTextureCHROMIUM is upgraded to handle
more formats. | 4474 // FIXME: relax the constrains if copyTextureCHROMIUM is upgraded to handle
more formats. |
4475 if (!canvas->renderingContext() || !canvas->renderingContext()->isAccelerate
d() || !canUseTexImageCanvasByGPU(internalformat, type)) { | 4475 if (!canvas->renderingContext() || !canvas->renderingContext()->isAccelerate
d() || !canUseTexImageCanvasByGPU(internalformat, type)) { |
4476 // 2D canvas has only FrontBuffer. | 4476 // 2D canvas has only FrontBuffer. |
4477 texImage2DImpl(target, level, internalformat, format, type, canvas->copi
edImage(FrontBuffer, PreferAcceleration).get(), | 4477 texImage2DImpl(target, level, internalformat, format, type, canvas->copi
edImage(FrontBuffer, PreferAcceleration).get(), |
(...skipping 15 matching lines...) Expand all Loading... |
4493 } | 4493 } |
4494 IntRect destRect(0, 0, size.width(), size.height()); | 4494 IntRect destRect(0, 0, size.width(), size.height()); |
4495 video->paintCurrentFrame(buf->canvas(), destRect, nullptr); | 4495 video->paintCurrentFrame(buf->canvas(), destRect, nullptr); |
4496 return buf->newImageSnapshot(); | 4496 return buf->newImageSnapshot(); |
4497 } | 4497 } |
4498 | 4498 |
4499 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in
ternalformat, | 4499 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in
ternalformat, |
4500 GLenum format, GLenum type, HTMLVideoElement* video, ExceptionState& excepti
onState) | 4500 GLenum format, GLenum type, HTMLVideoElement* video, ExceptionState& excepti
onState) |
4501 { | 4501 { |
4502 if (isContextLost() || !validateHTMLVideoElement("texImage2D", video, except
ionState) | 4502 if (isContextLost() || !validateHTMLVideoElement("texImage2D", video, except
ionState) |
4503 || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceHTMLVideoEleme
nt, target, level, internalformat, video->videoWidth(), video->videoHeight(), 1,
0, format, type, 0, 0, 0)) | 4503 || !validateTexFunc("texImage2D", NotTexSubImage, SourceHTMLVideoElement
, target, level, internalformat, video->videoWidth(), video->videoHeight(), 1, 0
, format, type, 0, 0, 0)) |
4504 return; | 4504 return; |
4505 | 4505 |
4506 // Go through the fast path doing a GPU-GPU textures copy without a readback
to system memory if possible. | 4506 // Go through the fast path doing a GPU-GPU textures copy without a readback
to system memory if possible. |
4507 // Otherwise, it will fall back to the normal SW path. | 4507 // Otherwise, it will fall back to the normal SW path. |
4508 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); | 4508 WebGLTexture* texture = validateTextureBinding("texImage2D", target, true); |
4509 ASSERT(texture); | 4509 ASSERT(texture); |
4510 if (GL_TEXTURE_2D == target) { | 4510 if (GL_TEXTURE_2D == target) { |
4511 if (Extensions3DUtil::canUseCopyTextureCHROMIUM(target, internalformat,
type, level) | 4511 if (Extensions3DUtil::canUseCopyTextureCHROMIUM(target, internalformat,
type, level) |
4512 && video->copyVideoTextureToPlatformTexture(webContext(), texture->o
bject(), internalformat, type, m_unpackPremultiplyAlpha, m_unpackFlipY)) { | 4512 && video->copyVideoTextureToPlatformTexture(webContext(), texture->o
bject(), internalformat, type, m_unpackPremultiplyAlpha, m_unpackFlipY)) { |
4513 texture->setLevelInfo(target, level, internalformat, video->videoWid
th(), video->videoHeight(), 1, type); | 4513 texture->setLevelInfo(target, level, internalformat, video->videoWid
th(), video->videoHeight(), 1, type); |
(...skipping 28 matching lines...) Expand all Loading... |
4542 } | 4542 } |
4543 | 4543 |
4544 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in
ternalformat, | 4544 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in
ternalformat, |
4545 GLenum format, GLenum type, PassRefPtrWillBeRawPtr<ImageBitmap> bitmap) | 4545 GLenum format, GLenum type, PassRefPtrWillBeRawPtr<ImageBitmap> bitmap) |
4546 { | 4546 { |
4547 ASSERT(bitmap->bitmapImage()); | 4547 ASSERT(bitmap->bitmapImage()); |
4548 if (bitmap->isNeutered()) { | 4548 if (bitmap->isNeutered()) { |
4549 synthesizeGLError(GL_INVALID_VALUE, "texImage2D", "The source data has b
een neutered."); | 4549 synthesizeGLError(GL_INVALID_VALUE, "texImage2D", "The source data has b
een neutered."); |
4550 return; | 4550 return; |
4551 } | 4551 } |
4552 if (isContextLost() || !validateTexFunc("texImage2D", NotTexSubImage2D, Sour
ceImageBitmap, target, level, 0, bitmap->width(), bitmap->height(), 1, 0, format
, type, 0, 0, 0)) | 4552 if (isContextLost() || !validateTexFunc("texImage2D", NotTexSubImage, Source
ImageBitmap, target, level, 0, bitmap->width(), bitmap->height(), 1, 0, format,
type, 0, 0, 0)) |
4553 return; | 4553 return; |
4554 StaticBitmapImage* imageForRender = bitmap->bitmapImage(); | 4554 StaticBitmapImage* imageForRender = bitmap->bitmapImage(); |
4555 texImage2DImpl(target, level, internalformat, format, type, imageForRender,
WebGLImageConversion::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha); | 4555 texImage2DImpl(target, level, internalformat, format, type, imageForRender,
WebGLImageConversion::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha); |
4556 } | 4556 } |
4557 | 4557 |
4558 void WebGLRenderingContextBase::texParameter(GLenum target, GLenum pname, GLfloa
t paramf, GLint parami, bool isFloat) | 4558 void WebGLRenderingContextBase::texParameter(GLenum target, GLenum pname, GLfloa
t paramf, GLint parami, bool isFloat) |
4559 { | 4559 { |
4560 if (isContextLost()) | 4560 if (isContextLost()) |
4561 return; | 4561 return; |
4562 WebGLTexture* tex = validateTextureBinding("texParameter", target, false); | 4562 WebGLTexture* tex = validateTextureBinding("texParameter", target, false); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4649 | 4649 |
4650 resetUnpackParameters(); | 4650 resetUnpackParameters(); |
4651 webContext()->texSubImage2D(target, level, xoffset, yoffset, imageExtractor.
imageWidth(), imageExtractor.imageHeight(), format, type, needConversion ? data
.data() : imagePixelData); | 4651 webContext()->texSubImage2D(target, level, xoffset, yoffset, imageExtractor.
imageWidth(), imageExtractor.imageHeight(), format, type, needConversion ? data
.data() : imagePixelData); |
4652 restoreUnpackParameters(); | 4652 restoreUnpackParameters(); |
4653 } | 4653 } |
4654 | 4654 |
4655 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint
xoffset, GLint yoffset, | 4655 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint
xoffset, GLint yoffset, |
4656 GLsizei width, GLsizei height, | 4656 GLsizei width, GLsizei height, |
4657 GLenum format, GLenum type, DOMArrayBufferView* pixels) | 4657 GLenum format, GLenum type, DOMArrayBufferView* pixels) |
4658 { | 4658 { |
4659 if (isContextLost() || !validateTexFunc("texSubImage2D", TexSubImage2D, Sour
ceArrayBufferView, target, level, 0, width, height, 1, 0, format, type, xoffset,
yoffset, 0) | 4659 if (isContextLost() || !validateTexFunc("texSubImage2D", TexSubImage, Source
ArrayBufferView, target, level, 0, width, height, 1, 0, format, type, xoffset, y
offset, 0) |
4660 || !validateTexFuncData("texSubImage2D", level, width, height, 1, format
, type, pixels, NullNotAllowed)) | 4660 || !validateTexFuncData("texSubImage2D", level, width, height, 1, format
, type, pixels, NullNotAllowed)) |
4661 return; | 4661 return; |
4662 void* data = pixels->baseAddress(); | 4662 void* data = pixels->baseAddress(); |
4663 Vector<uint8_t> tempData; | 4663 Vector<uint8_t> tempData; |
4664 bool changeUnpackAlignment = false; | 4664 bool changeUnpackAlignment = false; |
4665 if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) { | 4665 if (data && (m_unpackFlipY || m_unpackPremultiplyAlpha)) { |
4666 if (!WebGLImageConversion::extractTextureData(width, height, format, typ
e, | 4666 if (!WebGLImageConversion::extractTextureData(width, height, format, typ
e, |
4667 m_unpackAlignment, m_unpackFlipY, m_unpackPremultiplyAlpha, data, te
mpData)) | 4667 m_unpackAlignment, m_unpackFlipY, m_unpackPremultiplyAlpha, data, te
mpData)) |
4668 return; | 4668 return; |
4669 data = tempData.data(); | 4669 data = tempData.data(); |
(...skipping 10 matching lines...) Expand all Loading... |
4680 GLenum format, GLenum type, ImageData* pixels) | 4680 GLenum format, GLenum type, ImageData* pixels) |
4681 { | 4681 { |
4682 if (!pixels) { | 4682 if (!pixels) { |
4683 synthesizeGLError(GL_INVALID_VALUE, "texSubImage2D", "no image data"); | 4683 synthesizeGLError(GL_INVALID_VALUE, "texSubImage2D", "no image data"); |
4684 return; | 4684 return; |
4685 } | 4685 } |
4686 if (pixels->data()->bufferBase()->isNeutered()) { | 4686 if (pixels->data()->bufferBase()->isNeutered()) { |
4687 synthesizeGLError(GL_INVALID_VALUE, "texSubImage2D", "The source data ha
s been neutered."); | 4687 synthesizeGLError(GL_INVALID_VALUE, "texSubImage2D", "The source data ha
s been neutered."); |
4688 return; | 4688 return; |
4689 } | 4689 } |
4690 if (isContextLost() || !validateTexFunc("texSubImage2D", TexSubImage2D, Sour
ceImageData, target, level, 0, pixels->width(), pixels->height(), 1, 0, format,
type, xoffset, yoffset, 0)) | 4690 if (isContextLost() || !validateTexFunc("texSubImage2D", TexSubImage, Source
ImageData, target, level, 0, pixels->width(), pixels->height(), 1, 0, format, t
ype, xoffset, yoffset, 0)) |
4691 return; | 4691 return; |
4692 if (type == GL_UNSIGNED_INT_10F_11F_11F_REV) { | 4692 if (type == GL_UNSIGNED_INT_10F_11F_11F_REV) { |
4693 // The UNSIGNED_INT_10F_11F_11F_REV type pack/unpack isn't implemented. | 4693 // The UNSIGNED_INT_10F_11F_11F_REV type pack/unpack isn't implemented. |
4694 type = GL_FLOAT; | 4694 type = GL_FLOAT; |
4695 } | 4695 } |
4696 Vector<uint8_t> data; | 4696 Vector<uint8_t> data; |
4697 bool needConversion = true; | 4697 bool needConversion = true; |
4698 // The data from ImageData is always of format RGBA8. | 4698 // The data from ImageData is always of format RGBA8. |
4699 // No conversion is needed if destination format is RGBA and type is USIGNED
_BYTE and no Flip or Premultiply operation is required. | 4699 // No conversion is needed if destination format is RGBA and type is USIGNED
_BYTE and no Flip or Premultiply operation is required. |
4700 if (format == GL_RGBA && type == GL_UNSIGNED_BYTE && !m_unpackFlipY && !m_un
packPremultiplyAlpha) { | 4700 if (format == GL_RGBA && type == GL_UNSIGNED_BYTE && !m_unpackFlipY && !m_un
packPremultiplyAlpha) { |
(...skipping 17 matching lines...) Expand all Loading... |
4718 | 4718 |
4719 if (type == GL_UNSIGNED_INT_10F_11F_11F_REV) { | 4719 if (type == GL_UNSIGNED_INT_10F_11F_11F_REV) { |
4720 // The UNSIGNED_INT_10F_11F_11F_REV type pack/unpack isn't implemented. | 4720 // The UNSIGNED_INT_10F_11F_11F_REV type pack/unpack isn't implemented. |
4721 type = GL_FLOAT; | 4721 type = GL_FLOAT; |
4722 } | 4722 } |
4723 | 4723 |
4724 RefPtr<Image> imageForRender = image->cachedImage()->image(); | 4724 RefPtr<Image> imageForRender = image->cachedImage()->image(); |
4725 if (imageForRender && imageForRender->isSVGImage()) | 4725 if (imageForRender && imageForRender->isSVGImage()) |
4726 imageForRender = drawImageIntoBuffer(imageForRender.release(), image->wi
dth(), image->height(), "texSubImage2D"); | 4726 imageForRender = drawImageIntoBuffer(imageForRender.release(), image->wi
dth(), image->height(), "texSubImage2D"); |
4727 | 4727 |
4728 if (!imageForRender || !validateTexFunc("texSubImage2D", TexSubImage2D, Sour
ceHTMLImageElement, target, level, 0, imageForRender->width(), imageForRender->h
eight(), 1, 0, format, type, xoffset, yoffset, 0)) | 4728 if (!imageForRender || !validateTexFunc("texSubImage2D", TexSubImage, Source
HTMLImageElement, target, level, 0, imageForRender->width(), imageForRender->hei
ght(), 1, 0, format, type, xoffset, yoffset, 0)) |
4729 return; | 4729 return; |
4730 | 4730 |
4731 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, imageForRen
der.get(), WebGLImageConversion::HtmlDomImage, m_unpackFlipY, m_unpackPremultipl
yAlpha); | 4731 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, imageForRen
der.get(), WebGLImageConversion::HtmlDomImage, m_unpackFlipY, m_unpackPremultipl
yAlpha); |
4732 } | 4732 } |
4733 | 4733 |
4734 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint
xoffset, GLint yoffset, | 4734 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint
xoffset, GLint yoffset, |
4735 GLenum format, GLenum type, HTMLCanvasElement* canvas, ExceptionState& excep
tionState) | 4735 GLenum format, GLenum type, HTMLCanvasElement* canvas, ExceptionState& excep
tionState) |
4736 { | 4736 { |
4737 if (isContextLost() || !validateHTMLCanvasElement("texSubImage2D", canvas, e
xceptionState) | 4737 if (isContextLost() || !validateHTMLCanvasElement("texSubImage2D", canvas, e
xceptionState) |
4738 || !validateTexFunc("texSubImage2D", TexSubImage2D, SourceHTMLCanvasElem
ent, target, level, 0, canvas->width(), canvas->height(), 1, 0, format, type, xo
ffset, yoffset, 0)) | 4738 || !validateTexFunc("texSubImage2D", TexSubImage, SourceHTMLCanvasElemen
t, target, level, 0, canvas->width(), canvas->height(), 1, 0, format, type, xoff
set, yoffset, 0)) |
4739 return; | 4739 return; |
4740 | 4740 |
4741 WebGLTexture* texture = validateTextureBinding("texSubImage2D", target, true
); | 4741 WebGLTexture* texture = validateTextureBinding("texSubImage2D", target, true
); |
4742 ASSERT(texture); | 4742 ASSERT(texture); |
4743 | 4743 |
4744 GLenum internalformat = texture->getInternalFormat(target, level); | 4744 GLenum internalformat = texture->getInternalFormat(target, level); |
4745 // texImageCanvasByGPU relies on copyTextureCHROMIUM which doesn't support f
loat/integer/sRGB internal format. | 4745 // texImageCanvasByGPU relies on copyTextureCHROMIUM which doesn't support f
loat/integer/sRGB internal format. |
4746 // FIXME: relax the constrains if copyTextureCHROMIUM is upgraded to handle
more formats. | 4746 // FIXME: relax the constrains if copyTextureCHROMIUM is upgraded to handle
more formats. |
4747 if (!canvas->renderingContext() || !canvas->renderingContext()->isAccelerate
d() || !canUseTexImageCanvasByGPU(internalformat, type)) { | 4747 if (!canvas->renderingContext() || !canvas->renderingContext()->isAccelerate
d() || !canUseTexImageCanvasByGPU(internalformat, type)) { |
4748 // 2D canvas has only FrontBuffer. | 4748 // 2D canvas has only FrontBuffer. |
4749 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, canvas-
>copiedImage(FrontBuffer, PreferAcceleration).get(), | 4749 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, canvas-
>copiedImage(FrontBuffer, PreferAcceleration).get(), |
4750 WebGLImageConversion::HtmlDomCanvas, m_unpackFlipY, m_unpackPremulti
plyAlpha); | 4750 WebGLImageConversion::HtmlDomCanvas, m_unpackFlipY, m_unpackPremulti
plyAlpha); |
4751 return; | 4751 return; |
4752 } | 4752 } |
4753 | 4753 |
4754 texImageCanvasByGPU(TexSubImage2DByGPU, texture, target, level, GL_RGBA, typ
e, xoffset, yoffset, 0, canvas); | 4754 texImageCanvasByGPU(TexSubImage2DByGPU, texture, target, level, GL_RGBA, typ
e, xoffset, yoffset, 0, canvas); |
4755 } | 4755 } |
4756 | 4756 |
4757 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint
xoffset, GLint yoffset, | 4757 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint
xoffset, GLint yoffset, |
4758 GLenum format, GLenum type, HTMLVideoElement* video, ExceptionState& excepti
onState) | 4758 GLenum format, GLenum type, HTMLVideoElement* video, ExceptionState& excepti
onState) |
4759 { | 4759 { |
4760 if (isContextLost() || !validateHTMLVideoElement("texSubImage2D", video, exc
eptionState) | 4760 if (isContextLost() || !validateHTMLVideoElement("texSubImage2D", video, exc
eptionState) |
4761 || !validateTexFunc("texSubImage2D", TexSubImage2D, SourceHTMLVideoEleme
nt, target, level, 0, video->videoWidth(), video->videoHeight(), 1, 0, format, t
ype, xoffset, yoffset, 0)) | 4761 || !validateTexFunc("texSubImage2D", TexSubImage, SourceHTMLVideoElement
, target, level, 0, video->videoWidth(), video->videoHeight(), 1, 0, format, typ
e, xoffset, yoffset, 0)) |
4762 return; | 4762 return; |
4763 | 4763 |
4764 RefPtr<Image> image = videoFrameToImage(video); | 4764 RefPtr<Image> image = videoFrameToImage(video); |
4765 if (!image) | 4765 if (!image) |
4766 return; | 4766 return; |
4767 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get()
, WebGLImageConversion::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha); | 4767 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, image.get()
, WebGLImageConversion::HtmlDomVideo, m_unpackFlipY, m_unpackPremultiplyAlpha); |
4768 } | 4768 } |
4769 | 4769 |
4770 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint
xoffset, GLint yoffset, | 4770 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint
xoffset, GLint yoffset, |
4771 GLenum format, GLenum type, PassRefPtrWillBeRawPtr<ImageBitmap> bitmap) | 4771 GLenum format, GLenum type, PassRefPtrWillBeRawPtr<ImageBitmap> bitmap) |
4772 { | 4772 { |
4773 ASSERT(bitmap->bitmapImage()); | 4773 ASSERT(bitmap->bitmapImage()); |
4774 if (bitmap->isNeutered()) { | 4774 if (bitmap->isNeutered()) { |
4775 synthesizeGLError(GL_INVALID_VALUE, "texSubImage2D", "The source data ha
s been neutered."); | 4775 synthesizeGLError(GL_INVALID_VALUE, "texSubImage2D", "The source data ha
s been neutered."); |
4776 return; | 4776 return; |
4777 } | 4777 } |
4778 if (isContextLost() || !validateTexFunc("texSubImage2D", TexSubImage2D, Sour
ceImageBitmap, target, level, 0, bitmap->width(), bitmap->height(), 1, 0, format
, type, 0, 0, 0)) | 4778 if (isContextLost() || !validateTexFunc("texSubImage2D", TexSubImage, Source
ImageBitmap, target, level, 0, bitmap->width(), bitmap->height(), 1, 0, format,
type, 0, 0, 0)) |
4779 return; | 4779 return; |
4780 StaticBitmapImage* imageForRender = bitmap->bitmapImage(); | 4780 StaticBitmapImage* imageForRender = bitmap->bitmapImage(); |
4781 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, imageForRen
der, WebGLImageConversion::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha
); | 4781 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, imageForRen
der, WebGLImageConversion::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlpha
); |
4782 } | 4782 } |
4783 | 4783 |
4784 void WebGLRenderingContextBase::uniform1f(const WebGLUniformLocation* location,
GLfloat x) | 4784 void WebGLRenderingContextBase::uniform1f(const WebGLUniformLocation* location,
GLfloat x) |
4785 { | 4785 { |
4786 if (isContextLost() || !location) | 4786 if (isContextLost() || !location) |
4787 return; | 4787 return; |
4788 | 4788 |
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5729 synthesizeGLError(GL_INVALID_VALUE, functionName, "width or height o
ut of range"); | 5729 synthesizeGLError(GL_INVALID_VALUE, functionName, "width or height o
ut of range"); |
5730 return false; | 5730 return false; |
5731 } | 5731 } |
5732 break; | 5732 break; |
5733 case GL_TEXTURE_CUBE_MAP_POSITIVE_X: | 5733 case GL_TEXTURE_CUBE_MAP_POSITIVE_X: |
5734 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: | 5734 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: |
5735 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: | 5735 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: |
5736 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: | 5736 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: |
5737 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: | 5737 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: |
5738 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: | 5738 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: |
5739 if (functionType != TexSubImage2D && width != height) { | 5739 if (functionType != TexSubImage && width != height) { |
5740 synthesizeGLError(GL_INVALID_VALUE, functionName, "width != height f
or cube map"); | 5740 synthesizeGLError(GL_INVALID_VALUE, functionName, "width != height f
or cube map"); |
5741 return false; | 5741 return false; |
5742 } | 5742 } |
5743 // No need to check height here. For texImage width == height. | 5743 // No need to check height here. For texImage width == height. |
5744 // For texSubImage that will be checked when checking yoffset + height i
s in range. | 5744 // For texSubImage that will be checked when checking yoffset + height i
s in range. |
5745 if (width > (m_maxCubeMapTextureSize >> level)) { | 5745 if (width > (m_maxCubeMapTextureSize >> level)) { |
5746 synthesizeGLError(GL_INVALID_VALUE, functionName, "width or height o
ut of range for cube map"); | 5746 synthesizeGLError(GL_INVALID_VALUE, functionName, "width or height o
ut of range for cube map"); |
5747 return false; | 5747 return false; |
5748 } | 5748 } |
5749 break; | 5749 break; |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6175 maxX += width; | 6175 maxX += width; |
6176 maxY += height; | 6176 maxY += height; |
6177 if (!maxX.isValid() || ((width % kBlockWidth) && maxX.value() != tex->ge
tWidth(target, level))) { | 6177 if (!maxX.isValid() || ((width % kBlockWidth) && maxX.value() != tex->ge
tWidth(target, level))) { |
6178 synthesizeGLError(GL_INVALID_OPERATION, functionName, "width not mul
tiple of 4 and width + xoffset not equal to width of the texture level for ETC2/
EAC format texture"); | 6178 synthesizeGLError(GL_INVALID_OPERATION, functionName, "width not mul
tiple of 4 and width + xoffset not equal to width of the texture level for ETC2/
EAC format texture"); |
6179 return false; | 6179 return false; |
6180 } | 6180 } |
6181 if (!maxY.isValid() || ((height % kBlockHeight) && maxY.value() != tex->
getHeight(target, level))) { | 6181 if (!maxY.isValid() || ((height % kBlockHeight) && maxY.value() != tex->
getHeight(target, level))) { |
6182 synthesizeGLError(GL_INVALID_OPERATION, functionName, "height not mu
ltiple of 4 and height + yoffset not equal to height of the texture level for ET
C2/EAC format texture"); | 6182 synthesizeGLError(GL_INVALID_OPERATION, functionName, "height not mu
ltiple of 4 and height + yoffset not equal to height of the texture level for ET
C2/EAC format texture"); |
6183 return false; | 6183 return false; |
6184 } | 6184 } |
6185 return validateCompressedTexDimensions(functionName, TexSubImage2D, targ
et, level, width, height, depth, format); | 6185 return validateCompressedTexDimensions(functionName, TexSubImage, target
, level, width, height, depth, format); |
6186 } | 6186 } |
6187 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: | 6187 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: |
6188 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: | 6188 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: |
6189 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: | 6189 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: |
6190 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: { | 6190 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: { |
6191 const int kBlockWidth = 4; | 6191 const int kBlockWidth = 4; |
6192 const int kBlockHeight = 4; | 6192 const int kBlockHeight = 4; |
6193 if ((xoffset % kBlockWidth) || (yoffset % kBlockHeight)) { | 6193 if ((xoffset % kBlockWidth) || (yoffset % kBlockHeight)) { |
6194 synthesizeGLError(GL_INVALID_OPERATION, functionName, "xoffset or yo
ffset not multiple of 4"); | 6194 synthesizeGLError(GL_INVALID_OPERATION, functionName, "xoffset or yo
ffset not multiple of 4"); |
6195 return false; | 6195 return false; |
6196 } | 6196 } |
6197 // Before checking if it is in the range, check if overflow happens firs
t. | 6197 // Before checking if it is in the range, check if overflow happens firs
t. |
6198 CheckedInt<GLint> maxX = xoffset, maxY = yoffset; | 6198 CheckedInt<GLint> maxX = xoffset, maxY = yoffset; |
6199 maxX += width; | 6199 maxX += width; |
6200 maxY += height; | 6200 maxY += height; |
6201 if (!maxX.isValid() || !maxY.isValid() || maxX.value() > tex->getWidth(t
arget, level) | 6201 if (!maxX.isValid() || !maxY.isValid() || maxX.value() > tex->getWidth(t
arget, level) |
6202 || maxY.value() > tex->getHeight(target, level)) { | 6202 || maxY.value() > tex->getHeight(target, level)) { |
6203 synthesizeGLError(GL_INVALID_VALUE, functionName, "dimensions out of
range"); | 6203 synthesizeGLError(GL_INVALID_VALUE, functionName, "dimensions out of
range"); |
6204 return false; | 6204 return false; |
6205 } | 6205 } |
6206 return validateCompressedTexDimensions(functionName, TexSubImage2D, targ
et, level, width, height, depth, format); | 6206 return validateCompressedTexDimensions(functionName, TexSubImage, target
, level, width, height, depth, format); |
6207 } | 6207 } |
6208 case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: | 6208 case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: |
6209 case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: | 6209 case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: |
6210 case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: | 6210 case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: |
6211 case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: { | 6211 case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: { |
6212 if ((xoffset != 0) || (yoffset != 0)) { | 6212 if ((xoffset != 0) || (yoffset != 0)) { |
6213 synthesizeGLError(GL_INVALID_OPERATION, functionName, "xoffset and y
offset must be zero"); | 6213 synthesizeGLError(GL_INVALID_OPERATION, functionName, "xoffset and y
offset must be zero"); |
6214 return false; | 6214 return false; |
6215 } | 6215 } |
6216 if (width != tex->getWidth(target, level) | 6216 if (width != tex->getWidth(target, level) |
6217 || height != tex->getHeight(target, level)) { | 6217 || height != tex->getHeight(target, level)) { |
6218 synthesizeGLError(GL_INVALID_OPERATION, functionName, "dimensions mu
st match existing level"); | 6218 synthesizeGLError(GL_INVALID_OPERATION, functionName, "dimensions mu
st match existing level"); |
6219 return false; | 6219 return false; |
6220 } | 6220 } |
6221 return validateCompressedTexDimensions(functionName, TexSubImage2D, targ
et, level, width, height, depth, format); | 6221 return validateCompressedTexDimensions(functionName, TexSubImage, target
, level, width, height, depth, format); |
6222 } | 6222 } |
6223 case GC3D_COMPRESSED_ATC_RGB_AMD: | 6223 case GC3D_COMPRESSED_ATC_RGB_AMD: |
6224 case GC3D_COMPRESSED_ATC_RGBA_EXPLICIT_ALPHA_AMD: | 6224 case GC3D_COMPRESSED_ATC_RGBA_EXPLICIT_ALPHA_AMD: |
6225 case GC3D_COMPRESSED_ATC_RGBA_INTERPOLATED_ALPHA_AMD: | 6225 case GC3D_COMPRESSED_ATC_RGBA_INTERPOLATED_ALPHA_AMD: |
6226 case GL_ETC1_RGB8_OES: { | 6226 case GL_ETC1_RGB8_OES: { |
6227 synthesizeGLError(GL_INVALID_OPERATION, functionName, "unable to update
sub-images with this format"); | 6227 synthesizeGLError(GL_INVALID_OPERATION, functionName, "unable to update
sub-images with this format"); |
6228 return false; | 6228 return false; |
6229 } | 6229 } |
6230 default: | 6230 default: |
6231 return false; | 6231 return false; |
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7071 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1); | 7071 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, 1); |
7072 } | 7072 } |
7073 | 7073 |
7074 void WebGLRenderingContextBase::restoreUnpackParameters() | 7074 void WebGLRenderingContextBase::restoreUnpackParameters() |
7075 { | 7075 { |
7076 if (m_unpackAlignment != 1) | 7076 if (m_unpackAlignment != 1) |
7077 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 7077 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); |
7078 } | 7078 } |
7079 | 7079 |
7080 } // namespace blink | 7080 } // namespace blink |
OLD | NEW |