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

Side by Side Diff: remoting/client/plugin/pepper_video_renderer_2d.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
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 <functional> 7 #include <functional>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 const ClientContext& context, 93 const ClientContext& context,
94 EventHandler* event_handler) { 94 EventHandler* event_handler) {
95 DCHECK(CalledOnValidThread()); 95 DCHECK(CalledOnValidThread());
96 DCHECK(!instance_); 96 DCHECK(!instance_);
97 DCHECK(!event_handler_); 97 DCHECK(!event_handler_);
98 DCHECK(instance); 98 DCHECK(instance);
99 DCHECK(event_handler); 99 DCHECK(event_handler);
100 100
101 instance_ = instance; 101 instance_ = instance;
102 event_handler_ = event_handler; 102 event_handler_ = event_handler;
103 frame_consumer_proxy_ = new FrameConsumerProxy( 103 scoped_ptr<FrameConsumerProxy> frame_consumer_proxy =
104 context.main_task_runner(), weak_factory_.GetWeakPtr()); 104 make_scoped_ptr(new FrameConsumerProxy(weak_factory_.GetWeakPtr()));
105 software_video_renderer_.reset(new SoftwareVideoRenderer( 105 software_video_renderer_.reset(new SoftwareVideoRenderer(
106 context.main_task_runner(), context.decode_task_runner(), 106 context.main_task_runner(), context.decode_task_runner(),
107 frame_consumer_proxy_)); 107 frame_consumer_proxy.Pass()));
108 108
109 return true; 109 return true;
110 } 110 }
111 111
112 void PepperVideoRenderer2D::OnViewChanged(const pp::View& view) { 112 void PepperVideoRenderer2D::OnViewChanged(const pp::View& view) {
113 DCHECK(CalledOnValidThread()); 113 DCHECK(CalledOnValidThread());
114 114
115 bool view_changed = false; 115 bool view_changed = false;
116 116
117 pp::Rect pp_size = view.GetRect(); 117 pp::Rect pp_size = view.GetRect();
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 protocol::VideoStub* PepperVideoRenderer2D::GetVideoStub() { 200 protocol::VideoStub* PepperVideoRenderer2D::GetVideoStub() {
201 DCHECK(CalledOnValidThread()); 201 DCHECK(CalledOnValidThread());
202 202
203 return software_video_renderer_->GetVideoStub(); 203 return software_video_renderer_->GetVideoStub();
204 } 204 }
205 205
206 void PepperVideoRenderer2D::ApplyBuffer(const webrtc::DesktopSize& view_size, 206 void PepperVideoRenderer2D::ApplyBuffer(const webrtc::DesktopSize& view_size,
207 const webrtc::DesktopRect& clip_area, 207 const webrtc::DesktopRect& clip_area,
208 webrtc::DesktopFrame* buffer, 208 webrtc::DesktopFrame* buffer,
209 const webrtc::DesktopRegion& region, 209 const webrtc::DesktopRegion& region,
210 const webrtc::DesktopRegion& shape) { 210 const webrtc::DesktopRegion* shape) {
211 DCHECK(CalledOnValidThread()); 211 DCHECK(CalledOnValidThread());
212 212
213 if (!frame_received_) { 213 if (!frame_received_) {
214 event_handler_->OnVideoFirstFrameReceived(); 214 event_handler_->OnVideoFirstFrameReceived();
215 frame_received_ = true; 215 frame_received_ = true;
216 } 216 }
217 // We cannot use the data in the buffer if its dimensions don't match the 217 // We cannot use the data in the buffer if its dimensions don't match the
218 // current view size. 218 // current view size.
219 // TODO(alexeypa): We could rescale and draw it (or even draw it without
220 // rescaling) to reduce the perceived lag while we are waiting for
221 // the properly scaled data.
222 if (!view_size_.equals(view_size)) { 219 if (!view_size_.equals(view_size)) {
223 FreeBuffer(buffer); 220 FreeBuffer(buffer);
224 AllocateBuffers(); 221 AllocateBuffers();
225 } else { 222 } else {
226 FlushBuffer(clip_area, buffer, region); 223 FlushBuffer(clip_area, buffer, region);
227 event_handler_->OnVideoShape(shape); 224 if (shape) {
225 if (!source_shape_ || !source_shape_->Equals(*shape)) {
226 source_shape_ = make_scoped_ptr(new webrtc::DesktopRegion(*shape));
227 event_handler_->OnVideoShape(source_shape_.get());
228 }
229 } else if (source_shape_) {
230 source_shape_ = nullptr;
231 event_handler_->OnVideoShape(nullptr);
232 }
228 } 233 }
229 } 234 }
230 235
231 void PepperVideoRenderer2D::ReturnBuffer(webrtc::DesktopFrame* buffer) { 236 void PepperVideoRenderer2D::ReturnBuffer(webrtc::DesktopFrame* buffer) {
232 DCHECK(CalledOnValidThread()); 237 DCHECK(CalledOnValidThread());
233 238
234 // Reuse the buffer if it is large enough, otherwise drop it on the floor 239 // Reuse the buffer if it is large enough, otherwise drop it on the floor
235 // and allocate a new one. 240 // and allocate a new one.
236 if (buffer->size().width() >= clip_area_.width() && 241 if (buffer->size().width() >= clip_area_.width() &&
237 buffer->size().height() >= clip_area_.height()) { 242 buffer->size().height() >= clip_area_.height()) {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 369
365 // If there is a buffer queued for rendering then render it now. 370 // If there is a buffer queued for rendering then render it now.
366 if (merge_buffer_) { 371 if (merge_buffer_) {
367 buffer = merge_buffer_; 372 buffer = merge_buffer_;
368 merge_buffer_ = nullptr; 373 merge_buffer_ = nullptr;
369 FlushBuffer(merge_clip_area_, buffer, merge_region_); 374 FlushBuffer(merge_clip_area_, buffer, merge_region_);
370 } 375 }
371 } 376 }
372 377
373 } // namespace remoting 378 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/plugin/pepper_video_renderer_2d.h ('k') | remoting/client/plugin/pepper_video_renderer_3d.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698