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

Commit 840b8a67 authored by Mathias Agopian's avatar Mathias Agopian
Browse files

Revert "Add a LayerScreenshot"

This reverts commit d6809f40.
parent 4fb6416e
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -194,9 +194,6 @@ public class Surface implements Parcelable {
     */
    public static final int FX_SURFACE_DIM     = 0x00020000;

    /** @hide */
    public static final int FX_SURFACE_SCREENSHOT   = 0x00030000;

    /** Mask used for FX values above @hide */
    public static final int FX_SURFACE_MASK     = 0x000F0000;

+0 −1
Original line number Diff line number Diff line
@@ -53,7 +53,6 @@ public:
        eFXSurfaceNormal    = 0x00000000,
        eFXSurfaceBlur      = 0x00010000,
        eFXSurfaceDim       = 0x00020000,
        eFXSurfaceScreenshot= 0x00030000,
        eFXSurfaceMask      = 0x000F0000,
    };

+36 −14
Original line number Diff line number Diff line
@@ -64,16 +64,17 @@ class ScreenRotationAnimation {
            boolean inTransaction, int originalWidth, int originalHeight, int originalRotation) {
        mContext = context;

        Bitmap screenshot = Surface.screenshot(0, 0);

        if (screenshot == null) {
            // Device is not capable of screenshots...  we can't do an animation.
            return;
        }

        // Screenshot does NOT include rotation!
        mSnapshotRotation = 0;
        if (originalRotation == Surface.ROTATION_90
                || originalRotation == Surface.ROTATION_270) {
            mWidth = originalHeight;
            mHeight = originalWidth;
        } else {
            mWidth = originalWidth;
            mHeight = originalHeight;
        }
        mWidth = screenshot.getWidth();
        mHeight = screenshot.getHeight();

        mOriginalRotation = originalRotation;
        mOriginalWidth = originalWidth;
@@ -88,12 +89,7 @@ class ScreenRotationAnimation {
        try {
            try {
                mSurface = new Surface(session, 0, "FreezeSurface",
                        -1, mWidth, mHeight, PixelFormat.OPAQUE, Surface.FX_SURFACE_SCREENSHOT);
                if (mSurface == null || !mSurface.isValid()) {
                    // Screenshot failed, punt.
                    mSurface = null;
                    return;
                }
                        -1, mWidth, mHeight, PixelFormat.OPAQUE, 0);
                mSurface.setLayer(FREEZE_LAYER + 1);
            } catch (Surface.OutOfResourcesException e) {
                Slog.w(TAG, "Unable to allocate freeze surface", e);
@@ -104,12 +100,38 @@ class ScreenRotationAnimation {
                            "  FREEZE " + mSurface + ": CREATE");

            setRotation(originalRotation);

            if (mSurface != null) {
                Rect dirty = new Rect(0, 0, mWidth, mHeight);
                Canvas c = null;
                try {
                    c = mSurface.lockCanvas(dirty);
                } catch (IllegalArgumentException e) {
                    Slog.w(TAG, "Unable to lock surface", e);
                } catch (Surface.OutOfResourcesException e) {
                    Slog.w(TAG, "Unable to lock surface", e);
                }
                if (c == null) {
                    Slog.w(TAG, "Null surface canvas");
                    mSurface.destroy();
                    mSurface = null;
                    return;
                }

                Paint paint = new Paint(0);
                paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));
                c.drawBitmap(screenshot, 0, 0, paint);

                mSurface.unlockCanvasAndPost(c);
            }
        } finally {
            if (!inTransaction) {
                Surface.closeTransaction();
                if (WindowManagerService.SHOW_LIGHT_TRANSACTIONS) Slog.i(WindowManagerService.TAG,
                        "<<< CLOSE TRANSACTION ScreenRotationAnimation");
            }
    
            screenshot.recycle();
        }
    }

+0 −1
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@ LOCAL_SRC_FILES:= \
    Layer.cpp 								\
    LayerBase.cpp 							\
    LayerDim.cpp 							\
    LayerScreenshot.cpp						\
    DdmConnection.cpp						\
    DisplayHardware/DisplayHardware.cpp 	\
    DisplayHardware/DisplayHardwareBase.cpp \
+10 −2
Original line number Diff line number Diff line
@@ -88,8 +88,16 @@ void Layer::onFirstRef()

Layer::~Layer()
{
    mFlinger->postMessageAsync(
            new SurfaceFlinger::MessageDestroyGLTexture(mTextureName) );
    class MessageDestroyGLState : public MessageBase {
        GLuint texture;
    public:
        MessageDestroyGLState(GLuint texture) : texture(texture) { }
        virtual bool handler() {
            glDeleteTextures(1, &texture);
            return true;
        }
    };
    mFlinger->postMessageAsync( new MessageDestroyGLState(mTextureName) );
}

void Layer::onFrameQueued() {
Loading