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..d996646272d420a992e14c68c739c81e90b1a1d7 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(); |
+ view_size_dips_ = new_size_dips; |
+ view_size_ = SkISize::Make(view_size_dips_.width() * view_scale_, |
+ 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/17 19:36:06
why can't set graphics2d_ directly?
Wez
2012/07/17 20:11:43
The |graphics2d_| member in the class is still a G
|
+ |
+ // 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::MakeXYWH(pp_clip.x() * view_scale_, |
+ pp_clip.y() * view_scale_, |
+ pp_clip.width() * view_scale_, |
Sergey Ulanov
2012/07/17 19:36:06
ceil(pp_clip.width() * view_scale_)?
Wez
2012/07/17 20:11:43
That shouldn't be necessary for the scaling factor
Wez
2012/07/17 20:11:43
Done.
|
+ pp_clip.height() * 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_)); |
} |