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

Commit f607bdc1 authored by Romain Guy's avatar Romain Guy
Browse files

Correct implementation of saveLayer().

Change-Id: I5375126636913e0a84f2d6bbd0ebe40d2e4f2763
parent d14f0dfd
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -16,9 +16,6 @@

package android.view;

import com.android.internal.R;
import com.android.internal.view.menu.MenuBuilder;

import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
@@ -49,8 +46,6 @@ import android.os.RemoteException;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.util.AttributeSet;
import android.util.Config;
import android.util.EventLog;
import android.util.Log;
import android.util.Pool;
import android.util.Poolable;
@@ -67,6 +62,8 @@ import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager;
import android.widget.ScrollBarDrawable;
import com.android.internal.R;
import com.android.internal.view.menu.MenuBuilder;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -4022,12 +4019,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
     */
    public boolean dispatchKeyEvent(KeyEvent event) {
        // If any attached key listener a first crack at the event.
        //noinspection SimplifiableIfStatement

        //noinspection SimplifiableIfStatement,deprecation
        if (android.util.Config.LOGV) {
            captureViewInfo("captureViewKeyEvent", this);
        }

        //noinspection SimplifiableIfStatement
        if (mOnKeyListener != null && (mViewFlags & ENABLED_MASK) == ENABLED
                && mOnKeyListener.onKey(this, event.getKeyCode(), event)) {
            return true;
@@ -4059,6 +4057,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
            return false;
        }

        //noinspection SimplifiableIfStatement
        if (mOnTouchListener != null && (mViewFlags & ENABLED_MASK) == ENABLED &&
                mOnTouchListener.onTouch(this, event)) {
            return true;
@@ -4075,6 +4074,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
     * @see #getFilterTouchesWhenObscured
     */
    public boolean onFilterTouchEventForSecurity(MotionEvent event) {
        //noinspection RedundantIfStatement
        if ((mViewFlags & FILTER_TOUCHES_WHEN_OBSCURED) != 0
                && (event.getFlags() & MotionEvent.FLAG_WINDOW_IS_OBSCURED) != 0) {
            // Window is obscured, drop this touch.
@@ -7829,8 +7829,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
        saveCount = canvas.getSaveCount();

        int solidColor = getSolidColor();
        // TODO: Temporarily disable fading edges with hardware acceleration
        if (solidColor == 0 && !canvas.isHardwareAccelerated()) {
        if (solidColor == 0) {
            final int flags = Canvas.HAS_ALPHA_LAYER_SAVE_FLAG;

            if (drawTop) {
@@ -9577,6 +9576,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
        if (mAttachInfo == null) {
            return false;
        }
        //noinspection SimplifiableIfStatement
        if ((flags & HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING) == 0
                && !isHapticFeedbackEnabled()) {
            return false;
−805 KiB (112 KiB)
Loading image diff...
+2 −11
Original line number Diff line number Diff line
@@ -63,28 +63,19 @@ struct LayerSize {
 */
struct Layer {
    /**
     * Coordinates of the layer corresponding to this snapshot.
     * Only set when the flag kFlagIsLayer is set.
     * Coordinates of the layer.
     */
    Rect layer;
    /**
     * Name of the texture used to render the layer.
     * Only set when the flag kFlagIsLayer is set.
     */
    GLuint texture;
    /**
     * Name of the FBO used to render the layer.
     * Only set when the flag kFlagIsLayer is set.
     */
    GLuint fbo;
    /**
     * Opacity of the layer.
     * Only set when the flag kFlagIsLayer is set.
     */
    float alpha;
    int alpha;
    /**
     * Blending mode of the layer.
     * Only set when the flag kFlagIsLayer is set.
     */
    SkXfermode::Mode mode;
    /**
+1 −23
Original line number Diff line number Diff line
@@ -87,7 +87,6 @@ void LayerCache::deleteLayer(Layer* layer) {
    if (layer) {
        mSize -= layer->layer.getWidth() * layer->layer.getHeight() * 4;

        glDeleteFramebuffers(1, &layer->fbo);
        glDeleteTextures(1, &layer->texture);
        delete layer;
    }
@@ -99,7 +98,7 @@ void LayerCache::clear() {
    mCache.setOnEntryRemovedListener(NULL);
}

Layer* LayerCache::get(LayerSize& size, GLuint previousFbo) {
Layer* LayerCache::get(LayerSize& size) {
    Layer* layer = mCache.remove(size);
    if (layer) {
        LAYER_LOGD("Reusing layer");
@@ -111,10 +110,6 @@ Layer* LayerCache::get(LayerSize& size, GLuint previousFbo) {
        layer = new Layer;
        layer->blend = true;

        // Generate the FBO and attach the texture
        glGenFramebuffers(1, &layer->fbo);
        glBindFramebuffer(GL_FRAMEBUFFER, layer->fbo);

        // Generate the texture in which the FBO will draw
        glGenTextures(1, &layer->texture);
        glBindTexture(GL_TEXTURE_2D, layer->texture);
@@ -128,23 +123,6 @@ Layer* LayerCache::get(LayerSize& size, GLuint previousFbo) {

        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size.width, size.height, 0,
                GL_RGBA, GL_UNSIGNED_BYTE, NULL);

        // Bind texture to FBO
        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
                layer->texture, 0);

        GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
        if (status != GL_FRAMEBUFFER_COMPLETE) {
            LOGE("Framebuffer incomplete (GL error code 0x%x)", status);

            glBindFramebuffer(GL_FRAMEBUFFER, previousFbo);

            glDeleteFramebuffers(1, &layer->fbo);
            glDeleteTextures(1, &layer->texture);
            delete layer;

            return NULL;
        }
    }

    return layer;
+1 −3
Original line number Diff line number Diff line
@@ -62,10 +62,8 @@ public:
     * size of the cache goes down.
     *
     * @param size The dimensions of the desired layer
     * @param previousFbo The name of the FBO to bind to if creating a new
     *        layer fails
     */
    Layer* get(LayerSize& size, GLuint previousFbo);
    Layer* get(LayerSize& size);
    /**
     * Adds the layer to the cache. The layer will not be added if there is
     * not enough space available.
Loading