OLD | NEW |
---|---|
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/common/gpu/media/rendering_helper.h" | 5 #include "content/common/gpu/media/rendering_helper.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <numeric> | 8 #include <numeric> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 texture_id_(texture_id), | 68 texture_id_(texture_id), |
69 no_longer_needed_cb_(no_longer_needed_cb) { | 69 no_longer_needed_cb_(no_longer_needed_cb) { |
70 DCHECK(!no_longer_needed_cb_.is_null()); | 70 DCHECK(!no_longer_needed_cb_.is_null()); |
71 } | 71 } |
72 | 72 |
73 VideoFrameTexture::~VideoFrameTexture() { | 73 VideoFrameTexture::~VideoFrameTexture() { |
74 base::ResetAndReturn(&no_longer_needed_cb_).Run(); | 74 base::ResetAndReturn(&no_longer_needed_cb_).Run(); |
75 } | 75 } |
76 | 76 |
77 RenderingHelper::RenderedVideo::RenderedVideo() | 77 RenderingHelper::RenderedVideo::RenderedVideo() |
78 : last_frame_rendered(false), is_flushing(false) { | 78 : last_frame_rendered(false), is_flushing(false), frames_to_drop(0) { |
79 } | 79 } |
80 | 80 |
81 RenderingHelper::RenderedVideo::~RenderedVideo() { | 81 RenderingHelper::RenderedVideo::~RenderedVideo() { |
82 } | 82 } |
83 | 83 |
84 // static | 84 // static |
85 bool RenderingHelper::InitializeOneOff() { | 85 bool RenderingHelper::InitializeOneOff() { |
86 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 86 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
87 #if GL_VARIANT_GLX | 87 #if GL_VARIANT_GLX |
88 cmd_line->AppendSwitchASCII(switches::kUseGL, | 88 cmd_line->AppendSwitchASCII(switches::kUseGL, |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
391 ++frame_count_; | 391 ++frame_count_; |
392 } | 392 } |
393 | 393 |
394 void RenderingHelper::QueueVideoFrame( | 394 void RenderingHelper::QueueVideoFrame( |
395 size_t window_id, | 395 size_t window_id, |
396 scoped_refptr<VideoFrameTexture> video_frame) { | 396 scoped_refptr<VideoFrameTexture> video_frame) { |
397 CHECK_EQ(base::MessageLoop::current(), message_loop_); | 397 CHECK_EQ(base::MessageLoop::current(), message_loop_); |
398 RenderedVideo* video = &videos_[window_id]; | 398 RenderedVideo* video = &videos_[window_id]; |
399 DCHECK(!video->is_flushing); | 399 DCHECK(!video->is_flushing); |
400 | 400 |
401 if (video->frames_to_drop > 0) { | |
402 --video->frames_to_drop; | |
acolwell GONE FROM CHROMIUM
2014/09/16 19:10:39
Is this frame dropping visible outside this code i
Owen Lin
2014/09/17 02:48:35
The code is only used in the vda_unittest. It won'
| |
403 return; | |
404 } | |
405 | |
401 // Pop the last frame if it has been rendered. | 406 // Pop the last frame if it has been rendered. |
402 if (video->last_frame_rendered) { | 407 if (video->last_frame_rendered) { |
403 // When last_frame_rendered is true, we should have only one pending frame. | 408 // When last_frame_rendered is true, we should have only one pending frame. |
404 // Since we are going to have a new frame, we can release the pending one. | 409 // Since we are going to have a new frame, we can release the pending one. |
405 DCHECK(video->pending_frames.size() == 1); | 410 DCHECK(video->pending_frames.size() == 1); |
406 video->pending_frames.pop(); | 411 video->pending_frames.pop(); |
407 video->last_frame_rendered = false; | 412 video->last_frame_rendered = false; |
408 } | 413 } |
409 | 414 |
410 video->pending_frames.push(video_frame); | 415 video->pending_frames.push(video_frame); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
518 RenderTexture(GL_TEXTURE_2D, thumbnails_texture_id_); | 523 RenderTexture(GL_TEXTURE_2D, thumbnails_texture_id_); |
519 } else { | 524 } else { |
520 for (size_t i = 0; i < videos_.size(); ++i) { | 525 for (size_t i = 0; i < videos_.size(); ++i) { |
521 RenderedVideo* video = &videos_[i]; | 526 RenderedVideo* video = &videos_[i]; |
522 if (video->pending_frames.empty()) | 527 if (video->pending_frames.empty()) |
523 continue; | 528 continue; |
524 scoped_refptr<VideoFrameTexture> frame = video->pending_frames.front(); | 529 scoped_refptr<VideoFrameTexture> frame = video->pending_frames.front(); |
525 GLSetViewPort(video->render_area); | 530 GLSetViewPort(video->render_area); |
526 RenderTexture(frame->texture_target(), frame->texture_id()); | 531 RenderTexture(frame->texture_target(), frame->texture_id()); |
527 | 532 |
533 if (video->last_frame_rendered) | |
Pawel Osciak
2014/09/15 14:09:34
Please note here that we won't start dropping befo
Owen Lin
2014/09/16 01:38:34
That's the expected behavior, we always wait for t
| |
534 ++video->frames_to_drop; | |
535 | |
528 if (video->pending_frames.size() > 1 || video->is_flushing) { | 536 if (video->pending_frames.size() > 1 || video->is_flushing) { |
529 frames_to_be_returned.push_back(video->pending_frames.front()); | 537 frames_to_be_returned.push_back(video->pending_frames.front()); |
530 video->pending_frames.pop(); | 538 video->pending_frames.pop(); |
531 video->last_frame_rendered = false; | 539 video->last_frame_rendered = false; |
532 } else { | 540 } else { |
533 video->last_frame_rendered = true; | 541 video->last_frame_rendered = true; |
534 } | 542 } |
535 } | 543 } |
536 } | 544 } |
537 | 545 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
585 scale = std::min(1.0f, scale); | 593 scale = std::min(1.0f, scale); |
586 | 594 |
587 size_t w = scale * size.width(); | 595 size_t w = scale * size.width(); |
588 size_t h = scale * size.height(); | 596 size_t h = scale * size.height(); |
589 size_t x = offset_x[i % cols] + (widths[i % cols] - w) / 2; | 597 size_t x = offset_x[i % cols] + (widths[i % cols] - w) / 2; |
590 size_t y = offset_y[i / cols] + (heights[i / cols] - h) / 2; | 598 size_t y = offset_y[i / cols] + (heights[i / cols] - h) / 2; |
591 videos_[i].render_area = gfx::Rect(x, y, w, h); | 599 videos_[i].render_area = gfx::Rect(x, y, w, h); |
592 } | 600 } |
593 } | 601 } |
594 } // namespace content | 602 } // namespace content |
OLD | NEW |