Chromium Code Reviews| Index: remoting/client/plugin/pepper_view.cc |
| diff --git a/remoting/client/plugin/pepper_view.cc b/remoting/client/plugin/pepper_view.cc |
| index 35976e4efe2babacad8b22a0869d5cdc7030c10a..f0d752bcc9532f6b14eb0971499008d301db28fd 100644 |
| --- a/remoting/client/plugin/pepper_view.cc |
| +++ b/remoting/client/plugin/pepper_view.cc |
| @@ -10,7 +10,8 @@ |
| #include "base/string_util.h" |
| #include "base/synchronization/waitable_event.h" |
| #include "ppapi/cpp/completion_callback.h" |
| -#include "ppapi/cpp/graphics_2d.h" |
| +#include "ppapi/cpp/dev/graphics_2d_dev.h" |
| +#include "ppapi/cpp/dev/view_dev.h" |
| #include "ppapi/cpp/image_data.h" |
| #include "ppapi/cpp/point.h" |
| #include "ppapi/cpp/rect.h" |
| @@ -77,6 +78,8 @@ PepperView::PepperView(ChromotingInstance* instance, |
| view_size_(SkISize::Make(0, 0)), |
| clip_area_(SkIRect::MakeEmpty()), |
| source_size_(SkISize::Make(0, 0)), |
| + view_size_dips_(SkISize::Make(0, 0)), |
| + view_scale_(1.0f), |
| flush_pending_(false), |
| is_initialized_(false), |
| frame_received_(false) { |
| @@ -154,27 +157,47 @@ protocol::CursorShapeStub* PepperView::GetCursorShapeStub() { |
| return instance_; |
| } |
| -void PepperView::SetView(const SkISize& view_size, const SkIRect& clip_area) { |
| +void PepperView::SetView(const pp::View& view) { |
| bool view_changed = false; |
| - if (view_size_ != view_size) { |
| + pp::ViewDev view_dev(view); |
| + |
| + pp::Rect pp_size = view.GetRect(); |
| + SkISize new_size_dips = SkISize::Make(pp_size.width(), pp_size.height()); |
| + |
| + if (view_size_dips_ != new_size_dips || |
| + view_dev.GetDeviceScale() != view_scale_) { |
| view_changed = true; |
| - view_size_ = view_size; |
| + view_scale_ = view_dev.GetDeviceScale(); |
|
Sergey Ulanov
2012/07/19 17:50:23
nit: maybe call GetDeviceScale only once and save
Wez
2012/07/20 00:01:59
Done.
|
| + view_size_dips_ = new_size_dips; |
| + view_size_ = SkISize::Make(ceilf(view_size_dips_.width() * view_scale_), |
| + ceilf(view_size_dips_.height() * view_scale_)); |
| pp::Size pp_size = pp::Size(view_size_.width(), view_size_.height()); |
| - graphics2d_ = pp::Graphics2D(instance_, pp_size, true); |
| + pp::Graphics2DDev graphics2d = pp::Graphics2D(instance_, pp_size, true); |
|
Sergey Ulanov
2012/07/19 17:50:23
nit: might be better if you assign graphics2d_ fir
Wez
2012/07/20 00:01:59
Done.
|
| + |
| + // Ideally we would always let Graphics2D scale us, but the output quality |
| + // is lousy, so we don't. |
| + graphics2d.SetScale(1.0f / view_scale_); |
| + |
| + graphics2d_ = graphics2d; |
| bool result = instance_->BindGraphics(graphics2d_); |
| // There is no good way to handle this error currently. |
| DCHECK(result) << "Couldn't bind the device context."; |
| } |
| - if (clip_area_ != clip_area) { |
| + pp::Rect pp_clip = view.GetClipRect(); |
| + SkIRect new_clip = SkIRect::MakeLTRB(floorf(pp_clip.x() * view_scale_), |
| + floorf(pp_clip.y() * view_scale_), |
| + ceilf(pp_clip.right() * view_scale_), |
| + ceilf(pp_clip.bottom() * view_scale_); |
| + if (clip_area_ != new_clip) { |
| view_changed = true; |
| // YUV to RGB conversion may require even X and Y coordinates for |
| // the top left corner of the clipping area. |
| - clip_area_ = AlignRect(clip_area); |
| + clip_area_ = AlignRect(new_clip); |
| clip_area_.intersect(SkIRect::MakeSize(view_size_)); |
| } |