Reviewed by Mark Rowe.
+ Add check to make sure we return all the data in a row.
+
+ * fast/canvas/canvas-getImageData-expected.txt:
+ * fast/canvas/canvas-getImageData.html:
+
+2008-03-03 Oliver Hunt <oliver@apple.com>
+
+ Reviewed by Mark Rowe.
+
Test case for incorrect assertions
* fast/canvas/canvas-putImageData.js:
PASS: pixel at (92,0) was [0,244,0,255]
PASS: pixel at (96,0) was [0,255,0,255]
PASS: pixel at (5,5) was [64,128,191,255]
+PASS: Correctly retrieved every pixel in a row
PASS: Correct data for content outside canvas bounds
PASS: pixel at (50,50) was [0,0,0,0]
PASS: pixel at (50,54) was [0,0,0,1]
context.fillRect(5,5,1,1);
pixelShouldBe(context, 5, 5, [Math.round(0.25*255), Math.round(0.5*255), Math.round(0.75*255), 255]);
+// Make sure we return correct values for the row
+for (var i = 0; i < 100; i++) {
+ context.fillStyle = "rgba("+[0, i, 0, 1]+")";
+ context.fillRect(i, 10, 1, 1);
+}
+
+var rowImageData = context.getImageData(0, 10, 100, 1).data;
+var rowCheck = true;
+for (var i = 0; i < 100; i++) {
+ if (rowImageData[i * 4 + 1] != i) {
+ rowCheck = false;
+ break;
+ }
+}
+if (!rowCheck)
+ log("FAIL: Did not correctly retrieve every pixel in a row");
+else
+ log("PASS: Correctly retrieved every pixel in a row");
+
// Check that we return transparent black for regions outside the canvas proper
context.fillStyle = "rgba(255,255,255,255)";
context.fillRect(198, 5, 4, 1); // final 2 pixels horizontally should be clipped
Reviewed by Mark Rowe.
+ Bug 17620: getImageData lies
+ http://bugs.webkit.org/show_bug.cgi?id=17620
+
+ Correct logic to actually iterate over the source row
+
+ * platform/graphics/cg/ImageBufferCG.cpp:
+ (WebCore::ImageBuffer::getImageData):
+
+2008-03-03 Oliver Hunt <oliver@apple.com>
+
+ Reviewed by Mark Rowe.
+
Correct incorrect assertion
* platform/graphics/cg/ImageBufferCG.cpp:
unsigned char* destRows = data + desty * destBytesPerRow + destx * 4;
for (int y = 0; y < numRows; ++y) {
for (int x = 0; x < numColumns; x++) {
- if (unsigned char alpha = srcRows[3]) {
- destRows[0] = (srcRows[0] * 255) / alpha;
- destRows[1] = (srcRows[1] * 255) / alpha;
- destRows[2] = (srcRows[2] * 255) / alpha;
+ int basex = x * 4;
+ if (unsigned char alpha = srcRows[basex + 3]) {
+ destRows[0] = (srcRows[basex] * 255) / alpha;
+ destRows[1] = (srcRows[basex + 1] * 255) / alpha;
+ destRows[2] = (srcRows[basex + 2] * 255) / alpha;
destRows[3] = alpha;
} else {
reinterpret_cast<uint32_t*>(destRows)[0] = reinterpret_cast<uint32_t*>(srcRows)[0];