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

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: 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
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 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 } 415 }
416 416
417 bool WebMediaPlayerMS::copyVideoTextureToPlatformTexture( 417 bool WebMediaPlayerMS::copyVideoTextureToPlatformTexture(
418 blink::WebGraphicsContext3D* web_graphics_context, 418 blink::WebGraphicsContext3D* web_graphics_context,
419 unsigned int texture, 419 unsigned int texture,
420 unsigned int internal_format, 420 unsigned int internal_format,
421 unsigned int type, 421 unsigned int type,
422 bool premultiply_alpha, 422 bool premultiply_alpha,
423 bool flip_y) { 423 bool flip_y) {
424 TRACE_EVENT0("media", "WebMediaPlayerMS:copyVideoTextureToPlatformTexture"); 424 TRACE_EVENT0("media", "WebMediaPlayerMS:copyVideoTextureToPlatformTexture");
425 // TODO(dshwang): not include gl2.h because this method will be removed soon.
426 const unsigned int GL_TEXTURE_2D = 0x0DE1;
427 return copyVideoTextureToPlatformTexture(web_graphics_context, GL_TEXTURE_2D,
428 texture, internal_format, type, 0,
429 premultiply_alpha, flip_y);
430 }
431
432 bool WebMediaPlayerMS::copyVideoTextureToPlatformTexture(
433 blink::WebGraphicsContext3D* web_graphics_context,
434 unsigned int target,
435 unsigned int texture,
436 unsigned int internal_format,
437 unsigned int type,
438 int level,
439 bool premultiply_alpha,
440 bool flip_y) {
441 TRACE_EVENT0("media", "WebMediaPlayerMS:copyVideoTextureToPlatformTexture");
425 DCHECK(thread_checker_.CalledOnValidThread()); 442 DCHECK(thread_checker_.CalledOnValidThread());
426 443
427 scoped_refptr<media::VideoFrame> video_frame; 444 scoped_refptr<media::VideoFrame> video_frame;
428 { 445 {
429 base::AutoLock auto_lock(current_frame_lock_); 446 base::AutoLock auto_lock(current_frame_lock_);
430 video_frame = current_frame_; 447 video_frame = current_frame_;
431 } 448 }
432 449
433 if (!video_frame.get() || video_frame->HasTextures() || 450 if (!video_frame.get() || video_frame->HasTextures() ||
434 media::VideoFrame::NumPlanes(video_frame->format()) != 1) { 451 media::VideoFrame::NumPlanes(video_frame->format()) != 1) {
435 return false; 452 return false;
436 } 453 }
437 454
438 // TODO(dshwang): need more elegant way to convert WebGraphicsContext3D to 455 // TODO(dshwang): need more elegant way to convert WebGraphicsContext3D to
439 // GLES2Interface. 456 // GLES2Interface.
440 gpu::gles2::GLES2Interface* const gl = 457 gpu::gles2::GLES2Interface* const gl =
441 static_cast<gpu_blink::WebGraphicsContext3DImpl*>(web_graphics_context) 458 static_cast<gpu_blink::WebGraphicsContext3DImpl*>(web_graphics_context)
442 ->GetGLInterface(); 459 ->GetGLInterface();
443 media::SkCanvasVideoRenderer::CopyVideoFrameSingleTextureToGLTexture( 460 media::SkCanvasVideoRenderer::CopyVideoFrameSingleTextureToGLTexture(
444 gl, video_frame.get(), texture, internal_format, type, premultiply_alpha, 461 gl, video_frame.get(), target, texture, internal_format, type, level,
445 flip_y); 462 premultiply_alpha, flip_y);
446 return true; 463 return true;
447 } 464 }
448 465
466 bool WebMediaPlayerMS::copyVideoSubTextureToPlatformTexture(
467 blink::WebGraphicsContext3D* web_graphics_context,
468 unsigned int target,
469 unsigned int texture,
470 int level,
471 int xoffset,
472 int yoffset,
473 bool premultiply_alpha,
474 bool flip_y) {
475 TRACE_EVENT0("media",
476 "WebMediaPlayerMS:copyVideoSubTextureToPlatformTexture");
477 DCHECK(thread_checker_.CalledOnValidThread());
478
479 scoped_refptr<media::VideoFrame> video_frame;
480 {
481 base::AutoLock auto_lock(current_frame_lock_);
482 video_frame = current_frame_;
483 }
484
485 if (!video_frame.get() || video_frame->HasTextures() ||
486 media::VideoFrame::NumPlanes(video_frame->format()) != 1) {
487 return false;
488 }
489
490 // TODO(dshwang): need more elegant way to convert WebGraphicsContext3D to
491 // GLES2Interface.
492 gpu::gles2::GLES2Interface* gl =
493 static_cast<gpu_blink::WebGraphicsContext3DImpl*>(web_graphics_context)
494 ->GetGLInterface();
495 media::SkCanvasVideoRenderer::CopySubVideoFrameSingleTextureToGLTexture(
496 gl, video_frame.get(), target, texture, level, xoffset, yoffset,
497 premultiply_alpha, flip_y);
498 return true;
499 }
500
449 void WebMediaPlayerMS::SetVideoFrameProviderClient( 501 void WebMediaPlayerMS::SetVideoFrameProviderClient(
450 cc::VideoFrameProvider::Client* client) { 502 cc::VideoFrameProvider::Client* client) {
451 // This is called from both the main renderer thread and the compositor 503 // This is called from both the main renderer thread and the compositor
452 // thread (when the main thread is blocked). 504 // thread (when the main thread is blocked).
453 if (video_frame_provider_client_) 505 if (video_frame_provider_client_)
454 video_frame_provider_client_->StopUsingProvider(); 506 video_frame_provider_client_->StopUsingProvider();
455 video_frame_provider_client_ = client; 507 video_frame_provider_client_ = client;
456 } 508 }
457 509
458 bool WebMediaPlayerMS::UpdateCurrentFrame(base::TimeTicks deadline_min, 510 bool WebMediaPlayerMS::UpdateCurrentFrame(base::TimeTicks deadline_min,
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 GetClient()->readyStateChanged(); 608 GetClient()->readyStateChanged();
557 } 609 }
558 610
559 blink::WebMediaPlayerClient* WebMediaPlayerMS::GetClient() { 611 blink::WebMediaPlayerClient* WebMediaPlayerMS::GetClient() {
560 DCHECK(thread_checker_.CalledOnValidThread()); 612 DCHECK(thread_checker_.CalledOnValidThread());
561 DCHECK(client_); 613 DCHECK(client_);
562 return client_; 614 return client_;
563 } 615 }
564 616
565 } // namespace content 617 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698