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

Commit c897fbfa authored by Romain Guy's avatar Romain Guy Committed by Android (Google) Code Review
Browse files

Merge "Code cleanup"

parents b81b1c91 02ccac69
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -22055,6 +22055,7 @@ package android.view {
    method protected boolean verifyDrawable(android.graphics.drawable.Drawable);
    method public boolean willNotCacheDrawing();
    method public boolean willNotDraw();
    field public static android.util.Property ALPHA;
    field public static final int DRAWING_CACHE_QUALITY_AUTO = 0; // 0x0
    field public static final int DRAWING_CACHE_QUALITY_HIGH = 1048576; // 0x100000
    field public static final int DRAWING_CACHE_QUALITY_LOW = 524288; // 0x80000
+7 −1
Original line number Diff line number Diff line
@@ -42,10 +42,16 @@ abstract class GLES20Layer extends HardwareLayer {
        return mLayer;
    }

    @Override
    boolean copyInto(Bitmap bitmap) {
        return GLES20Canvas.nCopyLayer(mLayer, bitmap.mNativeBitmap);
    }
    
    @Override
    void update(int width, int height, boolean isOpaque) {
        super.update(width, height, isOpaque);
    }

    @Override
    void destroy() {
        if (mFinalizer != null) mFinalizer.destroy();
+2 −0
Original line number Diff line number Diff line
@@ -70,7 +70,9 @@ class GLES20TextureLayer extends GLES20Layer {
        return mSurface;
    }

    @Override
    void update(int width, int height, boolean isOpaque) {
        super.update(width, height, isOpaque);
        GLES20Canvas.nUpdateTextureLayer(mLayer, width, height, isOpaque, mSurface);
    }
}
+28 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.view;

import android.graphics.Bitmap;
import android.graphics.Canvas;

/**
@@ -34,7 +35,7 @@ abstract class HardwareLayer {
    int mWidth;
    int mHeight;

    final boolean mOpaque;
    boolean mOpaque;

    /**
     * Creates a new hardware layer with undefined dimensions.
@@ -92,7 +93,7 @@ abstract class HardwareLayer {
    abstract boolean isValid();

    /**
     * Resizes the layer, if necessary, to be at least as large
     * Resize the layer, if necessary, to be at least as large
     * as the supplied dimensions.
     * 
     * @param width The new desired minimum width for this layer
@@ -124,4 +125,29 @@ abstract class HardwareLayer {
     * @param currentCanvas
     */
    abstract void end(Canvas currentCanvas);

    /**
     * Copies this layer into the specified bitmap.
     * 
     * @param bitmap The bitmap to copy they layer into
     * 
     * @return True if the copy was successful, false otherwise
     */
    abstract boolean copyInto(Bitmap bitmap);

    /**
     * Update the layer's properties. This method should be used
     * when the underlying storage is modified by an external entity.
     * To change the underlying storage, use the {@link #resize(int, int)}
     * method instead.
     * 
     * @param width The new width of this layer
     * @param height The new height of this layer
     * @param isOpaque Whether this layer is opaque
     */
    void update(int width, int height, boolean isOpaque) {
        mWidth = width;
        mHeight = height;
        mOpaque = isOpaque;
    }
}
+12 −58
Original line number Diff line number Diff line
@@ -17,12 +17,11 @@

package android.view;

import android.graphics.Bitmap;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.SurfaceTexture;
import android.os.*;
import android.util.EventLog;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.util.Log;

import javax.microedition.khronos.egl.EGL10;
@@ -198,26 +197,6 @@ public abstract class HardwareRenderer {
     */
    abstract SurfaceTexture createSurfaceTexture(HardwareLayer layer);

    /**
     * Updates the specified layer.
     * 
     * @param layer The hardware layer to update
     * @param width The layer's width
     * @param height The layer's height
     * @param isOpaque Whether the layer is opaque
     */
    abstract void updateTextureLayer(HardwareLayer layer, int width, int height, boolean isOpaque);

    /**
     * Copies the content of the specified layer into the specified bitmap.
     * 
     * @param layer The hardware layer to copy
     * @param bitmap The bitmap to copy the layer into
     * 
     * @return True if the copy was successful, false otherwise
     */
    abstract boolean copyLayer(HardwareLayer layer, Bitmap bitmap);    

    /**
     * Initializes the hardware renderer for the specified surface and setup the
     * renderer for drawing, if needed. This is invoked when the ViewAncestor has
@@ -341,6 +320,13 @@ public abstract class HardwareRenderer {
            mDirtyRegionsRequested = mDirtyRegions;
        }

        /**
         * Indicates whether this renderer instance can track and update dirty regions.
         */
        boolean hasDirtyRegions() {
            return mDirtyRegions;
        }

        /**
         * Return a string for the EGL error code, or the hex representation
         * if the error is unknown.
@@ -634,18 +620,13 @@ public abstract class HardwareRenderer {
        void draw(View view, View.AttachInfo attachInfo, HardwareDrawCallbacks callbacks,
                Rect dirty) {
            if (canDraw()) {
                if (!mDirtyRegions) {
                if (!hasDirtyRegions()) {
                    dirty = null;
                }

                attachInfo.mDrawingTime = SystemClock.uptimeMillis();
                attachInfo.mIgnoreDirtyState = true;
                view.mPrivateFlags |= View.DRAWN;
                attachInfo.mDrawingTime = SystemClock.uptimeMillis();

                long startTime;
                if (ViewDebug.DEBUG_PROFILE_DRAWING) {
                    startTime = SystemClock.elapsedRealtime();
                }
                view.mPrivateFlags |= View.DRAWN;
                
                final int surfaceState = checkCurrent();
                if (surfaceState != SURFACE_STATE_ERROR) {
@@ -700,26 +681,9 @@ public abstract class HardwareRenderer {

                    onPostDraw();

                    if (ViewDebug.DEBUG_PROFILE_DRAWING) {
                        EventLog.writeEvent(60000, SystemClock.elapsedRealtime() - startTime);
                    }
    
                    attachInfo.mIgnoreDirtyState = false;

                    final long swapBuffersStartTime;
                    if (ViewDebug.DEBUG_LATENCY) {
                        swapBuffersStartTime = System.nanoTime();
                    }

                    sEgl.eglSwapBuffers(sEglDisplay, mEglSurface);

                    if (ViewDebug.DEBUG_LATENCY) {
                        long now = System.nanoTime();
                        Log.d(LOG_TAG, "Latency: Spent "
                                + ((now - swapBuffersStartTime) * 0.000001f)
                                + "ms waiting for eglSwapBuffers()");
                    }

                    checkEglErrors();
                }
            }
@@ -820,16 +784,6 @@ public abstract class HardwareRenderer {
            return ((GLES20TextureLayer) layer).getSurfaceTexture();
        }

        @Override
        void updateTextureLayer(HardwareLayer layer, int width, int height, boolean isOpaque) {
            ((GLES20TextureLayer) layer).update(width, height, isOpaque);
        }

        @Override
        boolean copyLayer(HardwareLayer layer, Bitmap bitmap) {
            return ((GLES20Layer) layer).copyInto(bitmap);
        }

        static HardwareRenderer create(boolean translucent) {
            if (GLES20Canvas.isAvailable()) {
                return new Gl20Renderer(translucent);
Loading