Merge "Pass ColorSpace along with HardwareBuffers" into qt-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
6e5efabcfd
@@ -18,6 +18,7 @@ package android.app;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.ColorSpace;
|
||||
import android.graphics.GraphicBuffer;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.RectF;
|
||||
@@ -49,6 +50,7 @@ public abstract class SharedElementCallback {
|
||||
private static final String BUNDLE_SNAPSHOT_BITMAP = "sharedElement:snapshot:bitmap";
|
||||
private static final String BUNDLE_SNAPSHOT_GRAPHIC_BUFFER =
|
||||
"sharedElement:snapshot:graphicBuffer";
|
||||
private static final String BUNDLE_SNAPSHOT_COLOR_SPACE = "sharedElement:snapshot:colorSpace";
|
||||
private static final String BUNDLE_SNAPSHOT_IMAGE_SCALETYPE = "sharedElement:snapshot:imageScaleType";
|
||||
private static final String BUNDLE_SNAPSHOT_IMAGE_MATRIX = "sharedElement:snapshot:imageMatrix";
|
||||
|
||||
@@ -186,6 +188,10 @@ public abstract class SharedElementCallback {
|
||||
} else {
|
||||
GraphicBuffer graphicBuffer = bitmap.createGraphicBufferHandle();
|
||||
bundle.putParcelable(BUNDLE_SNAPSHOT_GRAPHIC_BUFFER, graphicBuffer);
|
||||
ColorSpace cs = bitmap.getColorSpace();
|
||||
if (cs != null) {
|
||||
bundle.putInt(BUNDLE_SNAPSHOT_COLOR_SPACE, cs.getId());
|
||||
}
|
||||
}
|
||||
bundle.putString(BUNDLE_SNAPSHOT_IMAGE_SCALETYPE,
|
||||
imageView.getScaleType().toString());
|
||||
@@ -235,8 +241,13 @@ public abstract class SharedElementCallback {
|
||||
return null;
|
||||
}
|
||||
if (bitmap == null) {
|
||||
ColorSpace colorSpace = null;
|
||||
int colorSpaceId = bundle.getInt(BUNDLE_SNAPSHOT_COLOR_SPACE, 0);
|
||||
if (colorSpaceId >= 0 && colorSpaceId < ColorSpace.Named.values().length) {
|
||||
colorSpace = ColorSpace.get(ColorSpace.Named.values()[colorSpaceId]);
|
||||
}
|
||||
bitmap = Bitmap.wrapHardwareBuffer(HardwareBuffer.createFromGraphicBuffer(buffer),
|
||||
null);
|
||||
colorSpace);
|
||||
}
|
||||
ImageView imageView = new ImageView(context);
|
||||
view = imageView;
|
||||
|
||||
@@ -30,6 +30,7 @@ import android.app.contentsuggestions.ISelectionsCallback;
|
||||
import android.app.contentsuggestions.SelectionsRequest;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.ColorSpace;
|
||||
import android.graphics.GraphicBuffer;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@@ -62,11 +63,15 @@ public abstract class ContentSuggestionsService extends Service {
|
||||
private final IContentSuggestionsService mInterface = new IContentSuggestionsService.Stub() {
|
||||
@Override
|
||||
public void provideContextImage(int taskId, GraphicBuffer contextImage,
|
||||
Bundle imageContextRequestExtras) {
|
||||
int colorSpaceId, Bundle imageContextRequestExtras) {
|
||||
|
||||
Bitmap wrappedBuffer = null;
|
||||
if (contextImage != null) {
|
||||
wrappedBuffer = Bitmap.wrapHardwareBuffer(contextImage, null);
|
||||
ColorSpace colorSpace = null;
|
||||
if (colorSpaceId >= 0 && colorSpaceId < ColorSpace.Named.values().length) {
|
||||
colorSpace = ColorSpace.get(ColorSpace.Named.values()[colorSpaceId]);
|
||||
}
|
||||
wrappedBuffer = Bitmap.wrapHardwareBuffer(contextImage, colorSpace);
|
||||
}
|
||||
|
||||
mHandler.sendMessage(
|
||||
|
||||
@@ -32,6 +32,7 @@ oneway interface IContentSuggestionsService {
|
||||
void provideContextImage(
|
||||
int taskId,
|
||||
in GraphicBuffer contextImage,
|
||||
int colorSpaceId,
|
||||
in Bundle imageContextRequestExtras);
|
||||
void suggestContentSelections(
|
||||
in SelectionsRequest request,
|
||||
|
||||
@@ -2197,8 +2197,12 @@ public final class Bitmap implements Parcelable {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return {@link GraphicBuffer} which is internally used by hardware bitmap
|
||||
*
|
||||
* Note: the GraphicBuffer does *not* have an associated {@link ColorSpace}.
|
||||
* To render this object the same as its rendered with this Bitmap, you
|
||||
* should also call {@link getColorSpace}.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
|
||||
@@ -28,6 +28,7 @@ import android.app.contentsuggestions.SelectionsRequest;
|
||||
import android.content.ComponentName;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ServiceInfo;
|
||||
import android.graphics.ColorSpace;
|
||||
import android.graphics.GraphicBuffer;
|
||||
import android.os.Bundle;
|
||||
import android.os.RemoteException;
|
||||
@@ -99,11 +100,17 @@ public final class ContentSuggestionsPerUserService extends
|
||||
ActivityManager.TaskSnapshot snapshot =
|
||||
mActivityTaskManagerInternal.getTaskSnapshot(taskId, false);
|
||||
GraphicBuffer snapshotBuffer = null;
|
||||
int colorSpaceId = 0;
|
||||
if (snapshot != null) {
|
||||
snapshotBuffer = snapshot.getSnapshot();
|
||||
ColorSpace colorSpace = snapshot.getColorSpace();
|
||||
if (colorSpace != null) {
|
||||
colorSpaceId = colorSpace.getId();
|
||||
}
|
||||
}
|
||||
|
||||
service.provideContextImage(taskId, snapshotBuffer, imageContextRequestExtras);
|
||||
service.provideContextImage(taskId, snapshotBuffer, colorSpaceId,
|
||||
imageContextRequestExtras);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,9 +68,9 @@ public class RemoteContentSuggestionsService extends
|
||||
}
|
||||
|
||||
void provideContextImage(int taskId, @Nullable GraphicBuffer contextImage,
|
||||
@NonNull Bundle imageContextRequestExtras) {
|
||||
int colorSpaceId, @NonNull Bundle imageContextRequestExtras) {
|
||||
scheduleAsyncRequest((s) -> s.provideContextImage(taskId, contextImage,
|
||||
imageContextRequestExtras));
|
||||
colorSpaceId, imageContextRequestExtras));
|
||||
}
|
||||
|
||||
void suggestContentSelections(
|
||||
|
||||
Reference in New Issue
Block a user