Преглед изворни кода

better hd-sd calculation
the hd button will also not be shown if the devie doesnt support it.

Raanan Weber пре 7 година
родитељ
комит
67007ffb7e
2 измењених фајлова са 9 додато и 7 уклоњено
  1. 7 0
      Viewer/src/viewer/defaultViewer.ts
  2. 2 7
      Viewer/src/viewer/viewer.ts

+ 7 - 0
Viewer/src/viewer/defaultViewer.ts

@@ -106,6 +106,12 @@ export class DefaultViewer extends AbstractViewer {
                 }
                 }
                 this._resumePlay = false;
                 this._resumePlay = false;
             }, "pointerup", ".progress-wrapper");
             }, "pointerup", ".progress-wrapper");
+
+            if (window.devicePixelRatio === 1 && navbar.configuration.params && !navbar.configuration.params.hideHdButton) {
+                navbar.updateParams({
+                    hideHdButton: true
+                });
+            }
         }
         }
     }
     }
 
 
@@ -535,6 +541,7 @@ export class DefaultViewer extends AbstractViewer {
     }
     }
 
 
     protected _onConfigurationLoaded(configuration: ViewerConfiguration) {
     protected _onConfigurationLoaded(configuration: ViewerConfiguration) {
+
         super._onConfigurationLoaded(configuration);
         super._onConfigurationLoaded(configuration);
 
 
         // initialize the templates
         // initialize the templates

+ 2 - 7
Viewer/src/viewer/viewer.ts

@@ -255,14 +255,9 @@ export abstract class AbstractViewer {
     public toggleHD() {
     public toggleHD() {
         this._hdToggled = !this._hdToggled;
         this._hdToggled = !this._hdToggled;
 
 
-        let currentLevel = this.engine.getHardwareScalingLevel();
-        const scalingFactor = 2;
+        var scale = this._hdToggled ? Math.max(0.5, 1 / (window.devicePixelRatio || 2)) : 1;
 
 
-        if (this._hdToggled) {
-            this.engine.setHardwareScalingLevel(currentLevel / scalingFactor);
-        } else {
-            this.engine.setHardwareScalingLevel(currentLevel * scalingFactor);
-        }
+        this.engine.setHardwareScalingLevel(scale);
     }
     }
 
 
     /**
     /**