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

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

Issue 17511004: Added the desktop shape fields to VideoPacket. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR feedback. Created 7 years, 6 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 | Annotate | Revision Log
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_view.h" 5 #include "remoting/client/plugin/pepper_view.h"
6 6
7 #include <functional> 7 #include <functional>
8 8
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 // producer do the scaling, and render at device resolution. 97 // producer do the scaling, and render at device resolution.
98 if (dips_size_ != source_size_) { 98 if (dips_size_ != source_size_) {
99 dips_to_view_scale_ = dips_to_device_scale_; 99 dips_to_view_scale_ = dips_to_device_scale_;
100 view_size_ = SkISize::Make( 100 view_size_ = SkISize::Make(
101 ceilf(dips_size_.width() * dips_to_view_scale_), 101 ceilf(dips_size_.width() * dips_to_view_scale_),
102 ceilf(dips_size_.height() * dips_to_view_scale_)); 102 ceilf(dips_size_.height() * dips_to_view_scale_));
103 } 103 }
104 104
105 // Create a 2D rendering context at the chosen frame dimensions. 105 // Create a 2D rendering context at the chosen frame dimensions.
106 pp::Size pp_size = pp::Size(view_size_.width(), view_size_.height()); 106 pp::Size pp_size = pp::Size(view_size_.width(), view_size_.height());
107 graphics2d_ = pp::Graphics2D(instance_, pp_size, true); 107 graphics2d_ = pp::Graphics2D(instance_, pp_size, false);
108 108
109 // Specify the scale from our coordinates to DIPs. 109 // Specify the scale from our coordinates to DIPs.
110 pp::Graphics2D_Dev graphics2d_dev(graphics2d_); 110 pp::Graphics2D_Dev graphics2d_dev(graphics2d_);
111 graphics2d_dev.SetScale(1.0f / dips_to_view_scale_); 111 graphics2d_dev.SetScale(1.0f / dips_to_view_scale_);
112 112
113 bool result = instance_->BindGraphics(graphics2d_); 113 bool result = instance_->BindGraphics(graphics2d_);
114 114
115 // There is no good way to handle this error currently. 115 // There is no good way to handle this error currently.
116 DCHECK(result) << "Couldn't bind the device context."; 116 DCHECK(result) << "Couldn't bind the device context.";
117 } 117 }
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 producer_->InvalidateRegion(not_painted); 271 producer_->InvalidateRegion(not_painted);
272 } 272 }
273 } 273 }
274 274
275 // Flush the updated areas to the screen. 275 // Flush the updated areas to the screen.
276 int error = graphics2d_.Flush( 276 int error = graphics2d_.Flush(
277 PpCompletionCallback(base::Bind( 277 PpCompletionCallback(base::Bind(
278 &PepperView::OnFlushDone, AsWeakPtr(), start_time, buffer))); 278 &PepperView::OnFlushDone, AsWeakPtr(), start_time, buffer)));
279 CHECK(error == PP_OK_COMPLETIONPENDING); 279 CHECK(error == PP_OK_COMPLETIONPENDING);
280 flush_pending_ = true; 280 flush_pending_ = true;
281
282 // If the buffer we just rendered has a shape then pass that to JavaScript.
283 const SkRegion* buffer_shape = producer_->GetBufferShape();
284 if (buffer_shape)
285 instance_->SetDesktopShape(*buffer_shape);
281 } 286 }
282 287
283 void PepperView::OnFlushDone(base::Time paint_start, 288 void PepperView::OnFlushDone(base::Time paint_start,
284 pp::ImageData* buffer, 289 pp::ImageData* buffer,
285 int result) { 290 int result) {
286 DCHECK(context_->main_task_runner()->BelongsToCurrentThread()); 291 DCHECK(context_->main_task_runner()->BelongsToCurrentThread());
287 DCHECK(flush_pending_); 292 DCHECK(flush_pending_);
288 293
289 instance_->GetStats()->video_paint_ms()->Record( 294 instance_->GetStats()->video_paint_ms()->Record(
290 (base::Time::Now() - paint_start).InMilliseconds()); 295 (base::Time::Now() - paint_start).InMilliseconds());
291 296
292 flush_pending_ = false; 297 flush_pending_ = false;
293 ReturnBuffer(buffer); 298 ReturnBuffer(buffer);
294 299
295 // If there is a buffer queued for rendering then render it now. 300 // If there is a buffer queued for rendering then render it now.
296 if (merge_buffer_ != NULL) { 301 if (merge_buffer_ != NULL) {
297 buffer = merge_buffer_; 302 buffer = merge_buffer_;
298 merge_buffer_ = NULL; 303 merge_buffer_ = NULL;
299 FlushBuffer(merge_clip_area_, buffer, merge_region_); 304 FlushBuffer(merge_clip_area_, buffer, merge_region_);
300 } 305 }
301 } 306 }
302 307
303 } // namespace remoting 308 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/plugin/chromoting_instance.cc ('k') | remoting/client/rectangle_update_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698