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

Commit 4ff0cf4b authored by Romain Guy's avatar Romain Guy
Browse files

Add new debug tool to track hardware layers updates

You can setprop debug.hwui.show_layers_updates true to flash
hw layers in green when they update. This is also a setting
in the Dev. section of the settings app.

Change-Id: Ibe1d63a4f81567dc1d590c9b088d2e7505df8abf
parent bec1d13d
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -136,6 +136,18 @@ public abstract class HardwareRenderer {
     */
    public static final String DEBUG_DIRTY_REGIONS_PROPERTY = "debug.hwui.show_dirty_regions";

    /**
     * Turn on to flash hardware layers when they update.
     *
     * Possible values:
     * "true", to enable hardware layers updates debugging
     * "false", to disable hardware layers updates debugging
     *
     * @hide
     */
    public static final String DEBUG_SHOW_LAYERS_UPDATES_PROPERTY =
            "debug.hwui.show_layers_updates";

    /**
     * A process can set this flag to false to prevent the use of hardware
     * rendering.
+6 −4
Original line number Diff line number Diff line
@@ -881,15 +881,17 @@ public final class Bitmap implements Parcelable {
     * <code>(128, 128, 0, 0)</code>.</p>
     * 
     * <p>This method always returns false if {@link #getConfig()} is
     * {@link Bitmap.Config#ALPHA_8} or {@link Bitmap.Config#RGB_565}.</p>
     * {@link Bitmap.Config#RGB_565}.</p>
     * 
     * <p>This method only returns true if {@link #hasAlpha()} returns true.
     * A bitmap with no alpha channel can be used both as a pre-multiplied and
     * as a non pre-multiplied bitmap.</p>
     * 
     * @return true if the underlying pixels have been pre-multiplied, false
     *         otherwise
     */
    public final boolean isPremultiplied() {
        final Config config = getConfig();
        //noinspection deprecation
        return config == Config.ARGB_8888 || config == Config.ARGB_4444;
        return getConfig() != Config.RGB_565 && hasAlpha();
    }

    /** Returns the bitmap's width */
+11 −4
Original line number Diff line number Diff line
@@ -52,13 +52,10 @@ Caches::Caches(): Singleton<Caches>(), mInitialized(false) {
    initFont();
    initExtensions();
    initConstraints();
    initProperties();

    mDebugLevel = readDebugLevel();
    ALOGD("Enabling debug mode %d", mDebugLevel);

#if RENDER_LAYERS_AS_REGIONS
    INIT_LOGD("Layers will be composited as regions");
#endif
}

void Caches::init() {
@@ -126,6 +123,16 @@ void Caches::initConstraints() {
    glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
}

void Caches::initProperties() {
    char property[PROPERTY_VALUE_MAX];
    if (property_get(PROPERTY_DEBUG_LAYERS_UPDATES, property, NULL) > 0) {
        INIT_LOGD("  Layers updates debug enabled: %s", property);
        debugLayersUpdates = !strcmp(property, "true");
    } else {
        debugLayersUpdates = false;
    }
}

void Caches::terminate() {
    if (!mInitialized) return;

+2 −0
Original line number Diff line number Diff line
@@ -236,6 +236,7 @@ public:

    // Misc
    GLint maxTextureSize;
    bool debugLayersUpdates;

    TextureCache textureCache;
    LayerCache layerCache;
@@ -267,6 +268,7 @@ private:
    void initFont();
    void initExtensions();
    void initConstraints();
    void initProperties();

    static void eventMarkNull(GLsizei length, const GLchar* marker) { }
    static void startMarkNull(GLsizei length, const GLchar* marker) { }
+0 −10
Original line number Diff line number Diff line
@@ -45,7 +45,6 @@ int LayerRenderer::prepareDirty(float left, float top, float right, float bottom
    const float width = mLayer->layer.getWidth();
    const float height = mLayer->layer.getHeight();

#if RENDER_LAYERS_AS_REGIONS
    Rect dirty(left, top, right, bottom);
    if (dirty.isEmpty() || (dirty.left <= 0 && dirty.top <= 0 &&
            dirty.right >= width && dirty.bottom >= height)) {
@@ -58,9 +57,6 @@ int LayerRenderer::prepareDirty(float left, float top, float right, float bottom
    }

    return OpenGLRenderer::prepareDirty(dirty.left, dirty.top, dirty.right, dirty.bottom, opaque);
#else
    return OpenGLRenderer::prepareDirty(0.0f, 0.0f, width, height, opaque);
#endif
}

void LayerRenderer::finish() {
@@ -87,14 +83,10 @@ bool LayerRenderer::hasLayer() {
}

Region* LayerRenderer::getRegion() {
#if RENDER_LAYERS_AS_REGIONS
    if (getSnapshot()->flags & Snapshot::kFlagFboTarget) {
        return OpenGLRenderer::getRegion();
    }
    return &mLayer->region;
#else
    return OpenGLRenderer::getRegion();
#endif
}

// TODO: This implementation is flawed and can generate T-junctions
@@ -105,7 +97,6 @@ Region* LayerRenderer::getRegion() {
//       In practice, T-junctions do not appear often so this has yet
//       to be fixed.
void LayerRenderer::generateMesh() {
#if RENDER_LAYERS_AS_REGIONS
    if (mLayer->region.isRect() || mLayer->region.isEmpty()) {
        if (mLayer->mesh) {
            delete mLayer->mesh;
@@ -172,7 +163,6 @@ void LayerRenderer::generateMesh() {
            indices[index + 5] = quad + 3;   // bottom-right
        }
    }
#endif
}

///////////////////////////////////////////////////////////////////////////////
Loading