OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <GLES2/gl2.h> | 5 #include <GLES2/gl2.h> |
6 #include <math.h> | 6 #include <math.h> |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <stdio.h> | 9 #include <stdio.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 mvp_loc_(0), | 240 mvp_loc_(0), |
241 x_angle_(0), | 241 x_angle_(0), |
242 y_angle_(0), | 242 y_angle_(0), |
243 animating_(true) {} | 243 animating_(true) {} |
244 | 244 |
245 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]) { | 245 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]) { |
246 return true; | 246 return true; |
247 } | 247 } |
248 | 248 |
249 virtual void DidChangeView(const pp::View& view) { | 249 virtual void DidChangeView(const pp::View& view) { |
250 int32_t new_width = view.GetRect().width(); | 250 // Pepper specifies dimensions in DIPs (device-independent pixels). To |
251 int32_t new_height = view.GetRect().height(); | 251 // generate a context that is at device-pixel resolution on HiDPI devices, |
| 252 // scale the dimensions by view.GetDeviceScale(). |
| 253 int32_t new_width = view.GetRect().width() * view.GetDeviceScale(); |
| 254 int32_t new_height = view.GetRect().height() * view.GetDeviceScale(); |
252 | 255 |
253 if (context_.is_null()) { | 256 if (context_.is_null()) { |
254 if (!InitGL(new_width, new_height)) { | 257 if (!InitGL(new_width, new_height)) { |
255 // failed. | 258 // failed. |
256 return; | 259 return; |
257 } | 260 } |
258 | 261 |
259 InitShaders(); | 262 InitShaders(); |
260 InitBuffers(); | 263 InitBuffers(); |
261 InitTexture(); | 264 InitTexture(); |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 virtual ~Graphics3DModule() {} | 500 virtual ~Graphics3DModule() {} |
498 | 501 |
499 virtual pp::Instance* CreateInstance(PP_Instance instance) { | 502 virtual pp::Instance* CreateInstance(PP_Instance instance) { |
500 return new Graphics3DInstance(instance); | 503 return new Graphics3DInstance(instance); |
501 } | 504 } |
502 }; | 505 }; |
503 | 506 |
504 namespace pp { | 507 namespace pp { |
505 Module* CreateModule() { return new Graphics3DModule(); } | 508 Module* CreateModule() { return new Graphics3DModule(); } |
506 } // namespace pp | 509 } // namespace pp |
OLD | NEW |