Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: Source/modules/webgl/WebGLRenderingContextBase.cpp

Issue 1315233003: WebGL's SVGImage buffer should be cleared (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: updated results Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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> image, int width,
4129 int height, const char* functionName)
4127 { 4130 {
4131 ASSERT(image);
Ken Russell (switch to Gerrit) 2015/09/08 19:34:01 If this is being changed to take PassRefPtr<Image>
f(malita) 2015/09/08 19:51:42 Done.
4132
4128 IntSize size(width, height); 4133 IntSize size(width, height);
4129 ImageBuffer* buf = m_generatedImageCache.imageBuffer(size); 4134 ImageBuffer* buf = m_generatedImageCache.imageBuffer(size);
4130 if (!buf) { 4135 if (!buf) {
4131 synthesizeGLError(GL_OUT_OF_MEMORY, functionName, "out of memory"); 4136 synthesizeGLError(GL_OUT_OF_MEMORY, functionName, "out of memory");
4132 return nullptr; 4137 return nullptr;
4133 } 4138 }
4134 4139
4140 if (!image->currentFrameKnownToBeOpaque())
pdr. 2015/09/08 18:33:58 Why wasn't this needed for transparent animated gi
f(malita) 2015/09/08 18:44:45 We only ever call drawImageIntoBuffer for SVG imag
4141 buf->canvas()->clear(SK_ColorTRANSPARENT);
4142
4135 IntRect srcRect(IntPoint(), image->size()); 4143 IntRect srcRect(IntPoint(), image->size());
4136 IntRect destRect(0, 0, size.width(), size.height()); 4144 IntRect destRect(0, 0, size.width(), size.height());
4137 SkPaint paint; 4145 SkPaint paint;
4138 image->draw(buf->canvas(), paint, destRect, srcRect, DoNotRespectImageOrient ation, Image::DoNotClampImageToSourceRect); 4146 image->draw(buf->canvas(), paint, destRect, srcRect, DoNotRespectImageOrient ation, Image::DoNotClampImageToSourceRect);
4139 return buf->newImageSnapshot(); 4147 return buf->newImageSnapshot();
4140 } 4148 }
4141 4149
4142 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in ternalformat, 4150 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in ternalformat,
4143 GLsizei width, GLsizei height, GLint border, 4151 GLsizei width, GLsizei height, GLint border,
4144 GLenum format, GLenum type, DOMArrayBufferView* pixels) 4152 GLenum format, GLenum type, DOMArrayBufferView* pixels)
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
4190 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); 4198 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment);
4191 } 4199 }
4192 4200
4193 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in ternalformat, 4201 void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in ternalformat,
4194 GLenum format, GLenum type, HTMLImageElement* image, ExceptionState& excepti onState) 4202 GLenum format, GLenum type, HTMLImageElement* image, ExceptionState& excepti onState)
4195 { 4203 {
4196 if (isContextLost() || !validateHTMLImageElement("texImage2D", image, except ionState)) 4204 if (isContextLost() || !validateHTMLImageElement("texImage2D", image, except ionState))
4197 return; 4205 return;
4198 4206
4199 RefPtr<Image> imageForRender = image->cachedImage()->imageForLayoutObject(im age->layoutObject()); 4207 RefPtr<Image> imageForRender = image->cachedImage()->imageForLayoutObject(im age->layoutObject());
4200 if (imageForRender->isSVGImage()) 4208 if (imageForRender && imageForRender->isSVGImage())
4201 imageForRender = drawImageIntoBuffer(imageForRender.get(), image->width( ), image->height(), "texImage2D"); 4209 imageForRender = drawImageIntoBuffer(imageForRender.release(), image->wi dth(), image->height(), "texImage2D");
4202 4210
4203 if (!imageForRender || !validateTexFunc("texImage2D", NotTexSubImage2D, Sour ceHTMLImageElement, target, level, internalformat, imageForRender->width(), imag eForRender->height(), 0, format, type, 0, 0)) 4211 if (!imageForRender || !validateTexFunc("texImage2D", NotTexSubImage2D, Sour ceHTMLImageElement, target, level, internalformat, imageForRender->width(), imag eForRender->height(), 0, format, type, 0, 0))
4204 return; 4212 return;
4205 4213
4206 texImage2DImpl(target, level, internalformat, format, type, imageForRender.g et(), WebGLImageConversion::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlph a); 4214 texImage2DImpl(target, level, internalformat, format, type, imageForRender.g et(), WebGLImageConversion::HtmlDomImage, m_unpackFlipY, m_unpackPremultiplyAlph a);
4207 } 4215 }
4208 4216
4209 void WebGLRenderingContextBase::texImage2DCanvasByGPU(TexImageFunctionType funct ionType, WebGLTexture* texture, GLenum target, 4217 void WebGLRenderingContextBase::texImage2DCanvasByGPU(TexImageFunctionType funct ionType, WebGLTexture* texture, GLenum target,
4210 GLint level, GLenum internalformat, GLenum type, GLint xoffset, GLint yoffse t, HTMLCanvasElement* canvas) 4218 GLint level, GLenum internalformat, GLenum type, GLint xoffset, GLint yoffse t, HTMLCanvasElement* canvas)
4211 { 4219 {
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
4500 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment); 4508 webContext()->pixelStorei(GL_UNPACK_ALIGNMENT, m_unpackAlignment);
4501 } 4509 }
4502 4510
4503 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, 4511 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
4504 GLenum format, GLenum type, HTMLImageElement* image, ExceptionState& excepti onState) 4512 GLenum format, GLenum type, HTMLImageElement* image, ExceptionState& excepti onState)
4505 { 4513 {
4506 if (isContextLost() || !validateHTMLImageElement("texSubImage2D", image, exc eptionState)) 4514 if (isContextLost() || !validateHTMLImageElement("texSubImage2D", image, exc eptionState))
4507 return; 4515 return;
4508 4516
4509 RefPtr<Image> imageForRender = image->cachedImage()->imageForLayoutObject(im age->layoutObject()); 4517 RefPtr<Image> imageForRender = image->cachedImage()->imageForLayoutObject(im age->layoutObject());
4510 if (imageForRender->isSVGImage()) 4518 if (imageForRender && imageForRender->isSVGImage())
4511 imageForRender = drawImageIntoBuffer(imageForRender.get(), image->width( ), image->height(), "texSubImage2D"); 4519 imageForRender = drawImageIntoBuffer(imageForRender.release(), image->wi dth(), image->height(), "texSubImage2D");
4512 4520
4513 if (!imageForRender || !validateTexFunc("texSubImage2D", TexSubImage2D, Sour ceHTMLImageElement, target, level, 0, imageForRender->width(), imageForRender->h eight(), 0, format, type, xoffset, yoffset)) 4521 if (!imageForRender || !validateTexFunc("texSubImage2D", TexSubImage2D, Sour ceHTMLImageElement, target, level, 0, imageForRender->width(), imageForRender->h eight(), 0, format, type, xoffset, yoffset))
4514 return; 4522 return;
4515 4523
4516 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, imageForRen der.get(), WebGLImageConversion::HtmlDomImage, m_unpackFlipY, m_unpackPremultipl yAlpha); 4524 texSubImage2DImpl(target, level, xoffset, yoffset, format, type, imageForRen der.get(), WebGLImageConversion::HtmlDomImage, m_unpackFlipY, m_unpackPremultipl yAlpha);
4517 } 4525 }
4518 4526
4519 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, 4527 void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
4520 GLenum format, GLenum type, HTMLCanvasElement* canvas, ExceptionState& excep tionState) 4528 GLenum format, GLenum type, HTMLCanvasElement* canvas, ExceptionState& excep tionState)
4521 { 4529 {
(...skipping 2185 matching lines...) Expand 10 before | Expand all | Expand 10 after
6707 6715
6708 return totalBytesPerPixel; 6716 return totalBytesPerPixel;
6709 } 6717 }
6710 6718
6711 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const 6719 DrawingBuffer* WebGLRenderingContextBase::drawingBuffer() const
6712 { 6720 {
6713 return m_drawingBuffer.get(); 6721 return m_drawingBuffer.get();
6714 } 6722 }
6715 6723
6716 } // namespace blink 6724 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698