diff options
author | alexst@chromium.org <alexst@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-04 18:23:32 +0000 |
---|---|---|
committer | alexst@chromium.org <alexst@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-04 18:23:32 +0000 |
commit | 19fa81a02addc5d466d7d9740aaf5f07a8f4a62e (patch) | |
tree | 3db4be6ca8d08dfa60a6ad3338c81b62d43d3b8b /content | |
parent | 36524bc5292c05847f468ddf09035c86422de955 (diff) | |
download | chromium_src-19fa81a02addc5d466d7d9740aaf5f07a8f4a62e.zip chromium_src-19fa81a02addc5d466d7d9740aaf5f07a8f4a62e.tar.gz chromium_src-19fa81a02addc5d466d7d9740aaf5f07a8f4a62e.tar.bz2 |
Fix double sized layer issue on hDPI devices.
The content layer was sized using information received from BuffersSwapped,
which is in physical pixels. Container size is in DIP and therefore the
layer size needs to be adjusted by the device scale factor.
BUG=179256
Review URL: https://chromiumcodereview.appspot.com/12385084
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@185932 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
3 files changed, 16 insertions, 4 deletions
diff --git a/content/renderer/browser_plugin/browser_plugin.cc b/content/renderer/browser_plugin/browser_plugin.cc index 573ff76..0f86211 100644 --- a/content/renderer/browser_plugin/browser_plugin.cc +++ b/content/renderer/browser_plugin/browser_plugin.cc @@ -405,7 +405,8 @@ void BrowserPlugin::OnBuffersSwapped(int instance_id, compositing_helper_->OnBuffersSwapped(size, mailbox_name, gpu_route_id, - gpu_host_id); + gpu_host_id, + GetDeviceScaleFactor()); } void BrowserPlugin::OnGuestContentWindowReady(int instance_id, diff --git a/content/renderer/browser_plugin/browser_plugin_compositing_helper.cc b/content/renderer/browser_plugin/browser_plugin_compositing_helper.cc index 7c14969..597e218 100644 --- a/content/renderer/browser_plugin/browser_plugin_compositing_helper.cc +++ b/content/renderer/browser_plugin/browser_plugin_compositing_helper.cc @@ -152,7 +152,8 @@ void BrowserPluginCompositingHelper::OnBuffersSwapped( const gfx::Size& size, const std::string& mailbox_name, int gpu_route_id, - int gpu_host_id) { + int gpu_host_id, + float device_scale_factor) { // If the guest crashed but the GPU process didn't, we may still have // a transport surface waiting on an ACK, which we must send to // avoid leaking. @@ -188,7 +189,16 @@ void BrowserPluginCompositingHelper::OnBuffersSwapped( // or introduce a gutter around it. if (buffer_size_ != size) { buffer_size_ = size; - texture_layer_->setBounds(buffer_size_); + // The container size is in DIP, so is the layer size. + // Buffer size is in physical pixels, so we need to adjust + // it by the device scale factor. + float inverse_scale_factor = 1.0f / device_scale_factor; + gfx::SizeF scaledSize(size); + scaledSize.Scale(inverse_scale_factor); + gfx::Size device_scale_adjusted_size( + static_cast<int>(scaledSize.width()), + static_cast<int>(scaledSize.height())); + texture_layer_->setBounds(device_scale_adjusted_size); } bool current_mailbox_valid = !mailbox_name.empty(); diff --git a/content/renderer/browser_plugin/browser_plugin_compositing_helper.h b/content/renderer/browser_plugin/browser_plugin_compositing_helper.h index a11956d..998b739 100644 --- a/content/renderer/browser_plugin/browser_plugin_compositing_helper.h +++ b/content/renderer/browser_plugin/browser_plugin_compositing_helper.h @@ -38,7 +38,8 @@ class CONTENT_EXPORT BrowserPluginCompositingHelper : void OnBuffersSwapped(const gfx::Size& size, const std::string& mailbox_name, int gpu_route_id, - int gpu_host_id); + int gpu_host_id, + float device_scale_factor); void UpdateVisibility(bool); protected: // Friend RefCounted so that the dtor can be non-public. |