Skip to content

Commit

Permalink
Merge pull request #9980 from Snuffleupagus/paintInline-Uint8ClampedA…
Browse files Browse the repository at this point in the history
…rray

Ensure that `Uint8ClampedArray` is used for image data transfered by `getTransfers` (PR 9802 follow-up)
  • Loading branch information
timvandermeij authored Aug 16, 2018
2 parents 1268aea + bc89edb commit 160ca55
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/core/operator_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* limitations under the License.
*/

import { ImageKind, OPS } from '../shared/util';
import { assert, ImageKind, OPS } from '../shared/util';

var QueueOptimizer = (function QueueOptimizerClosure() {
function addState(parentState, pattern, checkFn, iterateFn, processFn) {
Expand Down Expand Up @@ -116,7 +116,7 @@ var QueueOptimizer = (function QueueOptimizerClosure() {
}
var imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
var imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
var imgData = new Uint8Array(imgWidth * imgHeight * 4);
var imgData = new Uint8ClampedArray(imgWidth * imgHeight * 4);
var imgRowSize = imgWidth << 2;
for (q = 0; q < count; q++) {
var data = argsArray[iFirstPIIXO + (q << 2)][0].data;
Expand Down Expand Up @@ -543,6 +543,12 @@ var OperatorList = (function OperatorListClosure() {
case OPS.paintInlineImageXObjectGroup:
case OPS.paintImageMaskXObject:
var arg = argsArray[i][0]; // first param in imgData

if (typeof PDFJSDev === 'undefined' ||
PDFJSDev.test('!PRODUCTION || TESTING')) {
assert(arg.data instanceof Uint8ClampedArray,
'OperatorList - getTransfers: Unsupported "arg.data" type.');
}
if (!arg.cached) {
transfers.push(arg.data.buffer);
}
Expand Down

0 comments on commit 160ca55

Please sign in to comment.