OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "ppapi/cpp/completion_callback.h" |
9 #include "ppapi/cpp/graphics_2d.h" | 10 #include "ppapi/cpp/graphics_2d.h" |
10 #include "ppapi/cpp/image_data.h" | 11 #include "ppapi/cpp/image_data.h" |
11 #include "ppapi/cpp/point.h" | 12 #include "ppapi/cpp/point.h" |
12 #include "ppapi/cpp/rect.h" | 13 #include "ppapi/cpp/rect.h" |
13 #include "ppapi/cpp/size.h" | 14 #include "ppapi/cpp/size.h" |
14 #include "remoting/base/util.h" | 15 #include "remoting/base/util.h" |
15 #include "remoting/client/chromoting_stats.h" | 16 #include "remoting/client/chromoting_stats.h" |
16 #include "remoting/client/client_context.h" | 17 #include "remoting/client/client_context.h" |
17 #include "remoting/client/plugin/chromoting_instance.h" | 18 #include "remoting/client/plugin/chromoting_instance.h" |
18 #include "remoting/client/plugin/pepper_util.h" | 19 #include "remoting/client/plugin/pepper_util.h" |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 | 303 |
303 double PepperView::GetVerticalScaleRatio() const { | 304 double PepperView::GetVerticalScaleRatio() const { |
304 if (instance_->DoScaling()) { | 305 if (instance_->DoScaling()) { |
305 DCHECK(!host_size_.isEmpty()); | 306 DCHECK(!host_size_.isEmpty()); |
306 return 1.0 * plugin_size_.height() / host_size_.height(); | 307 return 1.0 * plugin_size_.height() / host_size_.height(); |
307 } | 308 } |
308 return 1.0; | 309 return 1.0; |
309 } | 310 } |
310 | 311 |
311 void PepperView::AllocateFrame(media::VideoFrame::Format format, | 312 void PepperView::AllocateFrame(media::VideoFrame::Format format, |
312 size_t width, | 313 const SkISize& size, |
313 size_t height, | |
314 base::TimeDelta timestamp, | |
315 base::TimeDelta duration, | |
316 scoped_refptr<media::VideoFrame>* frame_out, | 314 scoped_refptr<media::VideoFrame>* frame_out, |
317 Task* done) { | 315 const base::Closure& done) { |
318 DCHECK(context_->main_message_loop()->BelongsToCurrentThread()); | 316 DCHECK(context_->main_message_loop()->BelongsToCurrentThread()); |
319 | 317 |
320 *frame_out = media::VideoFrame::CreateFrame(media::VideoFrame::RGB32, | 318 *frame_out = media::VideoFrame::CreateFrame( |
321 width, height, | 319 media::VideoFrame::RGB32, size.width(), size.height(), |
322 base::TimeDelta(), | 320 base::TimeDelta(), base::TimeDelta()); |
323 base::TimeDelta()); | |
324 (*frame_out)->AddRef(); | 321 (*frame_out)->AddRef(); |
325 done->Run(); | 322 done.Run(); |
326 delete done; | |
327 } | 323 } |
328 | 324 |
329 void PepperView::ReleaseFrame(media::VideoFrame* frame) { | 325 void PepperView::ReleaseFrame(media::VideoFrame* frame) { |
330 DCHECK(context_->main_message_loop()->BelongsToCurrentThread()); | 326 DCHECK(context_->main_message_loop()->BelongsToCurrentThread()); |
331 | 327 |
332 if (frame) | 328 if (frame) |
333 frame->Release(); | 329 frame->Release(); |
334 } | 330 } |
335 | 331 |
336 void PepperView::OnPartialFrameOutput(media::VideoFrame* frame, | 332 void PepperView::OnPartialFrameOutput(media::VideoFrame* frame, |
337 RectVector* rects, | 333 RectVector* rects, |
338 Task* done) { | 334 const base::Closure& done) { |
339 DCHECK(context_->main_message_loop()->BelongsToCurrentThread()); | 335 DCHECK(context_->main_message_loop()->BelongsToCurrentThread()); |
340 | 336 |
341 // TODO(ajwong): Clean up this API to be async so we don't need to use a | 337 // TODO(ajwong): Clean up this API to be async so we don't need to use a |
342 // member variable as a hack. | 338 // member variable as a hack. |
343 PaintFrame(frame, rects); | 339 PaintFrame(frame, rects); |
344 done->Run(); | 340 done.Run(); |
345 delete done; | |
346 } | 341 } |
347 | 342 |
348 void PepperView::OnPaintDone(base::Time paint_start) { | 343 void PepperView::OnPaintDone(base::Time paint_start) { |
349 DCHECK(context_->main_message_loop()->BelongsToCurrentThread()); | 344 DCHECK(context_->main_message_loop()->BelongsToCurrentThread()); |
350 instance_->GetStats()->video_paint_ms()->Record( | 345 instance_->GetStats()->video_paint_ms()->Record( |
351 (base::Time::Now() - paint_start).InMilliseconds()); | 346 (base::Time::Now() - paint_start).InMilliseconds()); |
352 | 347 |
353 // If the last flush failed because there was already another one in progress | 348 // If the last flush failed because there was already another one in progress |
354 // then we perform the flush now. | 349 // then we perform the flush now. |
355 if (flush_blocked_) | 350 if (flush_blocked_) |
356 FlushGraphics(base::Time::Now()); | 351 FlushGraphics(base::Time::Now()); |
357 return; | 352 return; |
358 } | 353 } |
359 | 354 |
360 } // namespace remoting | 355 } // namespace remoting |
OLD | NEW |