Disable DPR != 1 on Safari.
authorJoe Wreschnig <joe.wreschnig@gmail.com>
Tue, 23 Sep 2014 16:12:18 +0000 (18:12 +0200)
committerJoe Wreschnig <joe.wreschnig@gmail.com>
Tue, 23 Sep 2014 16:12:18 +0000 (18:12 +0200)
src/yuu/gfx.js

index 2c3088e..3765aaa 100644 (file)
     var gl;
     var canvas;
 
-    var dpr = yuu.DPR = this.devicePixelRatio || 1;
+    // Safari on OS X has issues with DPR != 1 where the backbuffer
+    // scales down, then back up. I'm pretty sure this is not a
+    // problem with this code, because I see similar artifacting on
+    // most demos, e.g.
+    // https://www.khronos.org/registry/webgl/sdk/demos/google/shiny-teapot/index.html
+    //
+    // With DPR = 1 this presumably still happens but the negative
+    // effect is lessened.
+    //
+    // Safari on iOS does _not_ have this problem (another reason why
+    // I suspect it's a bug in Safari and not this code), but reducing
+    // fragment count by 75% is generally a good idea on these devices
+    // anyway.
+    var dpr = yuu.DPR = !yuu.isSafari()
+        ? (this.devicePixelRatio || 1)
+        : 1;
 
     yT.defineProperty(Int8Array.prototype, "GL_TYPE", 0x1400);
     yT.defineProperty(Uint8Array.prototype, "GL_TYPE", 0x1401);