private void UpdateDisplayInfo(bool firstTime) { var di = GetSingleton <DisplayInfo>(); // TODO DOTSR-994 -- screenDpiScale is being used as both user configuration and information here if (di.screenDpiScale == 0.0f) { di.screenDpiScale = HTMLNativeCalls.getDPIScale(); } HTMLNativeCalls.getScreenSize(ref di.screenWidth, ref di.screenHeight); HTMLNativeCalls.getFrameSize(ref di.frameWidth, ref di.frameHeight); int wCanvas = 0, hCanvas = 0; if (firstTime) { // TODO DOTSR-994 -- this is a case where we're using width/height as read/write instead of as explicit read or write only wCanvas = di.width; hCanvas = di.height; } else { HTMLNativeCalls.getCanvasSize(ref wCanvas, ref hCanvas); } if (di.autoSizeToFrame) { di.width = (int)(di.frameWidth * di.screenDpiScale); di.height = (int)(di.frameHeight * di.screenDpiScale); wCanvas = di.frameWidth; hCanvas = di.frameHeight; } else if (firstTime) { di.width = (int)(di.width * di.screenDpiScale); di.height = (int)(di.height * di.screenDpiScale); } di.framebufferWidth = di.width; di.framebufferHeight = di.height; unsafe { if (firstTime || UnsafeUtility.MemCmp(UnsafeUtility.AddressOf(ref di), UnsafeUtility.AddressOf(ref lastDisplayInfo), sizeof(DisplayInfo)) != 0) { // Only do this if it's the first time, or if the struct values actually changed from the last time we set it #if DEBUG Debug.Log($"setCanvasSize {firstTime} {wCanvas}px {hCanvas}px (backing {di.framebufferWidth} {di.framebufferHeight}, dpi scale {di.screenDpiScale})"); #endif HTMLNativeCalls.setCanvasSize(wCanvas, hCanvas, di.framebufferWidth, di.framebufferHeight); SetSingleton(di); lastDisplayInfo = di; } } }
private void UpdateDisplayInfo(bool firstTime) { var env = World.TinyEnvironment(); var config = env.GetConfigData <DisplayInfo>(); int wCanvas = 0, hCanvas = 0; if (firstTime) { HTMLNativeCalls.getScreenSize(ref config.screenWidth, ref config.screenHeight); wCanvas = config.width; hCanvas = config.height; } else { HTMLNativeCalls.getCanvasSize(ref wCanvas, ref hCanvas); } HTMLNativeCalls.getFrameSize(ref config.frameWidth, ref config.frameHeight); if (config.autoSizeToFrame) { config.width = config.frameWidth; config.height = config.frameHeight; } if (firstTime || wCanvas != config.width || hCanvas != config.height) { #if DEBUG Debug.Log($"setCanvasSize {config.width} {config.height}"); #endif HTMLNativeCalls.setCanvasSizeAndMode(config.width, config.height, 2); config.framebufferWidth = config.width; config.framebufferHeight = config.height; } env.SetConfigData(config); }