Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that Uint8ClampedArray is used for image data transfered by getTransfers (PR 9802 follow-up) #9980

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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