Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e6034a30 authored by Leon Scroggins's avatar Leon Scroggins Committed by android-build-merger
Browse files

Merge "Pass ColorSpace along with HardwareBuffers" into qt-dev

am: 6e5efabc

Change-Id: Icd1b07906441304aaa97fd3e7b8228e19eeef09b
parents 8e6c24d9 6e5efabc
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -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;
+7 −2
Original line number Diff line number Diff line
@@ -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(
+1 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ oneway interface IContentSuggestionsService {
    void provideContextImage(
            int taskId,
            in GraphicBuffer contextImage,
            int colorSpaceId,
            in Bundle imageContextRequestExtras);
    void suggestContentSelections(
            in SelectionsRequest request,
+5 −1
Original line number Diff line number Diff line
@@ -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
+8 −1
Original line number Diff line number Diff line
@@ -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);
        }
    }

Loading