mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Use white backdrop when possible.
This commit is contained in:
parent
04f6e17e11
commit
ec311f303b
5 changed files with 32 additions and 12 deletions
|
@ -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) {
|
||||
|
|
|
@ -415,7 +415,23 @@ 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.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);
|
||||
|
|
|
@ -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')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue