Browse Source

Merge pull request #4474 from chriskr/draw-image-subpixel-support

Introduce paintSolidColorImageMask command to handle 1x1 solid image
Yury Delendik 11 years ago
parent
commit
1801fb2c37
  1. 20
      src/core/evaluator.js
  2. 5
      src/display/canvas.js
  3. 3
      src/shared/util.js
  4. 2
      test/pdfs/issue4436.pdf.link
  5. 9
      test/test_manifest.json

20
src/core/evaluator.js

@ -1696,6 +1696,25 @@ var QueueOptimizer = (function QueueOptimizerClosure() {
state[pattern[pattern.length - 1]] = fn; state[pattern[pattern.length - 1]] = fn;
} }
function handlePaintSolidColorImageMask(index, count, fnArray, argsArray) {
// Handles special case of mainly latex documents which
// use image masks to draw lines with the current fill style.
// 'count' groups of (save, transform, paintImageMaskXObject, restore)+
// have been found at index.
for (var i = 0; i < count; i++) {
var arg = argsArray[index + 4 * i + 2];
var imageMask = arg.length == 1 && arg[0];
if (imageMask && imageMask.width == 1 && imageMask.height == 1 &&
(!imageMask.data.length || (imageMask.data.length == 1 &&
imageMask.data[0] === 0))) {
fnArray[index + 4 * i + 2] = OPS.paintSolidColorImageMask;
continue;
}
break;
}
return count - i;
}
var InitialState = []; var InitialState = [];
addState(InitialState, addState(InitialState,
@ -1799,6 +1818,7 @@ var QueueOptimizer = (function QueueOptimizerClosure() {
for (; i < ii && fnArray[i - 4] === fnArray[i]; i++) { for (; i < ii && fnArray[i - 4] === fnArray[i]; i++) {
} }
var count = (i - j) >> 2; var count = (i - j) >> 2;
count = handlePaintSolidColorImageMask(j, count, fnArray, argsArray);
if (count < MIN_IMAGES_IN_MASKS_BLOCK) { if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
context.currentOperation = i - 1; context.currentOperation = i - 1;
return; return;

5
src/display/canvas.js

@ -2128,6 +2128,11 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
} }
}, },
paintSolidColorImageMask:
function CanvasGraphics_paintSolidColorImageMask() {
this.ctx.fillRect(0, 0, 1, 1);
},
// Marked content // Marked content
markPoint: function CanvasGraphics_markPoint(tag) { markPoint: function CanvasGraphics_markPoint(tag) {

3
src/shared/util.js

@ -151,7 +151,8 @@ var OPS = PDFJS.OPS = {
paintInlineImageXObject: 86, paintInlineImageXObject: 86,
paintInlineImageXObjectGroup: 87, paintInlineImageXObjectGroup: 87,
paintImageXObjectRepeat: 88, paintImageXObjectRepeat: 88,
paintImageMaskXObjectRepeat: 89 paintImageMaskXObjectRepeat: 89,
paintSolidColorImageMask: 90,
}; };
// A notice for devs. These are good for things that are helpful to devs, such // A notice for devs. These are good for things that are helpful to devs, such

2
test/pdfs/issue4436.pdf.link

@ -0,0 +1,2 @@
http://arxiv.org/pdf/1203.6597v3.pdf

9
test/test_manifest.json

@ -1575,5 +1575,14 @@
"rounds": 1, "rounds": 1,
"type": "eq", "type": "eq",
"about": "Image mask in higher resolution than the image itself" "about": "Image mask in higher resolution than the image itself"
},
{ "id": "issue4436",
"file": "pdfs/issue4436.pdf",
"md5": "34e6af7441961f5940e6440a62e37427",
"rounds": 1,
"link": true,
"firstPage": 9,
"lastPage": 9,
"type": "eq"
} }
] ]

Loading…
Cancel
Save