From c3c6c7a2e9d6ffe5438881216dea9cc2f87ce5d5 Mon Sep 17 00:00:00 2001 From: kkapsner Date: Sat, 26 Nov 2016 17:37:52 +0100 Subject: [PATCH] Fixes bug in fake function for readPixels. Fixes #92. --- lib/modifiedAPI.js | 15 +++++++++++++-- releaseNotes.txt | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/modifiedAPI.js b/lib/modifiedAPI.js index a5f0aeb..c0750e6 100644 --- a/lib/modifiedAPI.js +++ b/lib/modifiedAPI.js @@ -5,6 +5,8 @@ (function(){ "use strict"; + let Cu = require("chrome").Cu; + var randomSupply = null; function getContext(window, canvas){ @@ -257,10 +259,19 @@ object: "WebGLRenderingContext", fakeGenerator: function(prefs, notify){ return function readPixels(x, y, width, height, format, type, pixels){ + // not able to use the getFakeCanvas function because the context type is wrong... notify("fakedReadout"); + var xPixels = Cu.waiveXrays(pixels); var window = getWindow(this.canvas); - var context = window.HTMLCanvasElement.prototype.getContext.call(getFakeCanvas(window, this.canvas), "webGL"); - return window.WebGLRenderingContext.prototype.readPixels.apply(context, arguments); + var ret = window.WebGLRenderingContext.prototype.readPixels.apply(this, arguments); + var l = xPixels.length; + var rng = randomSupply.getRng(l, window); + + for (var i = 0; i < l; i += 1){ + xPixels[i] = rng(xPixels[i], i); + } + + return ret; }; } } diff --git a/releaseNotes.txt b/releaseNotes.txt index 5d04e22..7fa6488 100644 --- a/releaseNotes.txt +++ b/releaseNotes.txt @@ -3,6 +3,7 @@ Version 0.3.4: - different fake modes show independent notifications fixes: + - bug in readPixels (prevented google street view to work) - performance issues - German translations