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

Commit 3b1c32eb authored by Bart Sears's avatar Bart Sears Committed by Android (Google) Code Review
Browse files

Merge "Revert "Simplify TextureView draw path""

parents 36d4aaeb d35dcb13
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -20,7 +20,12 @@ import android.annotation.NonNull;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.CanvasProperty;
import android.graphics.NinePatch;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Picture;
import android.graphics.Rect;
import android.graphics.RectF;
import android.util.Pools.SynchronizedPool;

/**
@@ -201,12 +206,16 @@ public class DisplayListCanvas extends Canvas {
     * Draws the specified layer onto this canvas.
     *
     * @param layer The layer to composite on this canvas
     * @param x The left coordinate of the layer
     * @param y The top coordinate of the layer
     * @param paint The paint used to draw the layer
     */
    void drawHardwareLayer(HardwareLayer layer) {
        nDrawLayer(mNativeCanvasWrapper, layer.getLayerHandle());
    void drawHardwareLayer(HardwareLayer layer, float x, float y, Paint paint) {
        layer.setLayerPaint(paint);
        nDrawLayer(mNativeCanvasWrapper, layer.getLayerHandle(), x, y);
    }

    private static native void nDrawLayer(long renderer, long layer);
    private static native void nDrawLayer(long renderer, long layer, float x, float y);

    ///////////////////////////////////////////////////////////////////////////
    // Drawing
+4 −0
Original line number Diff line number Diff line
@@ -150,4 +150,8 @@ final class HardwareLayer {
    private static native void nSetSurfaceTexture(long layerUpdater,
            SurfaceTexture surface, boolean isAlreadyAttached);
    private static native void nUpdateSurfaceTexture(long layerUpdater);
    private static native void nUpdateRenderLayer(long layerUpdater, long displayList,
            int left, int top, int right, int bottom);

    private static native int nGetTexName(long layerUpdater);
}
+11 −17
Original line number Diff line number Diff line
@@ -319,25 +319,11 @@ public class TextureView extends View {
     */
    @Override
    public final void draw(Canvas canvas) {
        // NOTE: Maintain this carefully (see View#draw)
        // NOTE: Maintain this carefully (see View.java)
        mPrivateFlags = (mPrivateFlags & ~PFLAG_DIRTY_MASK) | PFLAG_DRAWN;

        /* Simplify drawing to guarantee the layer is the only thing drawn - so e.g. no background,
        scrolling, or fading edges. This guarantees all drawing is in the layer, so drawing
        properties (alpha, layer paint) affect all of the content of a TextureView. */

        if (canvas.isHardwareAccelerated()) {
            DisplayListCanvas displayListCanvas = (DisplayListCanvas) canvas;

            HardwareLayer layer = getHardwareLayer();
            if (layer != null) {
        applyUpdate();
        applyTransformMatrix();

                mLayer.setLayerPaint(mLayerPaint); // ensure layer paint is up to date
                displayListCanvas.drawHardwareLayer(layer);
            }
        }
    }

    /**
@@ -373,7 +359,12 @@ public class TextureView extends View {
        invalidate(true);
    }

    @Override
    HardwareLayer getHardwareLayer() {
        // NOTE: Maintain these two lines very carefully (see View.java)
        mPrivateFlags |= PFLAG_DRAWN | PFLAG_DRAWING_CACHE_VALID;
        mPrivateFlags &= ~PFLAG_DIRTY_MASK;

        if (mLayer == null) {
            if (mAttachInfo == null || mAttachInfo.mHardwareRenderer == null) {
                return null;
@@ -411,6 +402,9 @@ public class TextureView extends View {
            mSurface.setDefaultBufferSize(getWidth(), getHeight());
        }

        applyUpdate();
        applyTransformMatrix();

        return mLayer;
    }

+14 −1
Original line number Diff line number Diff line
@@ -15001,6 +15001,16 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        }
    }
    /**
     * If this View draws with a HardwareLayer, returns it.
     * Otherwise returns null
     *
     * TODO: Only TextureView uses this, can we eliminate it?
     */
    HardwareLayer getHardwareLayer() {
        return null;
    }
    /**
     * Destroys all hardware rendering resources. This method is invoked
     * when the system needs to reclaim resources. Upon execution of this
@@ -15151,7 +15161,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
            canvas.setHighContrastText(mAttachInfo.mHighContrastText);
            try {
                if (layerType == LAYER_TYPE_SOFTWARE) {
                final HardwareLayer layer = getHardwareLayer();
                if (layer != null && layer.isValid()) {
                    canvas.drawHardwareLayer(layer, 0, 0, mLayerPaint);
                } else if (layerType == LAYER_TYPE_SOFTWARE) {
                    buildDrawingCache(true);
                    Bitmap cache = getDrawingCache(true);
                    if (cache != null) {
+3 −3
Original line number Diff line number Diff line
@@ -139,10 +139,10 @@ static void android_view_DisplayListCanvas_drawRenderNode(JNIEnv* env,
// ----------------------------------------------------------------------------

static void android_view_DisplayListCanvas_drawLayer(JNIEnv* env, jobject clazz,
        jlong rendererPtr, jlong layerPtr) {
        jlong rendererPtr, jlong layerPtr, jfloat x, jfloat y) {
    DisplayListCanvas* renderer = reinterpret_cast<DisplayListCanvas*>(rendererPtr);
    DeferredLayerUpdater* layer = reinterpret_cast<DeferredLayerUpdater*>(layerPtr);
    renderer->drawLayer(layer);
    renderer->drawLayer(layer, x, y);
}

// ----------------------------------------------------------------------------
@@ -192,7 +192,7 @@ static JNINativeMethod gMethods[] = {
    { "nCreateDisplayListCanvas", "(II)J",     (void*) android_view_DisplayListCanvas_createDisplayListCanvas },
    { "nResetDisplayListCanvas", "(JII)V",     (void*) android_view_DisplayListCanvas_resetDisplayListCanvas },

    { "nDrawLayer",               "(JJ)V",     (void*) android_view_DisplayListCanvas_drawLayer },
    { "nDrawLayer",               "(JJFF)V",   (void*) android_view_DisplayListCanvas_drawLayer },

    { "nGetMaximumTextureWidth",  "()I",       (void*) android_view_DisplayListCanvas_getMaxTextureWidth },
    { "nGetMaximumTextureHeight", "()I",       (void*) android_view_DisplayListCanvas_getMaxTextureHeight },
Loading