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

Side by Side Diff: content/renderer/media/webmediaplayer_ms.cc

Issue 1315323006: webgl: optimize webgl.texSubImage2D(video) path. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix canvas2d-webgl failures Created 5 years, 2 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/webmediaplayer_ms.h" 5 #include "content/renderer/media/webmediaplayer_ms.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 } 341 }
342 342
343 unsigned WebMediaPlayerMS::videoDecodedByteCount() const { 343 unsigned WebMediaPlayerMS::videoDecodedByteCount() const {
344 DCHECK(thread_checker_.CalledOnValidThread()); 344 DCHECK(thread_checker_.CalledOnValidThread());
345 NOTIMPLEMENTED(); 345 NOTIMPLEMENTED();
346 return 0; 346 return 0;
347 } 347 }
348 348
349 bool WebMediaPlayerMS::copyVideoTextureToPlatformTexture( 349 bool WebMediaPlayerMS::copyVideoTextureToPlatformTexture(
350 blink::WebGraphicsContext3D* web_graphics_context, 350 blink::WebGraphicsContext3D* web_graphics_context,
351 unsigned int texture, 351 const CopyVideoTextureParams& params) {
352 unsigned int internal_format,
353 unsigned int type,
354 bool premultiply_alpha,
355 bool flip_y) {
356 TRACE_EVENT0("media", "WebMediaPlayerMS:copyVideoTextureToPlatformTexture"); 352 TRACE_EVENT0("media", "WebMediaPlayerMS:copyVideoTextureToPlatformTexture");
357 DCHECK(thread_checker_.CalledOnValidThread()); 353 DCHECK(thread_checker_.CalledOnValidThread());
354 DCHECK((params.copyType == CopyVideoTextureParams::FullCopy &&
355 !params.xoffset && !params.yoffset) ||
356 (params.copyType == CopyVideoTextureParams::SubCopy &&
357 !params.internalFormat && !params.type));
358 358
359 scoped_refptr<media::VideoFrame> video_frame = compositor_->GetCurrentFrame(); 359 scoped_refptr<media::VideoFrame> video_frame = compositor_->GetCurrentFrame();
360 360
361 if (!video_frame.get() || video_frame->HasTextures() || 361 if (!video_frame.get() || video_frame->HasTextures() ||
362 media::VideoFrame::NumPlanes(video_frame->format()) != 1) { 362 media::VideoFrame::NumPlanes(video_frame->format()) != 1) {
363 return false; 363 return false;
364 } 364 }
365 365
366 // TODO(dshwang): need more elegant way to convert WebGraphicsContext3D to 366 // TODO(dshwang): need more elegant way to convert WebGraphicsContext3D to
367 // GLES2Interface. 367 // GLES2Interface.
368 gpu::gles2::GLES2Interface* const gl = 368 gpu::gles2::GLES2Interface* const gl =
369 static_cast<gpu_blink::WebGraphicsContext3DImpl*>(web_graphics_context) 369 static_cast<gpu_blink::WebGraphicsContext3DImpl*>(web_graphics_context)
370 ->GetGLInterface(); 370 ->GetGLInterface();
371 media::SkCanvasVideoRenderer::CopyVideoFrameSingleTextureToGLTexture( 371 media::SkCanvasVideoRenderer::CopyVideoFrameSingleTextureToGLTexture(
372 gl, video_frame.get(), texture, internal_format, type, premultiply_alpha, 372 gl, video_frame.get(),
373 flip_y); 373 {params.copyType == CopyVideoTextureParams::FullCopy
DaleCurtis 2015/10/21 18:35:50 Ditto.
374 ? media::SkCanvasVideoRenderer::CopyFrameSingleTextureParams::
375 FullCopy
376 : media::SkCanvasVideoRenderer::CopyFrameSingleTextureParams::
377 SubCopy,
378 params.target, params.texture, params.internalFormat, params.type,
379 params.level, params.xoffset, params.yoffset, params.premultiplyAlpha,
380 params.flipY});
374 return true; 381 return true;
375 } 382 }
376 383
377 void WebMediaPlayerMS::OnFrameAvailable( 384 void WebMediaPlayerMS::OnFrameAvailable(
378 const scoped_refptr<media::VideoFrame>& frame) { 385 const scoped_refptr<media::VideoFrame>& frame) {
379 DVLOG(3) << __FUNCTION__; 386 DVLOG(3) << __FUNCTION__;
380 DCHECK(thread_checker_.CalledOnValidThread()); 387 DCHECK(thread_checker_.CalledOnValidThread());
381 388
382 base::TimeTicks render_time; 389 base::TimeTicks render_time;
383 if (frame->metadata()->GetTimeTicks(media::VideoFrameMetadata::REFERENCE_TIME, 390 if (frame->metadata()->GetTimeTicks(media::VideoFrameMetadata::REFERENCE_TIME,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 get_client()->networkStateChanged(); 440 get_client()->networkStateChanged();
434 } 441 }
435 442
436 void WebMediaPlayerMS::SetReadyState(WebMediaPlayer::ReadyState state) { 443 void WebMediaPlayerMS::SetReadyState(WebMediaPlayer::ReadyState state) {
437 DCHECK(thread_checker_.CalledOnValidThread()); 444 DCHECK(thread_checker_.CalledOnValidThread());
438 ready_state_ = state; 445 ready_state_ = state;
439 // Always notify to ensure client has the latest value. 446 // Always notify to ensure client has the latest value.
440 get_client()->readyStateChanged(); 447 get_client()->readyStateChanged();
441 } 448 }
442 } // namespace content 449 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698