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

Side by Side Diff: remoting/client/software_video_renderer.cc

Issue 1236663002: Allow shaped-desktop hosts to send shape only when it changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Pepper 2D renderer build Created 5 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
« no previous file with comments | « remoting/client/software_video_renderer.h ('k') | remoting/codec/audio_decoder_opus.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/software_video_renderer.h" 5 #include "remoting/client/software_video_renderer.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 } 73 }
74 74
75 private: 75 private:
76 scoped_ptr<VideoDecoder> parent_; 76 scoped_ptr<VideoDecoder> parent_;
77 }; 77 };
78 78
79 class SoftwareVideoRenderer::Core { 79 class SoftwareVideoRenderer::Core {
80 public: 80 public:
81 Core(scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 81 Core(scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
82 scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner, 82 scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner,
83 scoped_refptr<FrameConsumerProxy> consumer); 83 scoped_ptr<FrameConsumerProxy> consumer);
84 ~Core(); 84 ~Core();
85 85
86 void OnSessionConfig(const protocol::SessionConfig& config); 86 void OnSessionConfig(const protocol::SessionConfig& config);
87 void DrawBuffer(webrtc::DesktopFrame* buffer); 87 void DrawBuffer(webrtc::DesktopFrame* buffer);
88 void InvalidateRegion(const webrtc::DesktopRegion& region); 88 void InvalidateRegion(const webrtc::DesktopRegion& region);
89 void RequestReturnBuffers(const base::Closure& done); 89 void RequestReturnBuffers(const base::Closure& done);
90 void SetOutputSizeAndClip( 90 void SetOutputSizeAndClip(
91 const webrtc::DesktopSize& view_size, 91 const webrtc::DesktopSize& view_size,
92 const webrtc::DesktopRect& clip_area); 92 const webrtc::DesktopRect& clip_area);
93 93
94 // Decodes the contents of |packet|. DecodePacket may keep a reference to 94 // Decodes the contents of |packet|. DecodePacket may keep a reference to
95 // |packet| so the |packet| must remain alive and valid until |done| is 95 // |packet| so the |packet| must remain alive and valid until |done| is
96 // executed. 96 // executed.
97 void DecodePacket(scoped_ptr<VideoPacket> packet, const base::Closure& done); 97 void DecodePacket(scoped_ptr<VideoPacket> packet, const base::Closure& done);
98 98
99 private: 99 private:
100 // Paints the invalidated region to the next available buffer and returns it 100 // Paints the invalidated region to the next available buffer and returns it
101 // to the consumer. 101 // to the consumer.
102 void SchedulePaint(); 102 void SchedulePaint();
103 void DoPaint(); 103 void DoPaint();
104 104
105 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; 105 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
106 scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner_; 106 scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner_;
107 scoped_refptr<FrameConsumerProxy> consumer_; 107 scoped_ptr<FrameConsumerProxy> consumer_;
108 scoped_ptr<VideoDecoder> decoder_; 108 scoped_ptr<VideoDecoder> decoder_;
109 109
110 // Remote screen size in pixels. 110 // Remote screen size in pixels.
111 webrtc::DesktopSize source_size_; 111 webrtc::DesktopSize source_size_;
112 112
113 // Vertical and horizontal DPI of the remote screen. 113 // Vertical and horizontal DPI of the remote screen.
114 webrtc::DesktopVector source_dpi_; 114 webrtc::DesktopVector source_dpi_;
115 115
116 // The current dimensions of the frame consumer view. 116 // The current dimensions of the frame consumer view.
117 webrtc::DesktopSize view_size_; 117 webrtc::DesktopSize view_size_;
118 webrtc::DesktopRect clip_area_; 118 webrtc::DesktopRect clip_area_;
119 119
120 // The drawing buffers supplied by the frame consumer. 120 // The drawing buffers supplied by the frame consumer.
121 std::list<webrtc::DesktopFrame*> buffers_; 121 std::list<webrtc::DesktopFrame*> buffers_;
122 122
123 // Flag used to coalesce runs of SchedulePaint()s into a single DoPaint(). 123 // Flag used to coalesce runs of SchedulePaint()s into a single DoPaint().
124 bool paint_scheduled_; 124 bool paint_scheduled_;
125 125
126 base::WeakPtrFactory<Core> weak_factory_; 126 base::WeakPtrFactory<Core> weak_factory_;
127 }; 127 };
128 128
129 SoftwareVideoRenderer::Core::Core( 129 SoftwareVideoRenderer::Core::Core(
130 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 130 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
131 scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner, 131 scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner,
132 scoped_refptr<FrameConsumerProxy> consumer) 132 scoped_ptr<FrameConsumerProxy> consumer)
133 : main_task_runner_(main_task_runner), 133 : main_task_runner_(main_task_runner),
134 decode_task_runner_(decode_task_runner), 134 decode_task_runner_(decode_task_runner),
135 consumer_(consumer), 135 consumer_(consumer.Pass()),
136 paint_scheduled_(false), 136 paint_scheduled_(false),
137 weak_factory_(this) { 137 weak_factory_(this) {}
138 }
139 138
140 SoftwareVideoRenderer::Core::~Core() { 139 SoftwareVideoRenderer::Core::~Core() {
141 } 140 }
142 141
143 void SoftwareVideoRenderer::Core::OnSessionConfig(const SessionConfig& config) { 142 void SoftwareVideoRenderer::Core::OnSessionConfig(const SessionConfig& config) {
144 DCHECK(decode_task_runner_->BelongsToCurrentThread()); 143 DCHECK(decode_task_runner_->BelongsToCurrentThread());
145 144
146 // Initialize decoder based on the selected codec. 145 // Initialize decoder based on the selected codec.
147 ChannelConfig::Codec codec = config.video_config().codec; 146 ChannelConfig::Codec codec = config.video_config().codec;
148 if (codec == ChannelConfig::CODEC_VERBATIM) { 147 if (codec == ChannelConfig::CODEC_VERBATIM) {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 // Draw the invalidated region to the buffer. 234 // Draw the invalidated region to the buffer.
236 webrtc::DesktopFrame* buffer = buffers_.front(); 235 webrtc::DesktopFrame* buffer = buffers_.front();
237 webrtc::DesktopRegion output_region; 236 webrtc::DesktopRegion output_region;
238 decoder_->RenderFrame(view_size_, clip_area_, 237 decoder_->RenderFrame(view_size_, clip_area_,
239 buffer->data(), buffer->stride(), &output_region); 238 buffer->data(), buffer->stride(), &output_region);
240 239
241 // Notify the consumer that painting is done. 240 // Notify the consumer that painting is done.
242 if (!output_region.is_empty()) { 241 if (!output_region.is_empty()) {
243 buffers_.pop_front(); 242 buffers_.pop_front();
244 consumer_->ApplyBuffer(view_size_, clip_area_, buffer, output_region, 243 consumer_->ApplyBuffer(view_size_, clip_area_, buffer, output_region,
245 *decoder_->GetImageShape()); 244 decoder_->GetImageShape());
246 } 245 }
247 } 246 }
248 247
249 void SoftwareVideoRenderer::Core::RequestReturnBuffers( 248 void SoftwareVideoRenderer::Core::RequestReturnBuffers(
250 const base::Closure& done) { 249 const base::Closure& done) {
251 DCHECK(decode_task_runner_->BelongsToCurrentThread()); 250 DCHECK(decode_task_runner_->BelongsToCurrentThread());
252 251
253 while (!buffers_.empty()) { 252 while (!buffers_.empty()) {
254 consumer_->ReturnBuffer(buffers_.front()); 253 consumer_->ReturnBuffer(buffers_.front());
255 buffers_.pop_front(); 254 buffers_.pop_front();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 } 307 }
309 } 308 }
310 309
311 SchedulePaint(); 310 SchedulePaint();
312 } 311 }
313 } 312 }
314 313
315 SoftwareVideoRenderer::SoftwareVideoRenderer( 314 SoftwareVideoRenderer::SoftwareVideoRenderer(
316 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 315 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
317 scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner, 316 scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner,
318 scoped_refptr<FrameConsumerProxy> consumer) 317 scoped_ptr<FrameConsumerProxy> consumer)
319 : decode_task_runner_(decode_task_runner), 318 : decode_task_runner_(decode_task_runner),
320 core_(new Core(main_task_runner, decode_task_runner, consumer)), 319 core_(new Core(main_task_runner, decode_task_runner, consumer.Pass())),
321 latest_event_timestamp_(0), 320 latest_event_timestamp_(0),
322 weak_factory_(this) { 321 weak_factory_(this) {
323 DCHECK(CalledOnValidThread()); 322 DCHECK(CalledOnValidThread());
324 } 323 }
325 324
326 SoftwareVideoRenderer::~SoftwareVideoRenderer() { 325 SoftwareVideoRenderer::~SoftwareVideoRenderer() {
327 DCHECK(CalledOnValidThread()); 326 DCHECK(CalledOnValidThread());
328 bool result = decode_task_runner_->DeleteSoon(FROM_HERE, core_.release()); 327 bool result = decode_task_runner_->DeleteSoon(FROM_HERE, core_.release());
329 DCHECK(result); 328 DCHECK(result);
330 } 329 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 DCHECK(CalledOnValidThread()); 423 DCHECK(CalledOnValidThread());
425 424
426 // Record the latency between the packet being received and presented. 425 // Record the latency between the packet being received and presented.
427 stats_.video_decode_ms()->Record( 426 stats_.video_decode_ms()->Record(
428 (base::Time::Now() - decode_start).InMilliseconds()); 427 (base::Time::Now() - decode_start).InMilliseconds());
429 428
430 done.Run(); 429 done.Run();
431 } 430 }
432 431
433 } // namespace remoting 432 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/software_video_renderer.h ('k') | remoting/codec/audio_decoder_opus.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698