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

Side by Side Diff: remoting/client/plugin/pepper_video_renderer_2d.cc

Issue 2101833002: [Remoting Android] DisplayUpdaterFactory cleanups (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reviewer's Feedback Created 4 years, 5 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 (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
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/callback_helpers.h" 12 #include "base/callback_helpers.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "base/task_runner_util.h" 15 #include "base/task_runner_util.h"
16 #include "ppapi/cpp/completion_callback.h" 16 #include "ppapi/cpp/completion_callback.h"
17 #include "ppapi/cpp/image_data.h" 17 #include "ppapi/cpp/image_data.h"
18 #include "ppapi/cpp/instance.h" 18 #include "ppapi/cpp/instance.h"
19 #include "ppapi/cpp/point.h" 19 #include "ppapi/cpp/point.h"
20 #include "ppapi/cpp/rect.h" 20 #include "ppapi/cpp/rect.h"
21 #include "ppapi/cpp/size.h" 21 #include "ppapi/cpp/size.h"
22 #include "remoting/base/util.h" 22 #include "remoting/base/util.h"
23 #include "remoting/client/client_context.h" 23 #include "remoting/client/client_context.h"
24 #include "remoting/client/software_video_renderer.h"
25 #include "remoting/proto/video.pb.h" 24 #include "remoting/proto/video.pb.h"
26 #include "remoting/protocol/performance_tracker.h" 25 #include "remoting/protocol/performance_tracker.h"
27 #include "third_party/libyuv/include/libyuv/scale_argb.h" 26 #include "third_party/libyuv/include/libyuv/scale_argb.h"
28 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" 27 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
29 28
30 namespace remoting { 29 namespace remoting {
31 30
32 namespace { 31 namespace {
33 32
34 // DesktopFrame that wraps a supplied pp::ImageData 33 // DesktopFrame that wraps a supplied pp::ImageData
(...skipping 13 matching lines...) Expand all
48 return buffer_; 47 return buffer_;
49 } 48 }
50 49
51 private: 50 private:
52 pp::ImageData buffer_; 51 pp::ImageData buffer_;
53 }; 52 };
54 53
55 } // namespace 54 } // namespace
56 55
57 PepperVideoRenderer2D::PepperVideoRenderer2D() 56 PepperVideoRenderer2D::PepperVideoRenderer2D()
58 : callback_factory_(this), 57 : software_video_renderer_(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 void 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
79 return true;
80 } 74 }
81 75
82 void PepperVideoRenderer2D::OnViewChanged(const pp::View& view) { 76 void PepperVideoRenderer2D::OnViewChanged(const pp::View& view) {
83 DCHECK(thread_checker_.CalledOnValidThread()); 77 DCHECK(thread_checker_.CalledOnValidThread());
84 78
85 pp::Rect pp_size = view.GetRect(); 79 pp::Rect pp_size = view.GetRect();
86 view_size_ = webrtc::DesktopSize(pp_size.width(), pp_size.height()); 80 view_size_ = webrtc::DesktopSize(pp_size.width(), pp_size.height());
87 81
88 // Update scale if graphics2d has been initialized. 82 // Update scale if graphics2d has been initialized.
89 if (!graphics2d_.is_null() && source_size_.width() > 0) { 83 if (!graphics2d_.is_null() && source_size_.width() > 0) {
90 graphics2d_.SetScale(static_cast<float>(view_size_.width()) / 84 graphics2d_.SetScale(static_cast<float>(view_size_.width()) /
91 source_size_.width()); 85 source_size_.width());
92 86
93 // Bind graphics2d_ again after changing the scale to work around 87 // Bind graphics2d_ again after changing the scale to work around
94 // crbug.com/521745 . 88 // crbug.com/521745 .
95 instance_->BindGraphics(graphics2d_); 89 instance_->BindGraphics(graphics2d_);
96 bool result = instance_->BindGraphics(graphics2d_); 90 bool result = instance_->BindGraphics(graphics2d_);
97 DCHECK(result) << "Couldn't bind the device context."; 91 DCHECK(result) << "Couldn't bind the device context.";
98 } 92 }
99 } 93 }
100 94
101 void PepperVideoRenderer2D::EnableDebugDirtyRegion(bool enable) { 95 void PepperVideoRenderer2D::EnableDebugDirtyRegion(bool enable) {
102 debug_dirty_region_ = enable; 96 debug_dirty_region_ = enable;
103 } 97 }
104 98
99 bool PepperVideoRenderer2D::Initialize(
100 const ClientContext& client_context,
101 protocol::PerformanceTracker* perf_tracker) {
102 DCHECK(thread_checker_.CalledOnValidThread());
103
104 return software_video_renderer_.Initialize(client_context, perf_tracker);
105 }
106
105 void PepperVideoRenderer2D::OnSessionConfig( 107 void PepperVideoRenderer2D::OnSessionConfig(
106 const protocol::SessionConfig& config) { 108 const protocol::SessionConfig& config) {
107 DCHECK(thread_checker_.CalledOnValidThread()); 109 DCHECK(thread_checker_.CalledOnValidThread());
108 110
109 software_video_renderer_->OnSessionConfig(config); 111 software_video_renderer_.OnSessionConfig(config);
110 } 112 }
111 113
112 protocol::VideoStub* PepperVideoRenderer2D::GetVideoStub() { 114 protocol::VideoStub* PepperVideoRenderer2D::GetVideoStub() {
113 DCHECK(thread_checker_.CalledOnValidThread()); 115 DCHECK(thread_checker_.CalledOnValidThread());
114 116
115 return software_video_renderer_->GetVideoStub(); 117 return software_video_renderer_.GetVideoStub();
116 } 118 }
117 119
118 protocol::FrameConsumer* PepperVideoRenderer2D::GetFrameConsumer() { 120 protocol::FrameConsumer* PepperVideoRenderer2D::GetFrameConsumer() {
119 DCHECK(thread_checker_.CalledOnValidThread()); 121 DCHECK(thread_checker_.CalledOnValidThread());
120 122
121 return software_video_renderer_->GetFrameConsumer(); 123 return software_video_renderer_.GetFrameConsumer();
122 } 124 }
123 125
124 std::unique_ptr<webrtc::DesktopFrame> PepperVideoRenderer2D::AllocateFrame( 126 std::unique_ptr<webrtc::DesktopFrame> PepperVideoRenderer2D::AllocateFrame(
125 const webrtc::DesktopSize& size) { 127 const webrtc::DesktopSize& size) {
126 DCHECK(thread_checker_.CalledOnValidThread()); 128 DCHECK(thread_checker_.CalledOnValidThread());
127 129
128 pp::ImageData buffer_data(instance_, PP_IMAGEDATAFORMAT_BGRA_PREMUL, 130 pp::ImageData buffer_data(instance_, PP_IMAGEDATAFORMAT_BGRA_PREMUL,
129 pp::Size(size.width(), size.height()), false); 131 pp::Size(size.width(), size.height()), false);
130 return base::WrapUnique(new PepperDesktopFrame(buffer_data)); 132 return base::WrapUnique(new PepperDesktopFrame(buffer_data));
131 } 133 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 flush_pending_ = false; 210 flush_pending_ = false;
209 211
210 // Call all callbacks for the frames we've just flushed. 212 // Call all callbacks for the frames we've just flushed.
211 flushing_frames_done_callbacks_.clear(); 213 flushing_frames_done_callbacks_.clear();
212 214
213 // Flush again if necessary. 215 // Flush again if necessary.
214 Flush(); 216 Flush();
215 } 217 }
216 218
217 } // namespace remoting 219 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698