Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "remoting/client/plugin/pepper_video_renderer_2d.h" | 5 #include "remoting/client/plugin/pepper_video_renderer_2d.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 } // namespace | 55 } // namespace |
| 56 | 56 |
| 57 PepperVideoRenderer2D::PepperVideoRenderer2D() | 57 PepperVideoRenderer2D::PepperVideoRenderer2D() |
| 58 : callback_factory_(this), | 58 : callback_factory_(this), |
| 59 weak_factory_(this) {} | 59 weak_factory_(this) {} |
| 60 | 60 |
| 61 PepperVideoRenderer2D::~PepperVideoRenderer2D() {} | 61 PepperVideoRenderer2D::~PepperVideoRenderer2D() {} |
| 62 | 62 |
| 63 bool PepperVideoRenderer2D::Initialize( | 63 bool PepperVideoRenderer2D::SetPepperContext( |
| 64 pp::Instance* instance, | 64 pp::Instance* instance, |
| 65 const ClientContext& context, | 65 EventHandler* event_handler) { |
| 66 EventHandler* event_handler, | |
| 67 protocol::PerformanceTracker* perf_tracker) { | |
| 68 DCHECK(thread_checker_.CalledOnValidThread()); | 66 DCHECK(thread_checker_.CalledOnValidThread()); |
| 69 DCHECK(!instance_); | 67 DCHECK(!instance_); |
| 70 DCHECK(!event_handler_); | 68 DCHECK(!event_handler_); |
| 71 DCHECK(instance); | 69 DCHECK(instance); |
| 72 DCHECK(event_handler); | 70 DCHECK(event_handler); |
| 73 | 71 |
| 74 instance_ = instance; | 72 instance_ = instance; |
| 75 event_handler_ = event_handler; | 73 event_handler_ = event_handler; |
| 76 software_video_renderer_.reset(new SoftwareVideoRenderer( | |
| 77 context.decode_task_runner(), this, perf_tracker)); | |
| 78 | 74 |
| 79 return true; | 75 return true; |
| 80 } | 76 } |
| 81 | 77 |
| 82 void PepperVideoRenderer2D::OnViewChanged(const pp::View& view) { | 78 void PepperVideoRenderer2D::OnViewChanged(const pp::View& view) { |
| 83 DCHECK(thread_checker_.CalledOnValidThread()); | 79 DCHECK(thread_checker_.CalledOnValidThread()); |
| 84 | 80 |
| 85 pp::Rect pp_size = view.GetRect(); | 81 pp::Rect pp_size = view.GetRect(); |
| 86 view_size_ = webrtc::DesktopSize(pp_size.width(), pp_size.height()); | 82 view_size_ = webrtc::DesktopSize(pp_size.width(), pp_size.height()); |
| 87 | 83 |
| 88 // Update scale if graphics2d has been initialized. | 84 // Update scale if graphics2d has been initialized. |
| 89 if (!graphics2d_.is_null() && source_size_.width() > 0) { | 85 if (!graphics2d_.is_null() && source_size_.width() > 0) { |
| 90 graphics2d_.SetScale(static_cast<float>(view_size_.width()) / | 86 graphics2d_.SetScale(static_cast<float>(view_size_.width()) / |
| 91 source_size_.width()); | 87 source_size_.width()); |
| 92 | 88 |
| 93 // Bind graphics2d_ again after changing the scale to work around | 89 // Bind graphics2d_ again after changing the scale to work around |
| 94 // crbug.com/521745 . | 90 // crbug.com/521745 . |
| 95 instance_->BindGraphics(graphics2d_); | 91 instance_->BindGraphics(graphics2d_); |
| 96 bool result = instance_->BindGraphics(graphics2d_); | 92 bool result = instance_->BindGraphics(graphics2d_); |
| 97 DCHECK(result) << "Couldn't bind the device context."; | 93 DCHECK(result) << "Couldn't bind the device context."; |
| 98 } | 94 } |
| 99 } | 95 } |
| 100 | 96 |
| 101 void PepperVideoRenderer2D::EnableDebugDirtyRegion(bool enable) { | 97 void PepperVideoRenderer2D::EnableDebugDirtyRegion(bool enable) { |
| 102 debug_dirty_region_ = enable; | 98 debug_dirty_region_ = enable; |
| 103 } | 99 } |
| 104 | 100 |
| 101 bool PepperVideoRenderer2D::Initialize( | |
| 102 const ClientContext& client_context, | |
| 103 protocol::PerformanceTracker* perf_tracker) { | |
| 104 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 105 | |
| 106 software_video_renderer_.reset(new SoftwareVideoRenderer( | |
|
Sergey Ulanov
2016/06/28 19:08:01
Since now SoftwareVideoRenderer() now has Initiali
Yuwei
2016/06/28 21:43:03
Done.
| |
| 107 client_context.decode_task_runner(), this, perf_tracker)); | |
| 108 | |
|
Sergey Ulanov
2016/06/28 19:08:01
Need to call software_video_renderer_->Initialize(
Yuwei
2016/06/28 21:43:03
Done.
| |
| 109 return true; | |
| 110 } | |
| 111 | |
| 105 void PepperVideoRenderer2D::OnSessionConfig( | 112 void PepperVideoRenderer2D::OnSessionConfig( |
| 106 const protocol::SessionConfig& config) { | 113 const protocol::SessionConfig& config) { |
| 107 DCHECK(thread_checker_.CalledOnValidThread()); | 114 DCHECK(thread_checker_.CalledOnValidThread()); |
| 108 | 115 |
| 109 software_video_renderer_->OnSessionConfig(config); | 116 software_video_renderer_->OnSessionConfig(config); |
| 110 } | 117 } |
| 111 | 118 |
| 112 protocol::VideoStub* PepperVideoRenderer2D::GetVideoStub() { | 119 protocol::VideoStub* PepperVideoRenderer2D::GetVideoStub() { |
| 113 DCHECK(thread_checker_.CalledOnValidThread()); | 120 DCHECK(thread_checker_.CalledOnValidThread()); |
| 114 | 121 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 flush_pending_ = false; | 215 flush_pending_ = false; |
| 209 | 216 |
| 210 // Call all callbacks for the frames we've just flushed. | 217 // Call all callbacks for the frames we've just flushed. |
| 211 flushing_frames_done_callbacks_.clear(); | 218 flushing_frames_done_callbacks_.clear(); |
| 212 | 219 |
| 213 // Flush again if necessary. | 220 // Flush again if necessary. |
| 214 Flush(); | 221 Flush(); |
| 215 } | 222 } |
| 216 | 223 |
| 217 } // namespace remoting | 224 } // namespace remoting |
| OLD | NEW |