[OpenLayers-Commits] r11868 -
trunk/openlayers/lib/OpenLayers/Renderer
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Mon Apr 4 11:12:48 EDT 2011
Author: ahocevar
Date: 2011-04-04 08:12:44 -0700 (Mon, 04 Apr 2011)
New Revision: 11868
Modified:
trunk/openlayers/lib/OpenLayers/Renderer/Canvas.js
Log:
working around drawImage issue on Android 2.1 devices. r=erilem (closes #3243)
Modified: trunk/openlayers/lib/OpenLayers/Renderer/Canvas.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Renderer/Canvas.js 2011-04-04 10:25:34 UTC (rev 11867)
+++ trunk/openlayers/lib/OpenLayers/Renderer/Canvas.js 2011-04-04 15:12:44 UTC (rev 11868)
@@ -50,7 +50,7 @@
* the renderer was locked.
*/
pendingRedraw: false,
-
+
/**
* Constructor: OpenLayers.Renderer.Canvas
*
@@ -224,8 +224,15 @@
// TODO: check that we haven't moved
var canvas = this.canvas;
canvas.globalAlpha = opacity;
+ var factor = OpenLayers.Renderer.Canvas.drawImageScaleFactor ||
+ (OpenLayers.Renderer.Canvas.drawImageScaleFactor =
+ /android 2.1/.test(navigator.userAgent.toLowerCase()) ?
+ // 320 is the screen width of the G1 phone, for which
+ // drawImage works out of the box.
+ 320 / window.screen.width : 1
+ );
canvas.drawImage(
- img, x, y, width, height
+ img, x*factor, y*factor, width*factor, height*factor
);
if (this.hitDetection) {
this.setHitContextStyle("fill", featureId);
@@ -541,7 +548,7 @@
}
this.setCanvasStyle("reset");
},
-
+
/**
* Method: getLocalXY
* transform geographic xy into pixel xy
@@ -680,3 +687,11 @@
"t": 0,
"b": -1
};
+
+/**
+ * Constant: OpenLayers.Renderer.Canvas.drawImageScaleFactor
+ * {Number} Scale factor to apply to the canvas drawImage arguments. This
+ * is always 1 except for Android 2.1 devices, to work around
+ * http://code.google.com/p/android/issues/detail?id=5141.
+ */
+OpenLayers.Renderer.Canvas.drawImageScaleFactor = null;
More information about the Commits
mailing list