Skip to content

Commit

Permalink
shapedetection: Let SkBitmap calculate minimum valid value for rowBytes
Browse files Browse the repository at this point in the history
In order to align with the expectation of SkBitmap.rowBytes() equal to
SkBitmap.info().minRowBytes() in bitmap_skbitmap_mojom_traits.cc, pass 0
for rowBytes parameter when calling SkBitmap.tryAllocPixels() for
SkBitmap to calculate minimum valid value for rowBytes.

A new shape-detection WPT test is added to test if detectors can process ImageData with uint16 storage format properly which is the case where minimal row bytes is half of the image row bytes.

Bug: 1242240
Change-Id: I4399e5c2cbda853cf6c5a5d269eea46d226a958b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3919646
Reviewed-by: Reilly Grant <[email protected]>
Commit-Queue: Jack Hsieh <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1052249}
  • Loading branch information
chengweih001 authored and chromium-wpt-export-bot committed Sep 28, 2022
1 parent 5e39747 commit 03c06a3
Showing 1 changed file with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// META: script=/resources/testharness.js
// META: script=/resources/testharnessreport.js
// META: script=/shape-detection/resources/shapedetection-helpers.js

const imgUint16 = new ImageData(1024, 1024, {storageFormat: 'uint16'});

// These tests verify that a Detector's detect() can process ImageData with
// uint16 storage format.
const imageDataTests = [
{
createDetector: () => {
return new FaceDetector();
},
mockTestName: 'FaceDetectionTest',
name:
'FaceDetector.detect() can process uint16 storage format ImageData'
},
{
createDetector: () => {
return new BarcodeDetector();
},
mockTestName: 'BarcodeDetectionTest',
name:
'BarcodeDetector.detect() can process uint16 storage format ImageData'
},
{
createDetector: () => {
return new TextDetector();
},
mockTestName: 'TextDetectionTest',
name:
'TextDetector.detect() can process uint16 storage format ImageData'
}
];

for (let imageDataTest of imageDataTests) {
detection_test(imageDataTest.mockTestName, async () => {
let detector = imageDataTest.createDetector();
await detector.detect(imgUint16);
}, imageDataTest.name);
}

0 comments on commit 03c06a3

Please sign in to comment.