Index: remoting/client/plugin/pepper_view.cc |
diff --git a/remoting/client/plugin/pepper_view.cc b/remoting/client/plugin/pepper_view.cc |
index ac95e7335c958590f06804ea94507d23b5bb45ca..764f0a4d3599ec4e9ed2342739f21d3dd09d338f 100644 |
--- a/remoting/client/plugin/pepper_view.cc |
+++ b/remoting/client/plugin/pepper_view.cc |
@@ -82,16 +82,29 @@ void PepperView::SetView(const pp::View& view) { |
view_changed = true; |
view_scale_ = new_scale; |
view_size_dips_ = new_size_dips; |
- view_size_ = SkISize::Make(ceilf(view_size_dips_.width() * view_scale_), |
- ceilf(view_size_dips_.height() * view_scale_)); |
+ // If |view_scale_| is > 1.0 then the device is high-DPI, and there are |
+ // actually |view_scale_| physical pixels for every one Density Independent |
+ // Pixel (DIP). If we specify a scale of 1.0 to Graphics2D then we can |
+ // render at DIP resolution and let PPAPI up-scale for high-DPI devices. |
+ // Note that |view_scale_| is DIPS->pixels, |scale| is pixels->DIPS. |
+ float scale = 1.0f; |
+ view_size_ = view_size_dips_; |
+ |
+ // If the view's DIP dimensions don't match the source then let the frame |
+ // producer do the scaling, and render at device resolution. |
+ if (view_size_dips_ != source_size_) { |
+ scale = 1.0f / view_scale_; |
+ view_size_ = SkISize::Make(ceilf(view_size_dips_.width() * view_scale_), |
+ ceilf(view_size_dips_.height() * view_scale_)); |
+ } |
+ |
+ // Create a 2D rendering context at the chosen frame dimensions. |
pp::Size pp_size = pp::Size(view_size_.width(), view_size_.height()); |
graphics2d_ = pp::Graphics2D(instance_, pp_size, true); |
- // Ideally we would always let Graphics2D scale us, but the output quality |
- // is lousy, so we don't. |
Jamie
2012/12/18 19:45:32
I take it this comment is no longer true?
Wez
2012/12/18 19:47:23
No; it's still true for non-integer scale factors
|
pp::Graphics2D_Dev graphics2d_dev(graphics2d_); |
- graphics2d_dev.SetScale(1.0f / view_scale_); |
+ graphics2d_dev.SetScale(scale); |
bool result = instance_->BindGraphics(graphics2d_); |