| 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 4105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4116 return false; | 4116 return false; |
| 4117 } | 4117 } |
| 4118 if (value > static_cast<long long>(std::numeric_limits<int>::max())) { | 4118 if (value > static_cast<long long>(std::numeric_limits<int>::max())) { |
| 4119 String errorMsg = String(paramName) + " more than 32-bit"; | 4119 String errorMsg = String(paramName) + " more than 32-bit"; |
| 4120 synthesizeGLError(GL_INVALID_OPERATION, functionName, errorMsg.ascii().d
ata()); | 4120 synthesizeGLError(GL_INVALID_OPERATION, functionName, errorMsg.ascii().d
ata()); |
| 4121 return false; | 4121 return false; |
| 4122 } | 4122 } |
| 4123 return true; | 4123 return true; |
| 4124 } | 4124 } |
| 4125 | 4125 |
| 4126 PassRefPtr<Image> WebGLRenderingContextBase::drawImageIntoBuffer(Image* image, i
nt width, int height, const char* functionName) | 4126 // TODO(fmalita): figure why WebGLImageConversion::ImageExtractor can't handle S
VG-backed images, |
| 4127 // and get rid of this intermediate step. |
| 4128 PassRefPtr<Image> WebGLRenderingContextBase::drawImageIntoBuffer(PassRefPtr<Imag
e> passImage, |
| 4129 int width, int height, const char* functionName) |
| 4127 { | 4130 { |
| 4131 RefPtr<Image> image(passImage); |
| 4132 ASSERT(image); |
| 4133 |
| 4128 IntSize size(width, height); | 4134 IntSize size(width, height); |
| 4129 ImageBuffer* buf = m_generatedImageCache.imageBuffer(size); | 4135 ImageBuffer* buf = m_generatedImageCache.imageBuffer(size); |
| 4130 if (!buf) { | 4136 if (!buf) { |
| 4131 synthesizeGLError(GL_OUT_OF_MEMORY, functionName, "out of memory"); | 4137 synthesizeGLError(GL_OUT_OF_MEMORY, functionName, "out of memory"); |
| 4132 return nullptr; | 4138 return nullptr; |
| 4133 } | 4139 } |
| 4134 | 4140 |
| 4141 if (!image->currentFrameKnownToBeOpaque()) |
| 4142 buf->canvas()->clear(SK_ColorTRANSPARENT); |
| 4143 |
| 4135 IntRect srcRect(IntPoint(), image->size()); | 4144 IntRect srcRect(IntPoint(), image->size()); |
| 4136 IntRect destRect(0, 0, size.width(), size.height()); | 4145 IntRect destRect(0, 0, size.width(), size.height()); |
| 4137 SkPaint paint; | 4146 SkPaint paint; |
| 4138 image->draw(buf->canvas(), paint, destRect, srcRect, DoNotRespectImageOrient
ation, Image::DoNotClampImageToSourceRect); | 4147 image->draw(buf->canvas(), paint, destRect, srcRect, DoNotRespectImageOrient
ation, Image::DoNotClampImageToSourceRect); |
| 4139 return buf->newImageSnapshot(); | 4148 return buf->newImageSnapshot(); |
| 4140 } | 4149 } |
| 4141 | 4150 |
| 4142 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in
ternalformat, | 4151 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in
ternalformat, |
| 4143 GLsizei width, GLsizei height, GLint border, | 4152 GLsizei width, GLsizei height, GLint border, |
| 4144 GLenum format, GLenum type, DOMArrayBufferView* pixels) | 4153 GLenum format, GLenum type, DOMArrayBufferView* pixels) |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4190 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 4199 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); |
| 4191 } | 4200 } |
| 4192 | 4201 |
| 4193 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in
ternalformat, | 4202 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in
ternalformat, |
| 4194 GLenum format, GLenum type, HTMLImageElement* image, ExceptionState& excepti
onState) | 4203 GLenum format, GLenum type, HTMLImageElement* image, ExceptionState& excepti
onState) |
| 4195 { | 4204 { |
| 4196 if (isContextLost() || !validateHTMLImageElement("texImage2D", image, except
ionState)) | 4205 if (isContextLost() || !validateHTMLImageElement("texImage2D", image, except
ionState)) |
| 4197 return; | 4206 return; |
| 4198 | 4207 |
| 4199 RefPtr<Image> imageForRender = image->cachedImage()->imageForLayoutObject(im
age->layoutObject()); | 4208 RefPtr<Image> imageForRender = image->cachedImage()->imageForLayoutObject(im
age->layoutObject()); |
| 4200 if (imageForRender->isSVGImage()) | 4209 if (imageForRender && imageForRender->isSVGImage()) |
| 4201 imageForRender = drawImageIntoBuffer(imageForRender.get(), image->width(
), image->height(), "texImage2D"); | 4210 imageForRender = drawImageIntoBuffer(imageForRender.release(), image->wi
dth(), image->height(), "texImage2D"); |
| 4202 | 4211 |
| 4203 if (!imageForRender || !validateTexFunc("texImage2D", NotTexSubImage2D, Sour
ceHTMLImageElement, target, level, internalformat, imageForRender->width(), imag
eForRender->height(), 0, format, type, 0, 0)) | 4212 if (!imageForRender || !validateTexFunc("texImage2D", NotTexSubImage2D, Sour
ceHTMLImageElement, target, level, internalformat, imageForRender->width(), imag
eForRender->height(), 0, format, type, 0, 0)) |
| 4204 return; | 4213 return; |
| 4205 | 4214 |
| 4206 texImage2DImpl(target, level, internalformat, format, type, imageForRender.g
et(), WebGLImageConversion::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlph
a); | 4215 texImage2DImpl(target, level, internalformat, format, type, imageForRender.g
et(), WebGLImageConversion::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlph
a); |
| 4207 } | 4216 } |
| 4208 | 4217 |
| 4209 void WebGLRenderingContextBase::texImage2DCanvasByGPU(TexImageFunctionType funct
ionType, WebGLTexture* texture, GLenum target, | 4218 void WebGLRenderingContextBase::texImage2DCanvasByGPU(TexImageFunctionType funct
ionType, WebGLTexture* texture, GLenum target, |
| 4210 GLint level, GLenum internalformat, GLenum type, GLint xoffset, GLint yoffse
t, HTMLCanvasElement* canvas) | 4219 GLint level, GLenum internalformat, GLenum type, GLint xoffset, GLint yoffse
t, HTMLCanvasElement* canvas) |
| 4211 { | 4220 { |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4500 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); | 4509 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); |
| 4501 } | 4510 } |
| 4502 | 4511 |
| 4503 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint
xoffset, GLint yoffset, | 4512 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint
xoffset, GLint yoffset, |
| 4504 GLenum format, GLenum type, HTMLImageElement* image, ExceptionState& excepti
onState) | 4513 GLenum format, GLenum type, HTMLImageElement* image, ExceptionState& excepti
onState) |
| 4505 { | 4514 { |
| 4506 if (isContextLost() || !validateHTMLImageElement("texSubImage2D", image, exc
eptionState)) | 4515 if (isContextLost() || !validateHTMLImageElement("texSubImage2D", image, exc
eptionState)) |
| 4507 return; | 4516 return; |
| 4508 | 4517 |
| 4509 RefPtr<Image> imageForRender = image->cachedImage()->imageForLayoutObject(im
age->layoutObject()); | 4518 RefPtr<Image> imageForRender = image->cachedImage()->imageForLayoutObject(im
age->layoutObject()); |
| 4510 if (imageForRender->isSVGImage()) | 4519 if (imageForRender && imageForRender->isSVGImage()) |
| 4511 imageForRender = drawImageIntoBuffer(imageForRender.get(), image->width(
), image->height(), "texSubImage2D"); | 4520 imageForRender = drawImageIntoBuffer(imageForRender.release(), image->wi
dth(), image->height(), "texSubImage2D"); |
| 4512 | 4521 |
| 4513 if (!imageForRender || !validateTexFunc("texSubImage2D", TexSubImage2D, Sour
ceHTMLImageElement, target, level, 0, imageForRender->width(), imageForRender->h
eight(), 0, format, type, xoffset, yoffset)) | 4522 if (!imageForRender || !validateTexFunc("texSubImage2D", TexSubImage2D, Sour
ceHTMLImageElement, target, level, 0, imageForRender->width(), imageForRender->h
eight(), 0, format, type, xoffset, yoffset)) |
| 4514 return; | 4523 return; |
| 4515 | 4524 |
| 4516 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, imageForRen
der.get(), WebGLImageConversion::HtmlDomImage, m_unpackFlipY, m_unpackPremultipl
yAlpha); | 4525 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, imageForRen
der.get(), WebGLImageConversion::HtmlDomImage, m_unpackFlipY, m_unpackPremultipl
yAlpha); |
| 4517 } | 4526 } |
| 4518 | 4527 |
| 4519 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint
xoffset, GLint yoffset, | 4528 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint
xoffset, GLint yoffset, |
| 4520 GLenum format, GLenum type, HTMLCanvasElement* canvas, ExceptionState& excep
tionState) | 4529 GLenum format, GLenum type, HTMLCanvasElement* canvas, ExceptionState& excep
tionState) |
| 4521 { | 4530 { |
| (...skipping 2185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6707 | 6716 |
| 6708 return totalBytesPerPixel; | 6717 return totalBytesPerPixel; |
| 6709 } | 6718 } |
| 6710 | 6719 |
| 6711 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const | 6720 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const |
| 6712 { | 6721 { |
| 6713 return m_drawingBuffer.get(); | 6722 return m_drawingBuffer.get(); |
| 6714 } | 6723 } |
| 6715 | 6724 |
| 6716 } // namespace blink | 6725 } // namespace blink |
| OLD | NEW |