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

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

Merge "Fix INVALID_OPERATION error with layers rendering."

parents dc71b9e4 0bb5667b
Loading
Loading
Loading
Loading
+8 −32
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package android.view;

import android.content.ClipData;
import android.content.ClipDescription;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
@@ -55,7 +54,6 @@ import android.util.PoolableManager;
import android.util.Pools;
import android.util.SparseArray;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.DragEvent;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityEventSource;
import android.view.accessibility.AccessibilityManager;
@@ -2038,7 +2036,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
     *
     */
    boolean mCanAcceptDrop;
    private boolean mIsCurrentDropTarget;
    private int mThumbnailWidth;
    private int mThumbnailHeight;

@@ -9800,11 +9797,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
                    + " surface=" + surface);
            if (token != null) {
                Canvas canvas = surface.lockCanvas(null);
                try {
                    onDrawDragThumbnail(canvas);
                } finally {
                    surface.unlockCanvasAndPost(canvas);
                }

                okay = mAttachInfo.mSession.performDrag(mAttachInfo.mWindow, token,
                        touchX, touchY, thumbnailTouchX, thumbnailTouchX, data);
                        touchX, touchY, thumbnailTouchX, thumbnailTouchY, data);
                if (DEBUG_DRAG) Log.d(VIEW_LOG_TAG, "performDrag returned " + okay);
            }
        } catch (Exception e) {
@@ -9837,8 +9837,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
     * The View must call this method from onMeasureDragThumbnail() in order to
     * specify the dimensions of the drag thumbnail image.
     *
     * @param width
     * @param height
     * @param width The desired thumbnail width.
     * @param height The desired thumbnail height.
     */
    protected final void setDragThumbnailDimension(int width, int height) {
        mPrivateFlags |= MEASURED_DIMENSION_SET;
@@ -9973,30 +9973,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
                ViewConfiguration.getLongPressTimeout() - delayOffset);
    }

    private static int[] stateSetUnion(final int[] stateSet1, final int[] stateSet2) {
        final int stateSet1Length = stateSet1.length;
        final int stateSet2Length = stateSet2.length;
        final int[] newSet = new int[stateSet1Length + stateSet2Length];
        int k = 0;
        int i = 0;
        int j = 0;
        // This is a merge of the two input state sets and assumes that the
        // input sets are sorted by the order imposed by ViewDrawableStates.
        for (int viewState : R.styleable.ViewDrawableStates) {
            if (i < stateSet1Length && stateSet1[i] == viewState) {
                newSet[k++] = viewState;
                i++;
            } else if (j < stateSet2Length && stateSet2[j] == viewState) {
                newSet[k++] = viewState;
                j++;
            }
            if (k > 1) {
                assert(newSet[k - 1] > newSet[k - 2]);
            }
        }
        return newSet;
    }

    /**
     * Inflate a view from an XML resource.  This convenience method wraps the {@link
     * LayoutInflater} class, which provides a full range of options for view inflation.
+3 −3
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ struct LayerSize {
    uint32_t id;

    bool operator<(const LayerSize& rhs) const {
        if (id != 0 && rhs.id != 0) {
        if (id != 0 && rhs.id != 0 && id != rhs.id) {
            return id < rhs.id;
        }
        if (width == rhs.width) {
@@ -54,7 +54,7 @@ struct LayerSize {
    }

    bool operator==(const LayerSize& rhs) const {
        return width == rhs.width && height == rhs.height;
        return id == rhs.id && width == rhs.width && height == rhs.height;
    }
}; // struct LayerSize

@@ -83,7 +83,7 @@ struct Layer {
     */
    bool blend;
    /**
     * Indicates that this layer has never been used before.
     * Indicates whether this layer has been used already.
     */
    bool empty;
}; // struct Layer
+2 −0
Original line number Diff line number Diff line
@@ -114,6 +114,8 @@ Layer* LayerCache::get(LayerSize& size) {
        glGenTextures(1, &layer->texture);
        glBindTexture(GL_TEXTURE_2D, layer->texture);

        glPixelStorei(GL_UNPACK_ALIGNMENT, 4);

        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

+18 −11
Original line number Diff line number Diff line
@@ -366,6 +366,8 @@ bool OpenGLRenderer::createLayer(sp<Snapshot> snapshot, float left, float top,
        return false;
    }

    glActiveTexture(GL_TEXTURE0);

    LayerSize size(bounds.getWidth(), bounds.getHeight());
    Layer* layer = mCaches.layerCache.get(size);
    if (!layer) {
@@ -383,17 +385,22 @@ bool OpenGLRenderer::createLayer(sp<Snapshot> snapshot, float left, float top,
    // Copy the framebuffer into the layer
    glBindTexture(GL_TEXTURE_2D, layer->texture);

    if (layer->empty) {
    // TODO: Workaround for b/3054204
    glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bounds.left, mHeight - bounds.bottom,
            bounds.getWidth(), bounds.getHeight(), 0);
        layer->empty = false;
    } else {
        glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, bounds.left, mHeight - bounds.bottom,
                bounds.getWidth(), bounds.getHeight());
    }

    if (flags & SkCanvas::kClipToLayer_SaveFlag) {
        if (mSnapshot->clipTransformed(bounds)) setScissorFromClip();
    // TODO: Waiting for b/3054204 to be fixed
//    if (layer->empty) {
//        glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bounds.left, mHeight - bounds.bottom,
//                bounds.getWidth(), bounds.getHeight(), 0);
//        layer->empty = false;
//    } else {
//        glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, bounds.left, mHeight - bounds.bottom,
//                bounds.getWidth(), bounds.getHeight());
//    }

    if (flags & SkCanvas::kClipToLayer_SaveFlag && mSnapshot->clipTransformed(bounds)) {
        setScissorFromClip();
    }

    // Enqueue the buffer coordinates to clear the corresponding region later
+9 −0
Original line number Diff line number Diff line
@@ -165,6 +165,15 @@
            </intent-filter>
        </activity>
        
        <activity
                android:name="GradientsActivity"
                android:label="_Gradients">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
                android:name="ShadersActivity"
                android:label="_Shaders">
Loading