@@ -41,6 +41,8 @@ static const float kScrollFactor = 20.0f; // Just picked what fell right.
4141
4242static const char * kDispatchCreateWidgetName = " dispatchCreateWidget" ;
4343static const char * kDispatchCreateWidgetSignature = " (IILandroid/graphics/SurfaceTexture;II)V" ;
44+ static const char * kGetDisplayDensityName = " getDisplayDensity" ;
45+ static const char * kGetDisplayDensitySignature = " ()I" ;
4446static const char * kHandleMotionEventName = " handleMotionEvent" ;
4547static const char * kHandleMotionEventSignature = " (IIZFF)V" ;
4648static const char * kHandleScrollEvent = " handleScrollEvent" ;
@@ -160,6 +162,7 @@ struct BrowserWorld::State {
160162 float farClip;
161163 JNIEnv* env;
162164 jobject activity;
165+ int displayDensity;
163166 jmethodID dispatchCreateWidgetMethod;
164167 jmethodID handleMotionEventMethod;
165168 jmethodID handleScrollEventMethod;
@@ -178,26 +181,32 @@ struct BrowserWorld::State {
178181 root->AddLight (light);
179182 cullVisitor = CullVisitor::Create (contextWeak);
180183 drawList = DrawableList::Create (contextWeak);
184+ }
185+
186+ void InitializeWindows ();
187+ void UpdateControllers ();
188+ };
181189
190+ void
191+ BrowserWorld::State::InitializeWindows () {
182192 WidgetPtr browser = Widget::Create (contextWeak, WidgetTypeBrowser);
183193 browser->SetTransform (Matrix::Position (Vector (0 .0f , -3 .0f , -18 .0f )));
184194 root->AddNode (browser->GetRoot ());
185195 widgets.push_back (std::move (browser));
186- #if defined(VRBROWSER_GOOGLEVR)
196+ /* #if defined(VRBROWSER_GOOGLEVR)
187197 static const float kUIScaleFactor = 1.0f;
188198#else
189199 static const float kUIScaleFactor = 1.5f;
190- #endif // defined(VRBROWSER_GOOGLEVR)
200+ #endif // defined(VRBROWSER_GOOGLEVR*/
201+ const float uiScaleFactor = displayDensity/420 .0f ;
202+
191203 WidgetPtr urlbar = Widget::Create (contextWeak, WidgetTypeURLBar,
192- (int32_t ) (1920 .0f * kUIScaleFactor ),
193- (int32_t ) (275 .0f * kUIScaleFactor ), 9 .0f );
204+ (int32_t ) (1920 .0f * uiScaleFactor ),
205+ (int32_t ) (275 .0f * uiScaleFactor ), 9 .0f );
194206 urlbar->SetTransform (Matrix::Position (Vector (0 .0f , 7 .15f , -18 .0f )));
195207 root->AddNode (urlbar->GetRoot ());
196208 widgets.push_back (std::move (urlbar));
197- }
198-
199- void UpdateControllers ();
200- };
209+ }
201210
202211void
203212BrowserWorld::State::UpdateControllers () {
@@ -375,6 +384,13 @@ BrowserWorld::InitializeJava(JNIEnv* aEnv, jobject& aActivity, jobject& aAssetMa
375384 VRB_LOG (" Failed to find Java method: %s %s" , kHandleGestureName , kHandleGestureSignature );
376385 }
377386
387+ jmethodID getDisplayDensityMethod = m.env ->GetMethodID (clazz, kGetDisplayDensityName , kGetDisplayDensitySignature );
388+ if (getDisplayDensityMethod) {
389+ m.displayDensity = m.env ->CallIntMethod (m.activity , getDisplayDensityMethod);
390+ }
391+
392+ m.InitializeWindows ();
393+
378394 if ((m.controllers .size () == 0 ) && (m.controllerCount > 0 )) {
379395 for (int32_t ix = 0 ; ix < m.controllerCount ; ix++) {
380396 ControllerRecord record (ix);
0 commit comments