1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Merge pull request #3009 from brendandahl/backdrop

Use white backdrop when possible.
This commit is contained in:
Yury Delendik 2013-04-01 08:15:30 -07:00
commit 74b0a51cee
5 changed files with 33 additions and 13 deletions

View file

@ -384,11 +384,11 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
var stats = this.stats;
stats.time('Rendering');
gfx.beginDrawing(viewport);
var operatorList = this.operatorList;
gfx.beginDrawing(viewport, operatorList.transparency);
var startIdx = 0;
var length = this.operatorList.fnArray.length;
var operatorList = this.operatorList;
var length = operatorList.fnArray.length;
var stepper = null;
if (PDFJS.pdfBug && 'StepperManager' in globalScope &&
globalScope['StepperManager'].enabled) {

View file

@ -415,7 +415,24 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
'shadingFill': true
},
beginDrawing: function CanvasGraphics_beginDrawing(viewport) {
beginDrawing: function CanvasGraphics_beginDrawing(viewport, transparency) {
// For pdfs that use blend modes we have to clear the canvas else certain
// blend modes can look wrong since we'd be blending with a white
// backdrop. The problem with a transparent backdrop though is we then
// don't get sub pixel anti aliasing on text, so we fill with white if
// we can.
var width = this.ctx.canvas.width;
var height = this.ctx.canvas.height;
if (transparency) {
this.ctx.clearRect(0, 0, width, height);
} else {
this.ctx.mozOpaque = true;
this.ctx.save();
this.ctx.fillStyle = 'rgb(255, 255, 255)';
this.ctx.fillRect(0, 0, width, height);
this.ctx.restore();
}
var transform = viewport.transform;
this.ctx.save();
this.ctx.transform.apply(this.ctx, transform);

View file

@ -361,8 +361,11 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
}, handler, xref, resources, image, inline);
}
if (!queue)
queue = {};
if (!queue) {
queue = {
transparency: false
};
}
if (!queue.argsArray) {
queue.argsArray = [];
@ -532,7 +535,6 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
case 'FL':
case 'CA':
case 'ca':
case 'BM':
gsStateObj.push([key, value]);
break;
case 'Font':
@ -542,6 +544,12 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
value[1]
]);
break;
case 'BM':
if (!isName(value) || value.name !== 'Normal') {
queue.transparency = true;
}
gsStateObj.push([key, value]);
break;
case 'SMask':
// We support the default so don't trigger the TODO.
if (!isName(value) || value.name != 'None')