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

Commit ceec31b7 authored by Mathias Agopian's avatar Mathias Agopian Committed by Android (Google) Code Review
Browse files

Merge changes I5a218ca1,I853a76d9

* changes:
  Refactoring: Rename SurfaceTextureClient to Surface
  clean-up following Surface split
parents aa8307b9 52800617
Loading
Loading
Loading
Loading
+36 −38
Original line number Diff line number Diff line
@@ -32,6 +32,20 @@ import dalvik.system.CloseGuard;
public class Surface implements Parcelable {
    private static final String TAG = "Surface";

    private static native int nativeCreateFromSurfaceTexture(SurfaceTexture surfaceTexture)
            throws OutOfResourcesException;

    private native Canvas nativeLockCanvas(int nativeObject, Rect dirty);
    private native void nativeUnlockCanvasAndPost(int nativeObject, Canvas canvas);

    private static native void nativeRelease(int nativeObject);
    private static native void nativeDestroy(int nativeObject);
    private static native boolean nativeIsValid(int nativeObject);
    private static native boolean nativeIsConsumerRunningBehind(int nativeObject);
    private static native int nativeCopyFrom(int nativeObject, int surfaceControlNativeObject);
    private static native int nativeReadFromParcel(int nativeObject, Parcel source);
    private static native void nativeWriteToParcel(int nativeObject, Parcel dest);

    public static final Parcelable.Creator<Surface> CREATOR =
            new Parcelable.Creator<Surface>() {
        public Surface createFromParcel(Parcel source) {
@@ -44,33 +58,11 @@ public class Surface implements Parcelable {
                return null;
            }
        }

        public Surface[] newArray(int size) {
            return new Surface[size];
        }
    };

    /**
     * Rotation constant: 0 degree rotation (natural orientation)
     */
    public static final int ROTATION_0 = 0;

    /**
     * Rotation constant: 90 degree rotation.
     */
    public static final int ROTATION_90 = 1;

    /**
     * Rotation constant: 180 degree rotation.
     */
    public static final int ROTATION_180 = 2;

    /**
     * Rotation constant: 270 degree rotation.
     */
    public static final int ROTATION_270 = 3;


    private final CloseGuard mCloseGuard = CloseGuard.get();
    private String mName;

@@ -94,6 +86,28 @@ public class Surface implements Parcelable {
    private Matrix mCompatibleMatrix;


    /**
     * Rotation constant: 0 degree rotation (natural orientation)
     */
    public static final int ROTATION_0 = 0;

    /**
     * Rotation constant: 90 degree rotation.
     */
    public static final int ROTATION_90 = 1;

    /**
     * Rotation constant: 180 degree rotation.
     */
    public static final int ROTATION_180 = 2;

    /**
     * Rotation constant: 270 degree rotation.
     */
    public static final int ROTATION_270 = 3;



    /**
     * Create an empty surface, which will later be filled in by readFromParcel().
     * @hide
@@ -436,20 +450,4 @@ public class Surface implements Parcelable {
        if (mNativeObject == 0) throw new NullPointerException(
                "mNativeObject is null. Have you called release() already?");
    }

    private native int nativeCreateFromSurfaceTexture(SurfaceTexture surfaceTexture)
            throws OutOfResourcesException;

    private native void nativeRelease(int nativeObject);
    private native void nativeDestroy(int nativeObject);
    private native boolean nativeIsValid(int nativeObject);

    private native boolean nativeIsConsumerRunningBehind(int nativeObject);

    private native Canvas nativeLockCanvas(int nativeObject, Rect dirty);
    private native void nativeUnlockCanvasAndPost(int nativeObject, Canvas canvas);
    
    private native int nativeCopyFrom(int nativeObject, int surfaceControlNativeObject);
    private native int nativeReadFromParcel(int nativeObject, Parcel source);
    private native void nativeWriteToParcel(int nativeObject, Parcel dest);
}
+40 −40
Original line number Diff line number Diff line
@@ -30,6 +30,46 @@ import android.util.Log;
 */
public class SurfaceControl {
    private static final String TAG = "SurfaceControl";

    private static native int nativeCreate(SurfaceSession session, String name,
            int w, int h, int format, int flags)
            throws OutOfResourcesException;
    private static native void nativeRelease(int nativeObject);
    private static native void nativeDestroy(int nativeObject);

    private static native Bitmap nativeScreenshot(IBinder displayToken,
            int width, int height, int minLayer, int maxLayer, boolean allLayers);

    private static native void nativeOpenTransaction();
    private static native void nativeCloseTransaction();
    private static native void nativeSetAnimationTransaction();

    private static native void nativeSetLayer(int nativeObject, int zorder);
    private static native void nativeSetPosition(int nativeObject, float x, float y);
    private static native void nativeSetSize(int nativeObject, int w, int h);
    private static native void nativeSetTransparentRegionHint(int nativeObject, Region region);
    private static native void nativeSetAlpha(int nativeObject, float alpha);
    private static native void nativeSetMatrix(int nativeObject, float dsdx, float dtdx, float dsdy, float dtdy);
    private static native void nativeSetFlags(int nativeObject, int flags, int mask);
    private static native void nativeSetWindowCrop(int nativeObject, int l, int t, int r, int b);
    private static native void nativeSetLayerStack(int nativeObject, int layerStack);

    private static native IBinder nativeGetBuiltInDisplay(int physicalDisplayId);
    private static native IBinder nativeCreateDisplay(String name, boolean secure);
    private static native void nativeSetDisplaySurface(
            IBinder displayToken, int nativeSurfaceObject);
    private static native void nativeSetDisplayLayerStack(
            IBinder displayToken, int layerStack);
    private static native void nativeSetDisplayProjection(
            IBinder displayToken, int orientation,
            int l, int t, int r, int b, 
            int L, int T, int R, int B);
    private static native boolean nativeGetDisplayInfo(
            IBinder displayToken, SurfaceControl.PhysicalDisplayInfo outInfo);
    private static native void nativeBlankDisplay(IBinder displayToken);
    private static native void nativeUnblankDisplay(IBinder displayToken);


    private final CloseGuard mCloseGuard = CloseGuard.get();
    private String mName;
    int mNativeObject; // package visibility only for Surface.java access
@@ -532,44 +572,4 @@ public class SurfaceControl {
            throw new UnsupportedOperationException("Device is headless");
        }
    }
    
    

    private native int nativeCreate(SurfaceSession session, String name,
            int w, int h, int format, int flags)
            throws OutOfResourcesException;
    private native void nativeRelease(int nativeObject);
    private native void nativeDestroy(int nativeObject);
    
    private static native Bitmap nativeScreenshot(IBinder displayToken,
            int width, int height, int minLayer, int maxLayer, boolean allLayers);
    
    private static native void nativeOpenTransaction();
    private static native void nativeCloseTransaction();
    private static native void nativeSetAnimationTransaction();

    private native void nativeSetLayer(int nativeObject, int zorder);
    private native void nativeSetPosition(int nativeObject, float x, float y);
    private native void nativeSetSize(int nativeObject, int w, int h);
    private native void nativeSetTransparentRegionHint(int nativeObject, Region region);
    private native void nativeSetAlpha(int nativeObject, float alpha);
    private native void nativeSetMatrix(int nativeObject, float dsdx, float dtdx, float dsdy, float dtdy);
    private native void nativeSetFlags(int nativeObject, int flags, int mask);
    private native void nativeSetWindowCrop(int nativeObject, int l, int t, int r, int b);
    private native void nativeSetLayerStack(int nativeObject, int layerStack);

    private static native IBinder nativeGetBuiltInDisplay(int physicalDisplayId);
    private static native IBinder nativeCreateDisplay(String name, boolean secure);
    private static native void nativeSetDisplaySurface(
            IBinder displayToken, int nativeSurfaceObject);
    private static native void nativeSetDisplayLayerStack(
            IBinder displayToken, int layerStack);
    private static native void nativeSetDisplayProjection(
            IBinder displayToken, int orientation,
            int l, int t, int r, int b, 
            int L, int T, int R, int B);
    private static native boolean nativeGetDisplayInfo(
            IBinder displayToken, SurfaceControl.PhysicalDisplayInfo outInfo);
    private static native void nativeBlankDisplay(IBinder displayToken);
    private static native void nativeUnblankDisplay(IBinder displayToken);
}
+3 −3
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@
#include <stdio.h>

#include <gui/GLConsumer.h>
#include <gui/SurfaceTextureClient.h>
#include <gui/Surface.h>

#include <android_runtime/AndroidRuntime.h>

@@ -86,8 +86,8 @@ sp<ANativeWindow> android_SurfaceTexture_getNativeWindow(
        JNIEnv* env, jobject thiz)
{
    sp<GLConsumer> surfaceTexture(SurfaceTexture_getSurfaceTexture(env, thiz));
    sp<SurfaceTextureClient> surfaceTextureClient(surfaceTexture != NULL ?
            new SurfaceTextureClient(surfaceTexture->getBufferQueue()) : NULL);
    sp<Surface> surfaceTextureClient(surfaceTexture != NULL ?
            new Surface(surfaceTexture->getBufferQueue()) : NULL);
    return surfaceTextureClient;
}

+1 −1
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ public:
            uint32_t width, uint32_t height, uint32_t flags) {
        JNIEnv* env = AndroidRuntime::getJNIEnv();

        jobject surfaceObj = android_view_Surface_createFromISurfaceTexture(env, bufferProducer);
        jobject surfaceObj = android_view_Surface_createFromIGraphicBufferProducer(env, bufferProducer);
        if (surfaceObj == NULL) {
            ALOGE("Could not create Surface from surface texture %p provided by media server.",
                  bufferProducer.get());
+2 −2
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@

#include <gui/Surface.h>
#include <gui/GLConsumer.h>
#include <gui/SurfaceTextureClient.h>
#include <gui/Surface.h>

#include <ui/ANativeObjectBase.h>

@@ -631,7 +631,7 @@ not_valid_surface:
    if (surfaceTexture == NULL)
        goto not_valid_surface;

    window = new android::SurfaceTextureClient(surfaceTexture->getBufferQueue());
    window = new android::Surface(surfaceTexture->getBufferQueue());

    if (window == NULL)
        goto not_valid_surface;
Loading