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

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

Issue 2527343002: Avoid doing and then abandoning semi-accelerated texImageHelperHTMLVideoElement path. (Closed)
Patch Set: Created 4 years 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 | « no previous file | 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 5128 matching lines...) Expand 10 before | Expand all | Expand 10 after
5139 if (!validateTexFunc(funcName, functionType, SourceHTMLVideoElement, target, 5139 if (!validateTexFunc(funcName, functionType, SourceHTMLVideoElement, target,
5140 level, internalformat, video->videoWidth(), 5140 level, internalformat, video->videoWidth(),
5141 video->videoHeight(), 1, 0, format, type, xoffset, 5141 video->videoHeight(), 1, 0, format, type, xoffset,
5142 yoffset, zoffset)) 5142 yoffset, zoffset))
5143 return; 5143 return;
5144 5144
5145 bool sourceImageRectIsDefault = 5145 bool sourceImageRectIsDefault =
5146 sourceImageRect == sentinelEmptyRect() || 5146 sourceImageRect == sentinelEmptyRect() ||
5147 sourceImageRect == 5147 sourceImageRect ==
5148 IntRect(0, 0, video->videoWidth(), video->videoHeight()); 5148 IntRect(0, 0, video->videoWidth(), video->videoHeight());
5149 if (functionID == TexImage2D && sourceImageRectIsDefault && depth == 1) { 5149 if (functionID == TexImage2D && sourceImageRectIsDefault && depth == 1 &&
5150 GL_TEXTURE_2D == target && Extensions3DUtil::canUseCopyTextureCHROMIUM(
5151 target, internalformat, type, level)) {
5150 DCHECK_EQ(xoffset, 0); 5152 DCHECK_EQ(xoffset, 0);
5151 DCHECK_EQ(yoffset, 0); 5153 DCHECK_EQ(yoffset, 0);
5152 DCHECK_EQ(zoffset, 0); 5154 DCHECK_EQ(zoffset, 0);
5153 // Go through the fast path doing a GPU-GPU textures copy without a readback 5155 // Go through the fast path doing a GPU-GPU textures copy without a readback
5154 // to system memory if possible. Otherwise, it will fall back to the normal 5156 // to system memory if possible. Otherwise, it will fall back to the normal
5155 // SW path. 5157 // SW path.
5156 if (GL_TEXTURE_2D == target) { 5158 if (video->copyVideoTextureToPlatformTexture(
5157 if (Extensions3DUtil::canUseCopyTextureCHROMIUM(target, internalformat, 5159 contextGL(), texture->object(), internalformat, type,
5158 type, level) && 5160 m_unpackPremultiplyAlpha, m_unpackFlipY)) {
5159 video->copyVideoTextureToPlatformTexture( 5161 return;
5160 contextGL(), texture->object(), internalformat, type, 5162 }
5161 m_unpackPremultiplyAlpha, m_unpackFlipY)) {
5162 return;
5163 }
5164 5163
5165 // Try using an accelerated image buffer, this allows YUV conversion to be 5164 // Try using an accelerated image buffer, this allows YUV conversion to be
5166 // done on the GPU. 5165 // done on the GPU.
5167 std::unique_ptr<ImageBufferSurface> surface = 5166 std::unique_ptr<ImageBufferSurface> surface =
5168 wrapUnique(new AcceleratedImageBufferSurface( 5167 wrapUnique(new AcceleratedImageBufferSurface(
5169 IntSize(video->videoWidth(), video->videoHeight()))); 5168 IntSize(video->videoWidth(), video->videoHeight())));
5170 if (surface->isValid()) { 5169 if (surface->isValid()) {
5171 std::unique_ptr<ImageBuffer> imageBuffer( 5170 std::unique_ptr<ImageBuffer> imageBuffer(
5172 ImageBuffer::create(std::move(surface))); 5171 ImageBuffer::create(std::move(surface)));
5173 if (imageBuffer) { 5172 if (imageBuffer) {
5174 // The video element paints an RGBA frame into our surface here. By 5173 // The video element paints an RGBA frame into our surface here. By
5175 // using an AcceleratedImageBufferSurface, we enable the 5174 // using an AcceleratedImageBufferSurface, we enable the
5176 // WebMediaPlayer implementation to do any necessary color space 5175 // WebMediaPlayer implementation to do any necessary color space
5177 // conversion on the GPU (though it 5176 // conversion on the GPU (though it
5178 // may still do a CPU conversion and upload the results). 5177 // may still do a CPU conversion and upload the results).
5179 video->paintCurrentFrame( 5178 video->paintCurrentFrame(
5180 imageBuffer->canvas(), 5179 imageBuffer->canvas(),
5181 IntRect(0, 0, video->videoWidth(), video->videoHeight()), 5180 IntRect(0, 0, video->videoWidth(), video->videoHeight()), nullptr);
5182 nullptr);
5183 5181
5184 // This is a straight GPU-GPU copy, any necessary color space 5182 // This is a straight GPU-GPU copy, any necessary color space
5185 // conversion was handled in the paintCurrentFrameInContext() call. 5183 // conversion was handled in the paintCurrentFrameInContext() call.
5186 5184
5187 // Note that copyToPlatformTexture no longer allocates the 5185 // Note that copyToPlatformTexture no longer allocates the
5188 // destination texture. 5186 // destination texture.
5189 texImage2DBase(target, level, internalformat, video->videoWidth(), 5187 texImage2DBase(target, level, internalformat, video->videoWidth(),
5190 video->videoHeight(), 0, format, type, nullptr); 5188 video->videoHeight(), 0, format, type, nullptr);
5191 5189
5192 if (imageBuffer->copyToPlatformTexture( 5190 if (imageBuffer->copyToPlatformTexture(
aleksandar.stojiljkovic 2016/11/25 12:00:04 Copy from the CL description:
Ken Russell (switch to Gerrit) 2016/11/29 04:55:23 I see. Thanks for pointing that out.
5193 contextGL(), texture->object(), internalformat, type, level, 5191 contextGL(), texture->object(), internalformat, type, level,
5194 m_unpackPremultiplyAlpha, m_unpackFlipY, IntPoint(0, 0), 5192 m_unpackPremultiplyAlpha, m_unpackFlipY, IntPoint(0, 0),
5195 IntRect(0, 0, video->videoWidth(), video->videoHeight()))) { 5193 IntRect(0, 0, video->videoWidth(), video->videoHeight()))) {
5196 return; 5194 return;
5197 }
5198 } 5195 }
5199 } 5196 }
5200 } 5197 }
5201 } 5198 }
5202 5199
5203 RefPtr<Image> image = videoFrameToImage(video); 5200 RefPtr<Image> image = videoFrameToImage(video);
5204 if (!image) 5201 if (!image)
5205 return; 5202 return;
5206 texImageImpl(functionID, target, level, internalformat, xoffset, yoffset, 5203 texImageImpl(functionID, target, level, internalformat, xoffset, yoffset,
5207 zoffset, format, type, image.get(), 5204 zoffset, format, type, image.get(),
(...skipping 2563 matching lines...) Expand 10 before | Expand all | Expand 10 after
7771 7768
7772 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas( 7769 void WebGLRenderingContextBase::getHTMLOrOffscreenCanvas(
7773 HTMLCanvasElementOrOffscreenCanvas& result) const { 7770 HTMLCanvasElementOrOffscreenCanvas& result) const {
7774 if (canvas()) 7771 if (canvas())
7775 result.setHTMLCanvasElement(canvas()); 7772 result.setHTMLCanvasElement(canvas());
7776 else 7773 else
7777 result.setOffscreenCanvas(getOffscreenCanvas()); 7774 result.setOffscreenCanvas(getOffscreenCanvas());
7778 } 7775 }
7779 7776
7780 } // namespace blink 7777 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698