Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/child/dataCollector.js

Issue 29333406: Issue 3504 - Fixed: Screenshot color reduction step of the Issue Reporter is very slow (Closed)
Patch Set: Created Jan. 12, 2016, 4:41 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/child/dataCollector.js
===================================================================
--- a/lib/child/dataCollector.js
+++ b/lib/child/dataCollector.js
@@ -107,21 +107,21 @@ function* createScreenshot(window, scree
context.save();
context.scale(scalingFactor, scalingFactor);
context.drawWindow(window, copyX, copyY, copyWidth, copyHeight, "rgb(255,255,255)");
context.restore();
// Reduce colors
let pixelData = context.getImageData(0, 0, canvas.width, canvas.height);
- let max = pixelData.width * pixelData.height * 4;
+ let data = pixelData.data;
let mapping = [0x00, 0x55, 0xAA, 0xFF];
- for (let i = 0; i < max; i++)
+ for (let i = 0; i < data.length; i++)
{
- pixelData.data[i] = mapping[pixelData.data[i] >> 6];
+ data[i] = mapping[data[i] >> 6];
if (i % 5000 == 0)
{
// Take a break every 5000 bytes to prevent browser hangs
yield new Promise((resolve, reject) => Utils.runAsync(resolve));
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld