Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1027)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionImpl.java

Issue 2755393002: Revert of RELAND: ShapeDetection: use mojom::Bitmap for mojo interface. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionImpl.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionImpl.java b/chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionImpl.java
index f7d8f733f384d4db8d9c0f522cf9f95e70dbc2ea..6d46e5fa3985d7948e29ab92ed28f90c75b43914 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionImpl.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/shapedetection/BarcodeDetectionImpl.java
@@ -20,10 +20,11 @@
import org.chromium.gfx.mojom.PointF;
import org.chromium.gfx.mojom.RectF;
import org.chromium.mojo.system.MojoException;
+import org.chromium.mojo.system.SharedBufferHandle;
+import org.chromium.mojo.system.SharedBufferHandle.MapFlags;
import org.chromium.services.service_manager.InterfaceFactory;
import org.chromium.shape_detection.mojom.BarcodeDetection;
import org.chromium.shape_detection.mojom.BarcodeDetectionResult;
-import org.chromium.skia.mojom.ColorType;
import java.nio.ByteBuffer;
@@ -42,7 +43,8 @@
}
@Override
- public void detect(org.chromium.skia.mojom.Bitmap bitmapData, DetectResponse callback) {
+ public void detect(
+ SharedBufferHandle frameData, int width, int height, DetectResponse callback) {
if (!ExternalAuthUtils.getInstance().canUseGooglePlayServices(
mContext, new UserRecoverableErrorHandler.Silent())) {
Log.e(TAG, "Google Play Services not available");
@@ -59,21 +61,9 @@
return;
}
- // TODO(junwei.fu): Consider supporting other bitmap pixel formats,
- // https://crbug.com/684921.
- if (bitmapData.colorType != ColorType.RGBA_8888
- && bitmapData.colorType != ColorType.BGRA_8888) {
- Log.e(TAG, "Unsupported bitmap pixel format");
- callback.call(new BarcodeDetectionResult[0]);
- return;
- }
-
- int width = bitmapData.width;
- int height = bitmapData.height;
final long numPixels = (long) width * height;
// TODO(mcasas): https://crbug.com/670028 homogeneize overflow checking.
- if (bitmapData.pixelData == null || width <= 0 || height <= 0
- || numPixels > (Long.MAX_VALUE / 4)) {
+ if (!frameData.isValid() || width <= 0 || height <= 0 || numPixels > (Long.MAX_VALUE / 4)) {
callback.call(new BarcodeDetectionResult[0]);
return;
}
@@ -81,7 +71,7 @@
// Mapping |frameData| will fail if the intended mapped size is larger
// than its actual capacity, which is limited by the appropriate
// mojo::edk::Configuration entry.
- ByteBuffer imageBuffer = ByteBuffer.wrap(bitmapData.pixelData);
+ ByteBuffer imageBuffer = frameData.map(0, numPixels * 4, MapFlags.none());
if (imageBuffer.capacity() <= 0) {
callback.call(new BarcodeDetectionResult[0]);
return;
« no previous file with comments | « chrome/android/BUILD.gn ('k') | chrome/android/java/src/org/chromium/chrome/browser/shapedetection/TextDetectionImpl.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698