diff options
author | jhorwich@chromium.org <jhorwich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-18 00:53:10 +0000 |
---|---|---|
committer | jhorwich@chromium.org <jhorwich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-18 00:53:10 +0000 |
commit | 58c9998ef6086965b8d66f9e5f2abc2f8ca27200 (patch) | |
tree | a9178972cace7d11f475ad40ff4aa1dcab690912 /native_client_sdk | |
parent | ec927b359384520cd79dc87d20483c6223e89557 (diff) | |
download | chromium_src-58c9998ef6086965b8d66f9e5f2abc2f8ca27200.zip chromium_src-58c9998ef6086965b8d66f9e5f2abc2f8ca27200.tar.gz chromium_src-58c9998ef6086965b8d66f9e5f2abc2f8ca27200.tar.bz2 |
NaCl SDK: Demonstrate use of pp::View::GetDeviceScale for 3D
Demonstrate in the NaCl SDK API demo for pp::Graphics3D how to
use full device resolution on HiDPI displays. For Graphics3D it
is simply a matter of sizing the texture in device pixels, by
multiplying the width/height by view.GetDeviceScale().
BUG=196253
TEST=Build NaCl SDK, run with --force-device-scale-factor=2
Review URL: https://codereview.chromium.org/398943003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283952 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'native_client_sdk')
-rw-r--r-- | native_client_sdk/src/examples/api/graphics_3d/graphics_3d.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/native_client_sdk/src/examples/api/graphics_3d/graphics_3d.cc b/native_client_sdk/src/examples/api/graphics_3d/graphics_3d.cc index abe5aec..0777cb88 100644 --- a/native_client_sdk/src/examples/api/graphics_3d/graphics_3d.cc +++ b/native_client_sdk/src/examples/api/graphics_3d/graphics_3d.cc @@ -247,8 +247,11 @@ class Graphics3DInstance : public pp::Instance { } virtual void DidChangeView(const pp::View& view) { - int32_t new_width = view.GetRect().width(); - int32_t new_height = view.GetRect().height(); + // Pepper specifies dimensions in DIPs (device-independent pixels). To + // generate a context that is at device-pixel resolution on HiDPI devices, + // scale the dimensions by view.GetDeviceScale(). + int32_t new_width = view.GetRect().width() * view.GetDeviceScale(); + int32_t new_height = view.GetRect().height() * view.GetDeviceScale(); if (context_.is_null()) { if (!InitGL(new_width, new_height)) { |