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

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

Issue 2506863002: implement tex(Sub)Image2D/3D for HTMLVideoElement (Closed)
Patch Set: roll webgl Created 4 years, 1 month 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
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5112 matching lines...) Expand 10 before | Expand all | Expand 10 after
5123 TexImageFunctionID functionID, 5123 TexImageFunctionID functionID,
5124 GLenum target, 5124 GLenum target,
5125 GLint level, 5125 GLint level,
5126 GLint internalformat, 5126 GLint internalformat,
5127 GLenum format, 5127 GLenum format,
5128 GLenum type, 5128 GLenum type,
5129 GLint xoffset, 5129 GLint xoffset,
5130 GLint yoffset, 5130 GLint yoffset,
5131 GLint zoffset, 5131 GLint zoffset,
5132 HTMLVideoElement* video, 5132 HTMLVideoElement* video,
5133 const IntRect& sourceImageRect,
5134 GLsizei depth,
5135 GLint unpackImageHeight,
5133 ExceptionState& exceptionState) { 5136 ExceptionState& exceptionState) {
5134 const char* funcName = getTexImageFunctionName(functionID); 5137 const char* funcName = getTexImageFunctionName(functionID);
5135 if (isContextLost()) 5138 if (isContextLost())
5136 return; 5139 return;
5137 if (!validateHTMLVideoElement(funcName, video, exceptionState)) 5140 if (!validateHTMLVideoElement(funcName, video, exceptionState))
5138 return; 5141 return;
5139 WebGLTexture* texture = validateTexImageBinding(funcName, functionID, target); 5142 WebGLTexture* texture = validateTexImageBinding(funcName, functionID, target);
5140 if (!texture) 5143 if (!texture)
5141 return; 5144 return;
5142 TexImageFunctionType functionType; 5145 TexImageFunctionType functionType;
5143 if (functionID == TexImage2D) 5146 if (functionID == TexImage2D || functionID == TexImage3D)
5144 functionType = TexImage; 5147 functionType = TexImage;
5145 else 5148 else
5146 functionType = TexSubImage; 5149 functionType = TexSubImage;
5147 if (!validateTexFunc(funcName, functionType, SourceHTMLVideoElement, target, 5150 if (!validateTexFunc(funcName, functionType, SourceHTMLVideoElement, target,
5148 level, internalformat, video->videoWidth(), 5151 level, internalformat, video->videoWidth(),
5149 video->videoHeight(), 1, 0, format, type, xoffset, 5152 video->videoHeight(), 1, 0, format, type, xoffset,
5150 yoffset, zoffset)) 5153 yoffset, zoffset))
5151 return; 5154 return;
5152 5155
5153 if (functionID == TexImage2D) { 5156 bool sourceImageRectIsDefault =
5157 sourceImageRect == sentinelEmptyRect() ||
5158 sourceImageRect ==
5159 IntRect(0, 0, video->videoWidth(), video->videoHeight());
5160 if (functionID == TexImage2D && sourceImageRectIsDefault && depth == 1 &&
5161 unpackImageHeight == 0) {
5162 DCHECK_EQ(xoffset, 0);
5163 DCHECK_EQ(yoffset, 0);
5164 DCHECK_EQ(zoffset, 0);
5154 // Go through the fast path doing a GPU-GPU textures copy without a readback 5165 // Go through the fast path doing a GPU-GPU textures copy without a readback
5155 // to system memory if possible. Otherwise, it will fall back to the normal 5166 // to system memory if possible. Otherwise, it will fall back to the normal
5156 // SW path. 5167 // SW path.
5157 if (GL_TEXTURE_2D == target) { 5168 if (GL_TEXTURE_2D == target) {
5158 if (Extensions3DUtil::canUseCopyTextureCHROMIUM(target, internalformat, 5169 if (Extensions3DUtil::canUseCopyTextureCHROMIUM(target, internalformat,
5159 type, level) && 5170 type, level) &&
5160 video->copyVideoTextureToPlatformTexture( 5171 video->copyVideoTextureToPlatformTexture(
5161 contextGL(), texture->object(), internalformat, type, 5172 contextGL(), texture->object(), internalformat, type,
5162 m_unpackPremultiplyAlpha, m_unpackFlipY)) { 5173 m_unpackPremultiplyAlpha, m_unpackFlipY)) {
5163 return; 5174 return;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
5200 } 5211 }
5201 } 5212 }
5202 } 5213 }
5203 5214
5204 RefPtr<Image> image = videoFrameToImage(video); 5215 RefPtr<Image> image = videoFrameToImage(video);
5205 if (!image) 5216 if (!image)
5206 return; 5217 return;
5207 texImageImpl(functionID, target, level, internalformat, xoffset, yoffset, 5218 texImageImpl(functionID, target, level, internalformat, xoffset, yoffset,
5208 zoffset, format, type, image.get(), 5219 zoffset, format, type, image.get(),
5209 WebGLImageConversion::HtmlDomVideo, m_unpackFlipY, 5220 WebGLImageConversion::HtmlDomVideo, m_unpackFlipY,
5210 m_unpackPremultiplyAlpha, 5221 m_unpackPremultiplyAlpha, sourceImageRect, depth,
5211 IntRect(0, 0, video->videoWidth(), video->videoHeight()), 1, 0); 5222 unpackImageHeight);
5212 } 5223 }
5213 5224
5214 void WebGLRenderingContextBase::texImageBitmapByGPU(ImageBitmap* bitmap, 5225 void WebGLRenderingContextBase::texImageBitmapByGPU(ImageBitmap* bitmap,
5215 GLuint targetTexture, 5226 GLuint targetTexture,
5216 GLenum targetInternalformat, 5227 GLenum targetInternalformat,
5217 GLenum targetType, 5228 GLenum targetType,
5218 GLint targetLevel, 5229 GLint targetLevel,
5219 bool flipY) { 5230 bool flipY) {
5220 bitmap->bitmapImage()->copyToTexture(drawingBuffer()->contextProvider(), 5231 bitmap->bitmapImage()->copyToTexture(drawingBuffer()->contextProvider(),
5221 targetTexture, targetInternalformat, 5232 targetTexture, targetInternalformat,
5222 targetType, flipY); 5233 targetType, flipY);
5223 } 5234 }
5224 5235
5225 void WebGLRenderingContextBase::texImage2D(GLenum target, 5236 void WebGLRenderingContextBase::texImage2D(GLenum target,
5226 GLint level, 5237 GLint level,
5227 GLint internalformat, 5238 GLint internalformat,
5228 GLenum format, 5239 GLenum format,
5229 GLenum type, 5240 GLenum type,
5230 HTMLVideoElement* video, 5241 HTMLVideoElement* video,
5231 ExceptionState& exceptionState) { 5242 ExceptionState& exceptionState) {
5232 texImageHelperHTMLVideoElement(TexImage2D, target, level, internalformat, 5243 texImageHelperHTMLVideoElement(TexImage2D, target, level, internalformat,
5233 format, type, 0, 0, 0, video, exceptionState); 5244 format, type, 0, 0, 0, video,
5245 sentinelEmptyRect(), 1, 0, exceptionState);
5234 } 5246 }
5235 5247
5236 void WebGLRenderingContextBase::texImageHelperImageBitmap( 5248 void WebGLRenderingContextBase::texImageHelperImageBitmap(
5237 TexImageFunctionID functionID, 5249 TexImageFunctionID functionID,
5238 GLenum target, 5250 GLenum target,
5239 GLint level, 5251 GLint level,
5240 GLint internalformat, 5252 GLint internalformat,
5241 GLenum format, 5253 GLenum format,
5242 GLenum type, 5254 GLenum type,
5243 GLint xoffset, 5255 GLint xoffset,
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
5482 5494
5483 void WebGLRenderingContextBase::texSubImage2D(GLenum target, 5495 void WebGLRenderingContextBase::texSubImage2D(GLenum target,
5484 GLint level, 5496 GLint level,
5485 GLint xoffset, 5497 GLint xoffset,
5486 GLint yoffset, 5498 GLint yoffset,
5487 GLenum format, 5499 GLenum format,
5488 GLenum type, 5500 GLenum type,
5489 HTMLVideoElement* video, 5501 HTMLVideoElement* video,
5490 ExceptionState& exceptionState) { 5502 ExceptionState& exceptionState) {
5491 texImageHelperHTMLVideoElement(TexSubImage2D, target, level, 0, format, type, 5503 texImageHelperHTMLVideoElement(TexSubImage2D, target, level, 0, format, type,
5492 xoffset, yoffset, 0, video, exceptionState); 5504 xoffset, yoffset, 0, video,
5505 sentinelEmptyRect(), 1, 0, exceptionState);
5493 } 5506 }
5494 5507
5495 void WebGLRenderingContextBase::texSubImage2D(GLenum target, 5508 void WebGLRenderingContextBase::texSubImage2D(GLenum target,
5496 GLint level, 5509 GLint level,
5497 GLint xoffset, 5510 GLint xoffset,
5498 GLint yoffset, 5511 GLint yoffset,
5499 GLenum format, 5512 GLenum format,
5500 GLenum type, 5513 GLenum type,
5501 ImageBitmap* bitmap, 5514 ImageBitmap* bitmap,
5502 ExceptionState& exceptionState) { 5515 ExceptionState& exceptionState) {
(...skipping 2224 matching lines...) Expand 10 before | Expand all | Expand 10 after
7727 7740
7728 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( 7741 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas(
7729 HTMLCanvasElementOrOffscreenCanvas& result) const { 7742 HTMLCanvasElementOrOffscreenCanvas& result) const {
7730 if (canvas()) 7743 if (canvas())
7731 result.setHTMLCanvasElement(canvas()); 7744 result.setHTMLCanvasElement(canvas());
7732 else 7745 else
7733 result.setOffscreenCanvas(getOffscreenCanvas()); 7746 result.setOffscreenCanvas(getOffscreenCanvas());
7734 } 7747 }
7735 7748
7736 } // namespace blink 7749 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698