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

Commit 46de9f56 authored by Chris Craik's avatar Chris Craik Committed by Android Git Automerger
Browse files

am 6659ac77: Merge "Avoid over-damaging layer area for multidraws" into mnc-dev

* commit '6659ac77':
  Avoid over-damaging layer area for multidraws
parents f249c3ee 6659ac77
Loading
Loading
Loading
Loading
+12 −7
Original line number Original line Diff line number Diff line
@@ -1097,7 +1097,7 @@ void OpenGLRenderer::dirtyLayer(const float left, const float top,
}
}


void OpenGLRenderer::dirtyLayerUnchecked(Rect& bounds, Region* region) {
void OpenGLRenderer::dirtyLayerUnchecked(Rect& bounds, Region* region) {
    if (bounds.intersect(mState.currentClipRect())) {
    if (CC_LIKELY(!bounds.isEmpty() && bounds.intersect(mState.currentClipRect()))) {
        bounds.snapToPixelBoundaries();
        bounds.snapToPixelBoundaries();
        android::Rect dirty(bounds.left, bounds.top, bounds.right, bounds.bottom);
        android::Rect dirty(bounds.left, bounds.top, bounds.right, bounds.bottom);
        if (!dirty.isEmpty()) {
        if (!dirty.isEmpty()) {
@@ -1146,7 +1146,7 @@ void OpenGLRenderer::clearLayerRegions() {
                .setTransform(*currentSnapshot(), transformFlags)
                .setTransform(*currentSnapshot(), transformFlags)
                .setModelViewOffsetRect(0, 0, Rect(currentSnapshot()->getClipRect()))
                .setModelViewOffsetRect(0, 0, Rect(currentSnapshot()->getClipRect()))
                .build();
                .build();
        renderGlop(glop, false);
        renderGlop(glop, GlopRenderType::LayerClear);


        if (scissorChanged) mRenderState.scissor().setEnabled(true);
        if (scissorChanged) mRenderState.scissor().setEnabled(true);
    } else {
    } else {
@@ -1454,10 +1454,15 @@ void OpenGLRenderer::debugClip() {
#endif
#endif
}
}


void OpenGLRenderer::renderGlop(const Glop& glop, bool clearLayer) {
void OpenGLRenderer::renderGlop(const Glop& glop, GlopRenderType type) {
    // TODO: It would be best if we could do this before quickRejectSetupScissor()
    // TODO: It would be best if we could do this before quickRejectSetupScissor()
    //       changes the scissor test state
    //       changes the scissor test state
    if (clearLayer) clearLayerRegions();
    if (type != GlopRenderType::LayerClear) {
        // Regular draws need to clear the dirty area on the layer before they start drawing on top
        // of it. If this draw *is* a layer clear, it skips the clear step (since it would
        // infinitely recurse)
        clearLayerRegions();
    }


    if (mState.getDirtyClip()) {
    if (mState.getDirtyClip()) {
        if (mRenderState.scissor().isEnabled()) {
        if (mRenderState.scissor().isEnabled()) {
@@ -1467,7 +1472,7 @@ void OpenGLRenderer::renderGlop(const Glop& glop, bool clearLayer) {
        setStencilFromClip();
        setStencilFromClip();
    }
    }
    mRenderState.render(glop);
    mRenderState.render(glop);
    if (!mRenderState.stencil().isWriteEnabled()) {
    if (type == GlopRenderType::Standard && !mRenderState.stencil().isWriteEnabled()) {
        // TODO: specify more clearly when a draw should dirty the layer.
        // TODO: specify more clearly when a draw should dirty the layer.
        // is writing to the stencil the only time we should ignore this?
        // is writing to the stencil the only time we should ignore this?
        dirtyLayer(glop.bounds.left, glop.bounds.top, glop.bounds.right, glop.bounds.bottom);
        dirtyLayer(glop.bounds.left, glop.bounds.top, glop.bounds.right, glop.bounds.bottom);
@@ -1540,7 +1545,7 @@ void OpenGLRenderer::drawBitmaps(const SkBitmap* bitmap, AssetAtlas::Entry* entr
            .setTransform(*currentSnapshot(), transformFlags)
            .setTransform(*currentSnapshot(), transformFlags)
            .setModelViewOffsetRectOptionalSnap(snap, x, y, Rect(0, 0, bounds.getWidth(), bounds.getHeight()))
            .setModelViewOffsetRectOptionalSnap(snap, x, y, Rect(0, 0, bounds.getWidth(), bounds.getHeight()))
            .build();
            .build();
    renderGlop(glop);
    renderGlop(glop, GlopRenderType::Multi);
}
}


void OpenGLRenderer::drawBitmap(const SkBitmap* bitmap, const SkPaint* paint) {
void OpenGLRenderer::drawBitmap(const SkBitmap* bitmap, const SkPaint* paint) {
@@ -1738,7 +1743,7 @@ void OpenGLRenderer::drawPatches(const SkBitmap* bitmap, AssetAtlas::Entry* entr
            .setTransform(*currentSnapshot(), transformFlags)
            .setTransform(*currentSnapshot(), transformFlags)
            .setModelViewOffsetRect(0, 0, Rect(0, 0, 0, 0))
            .setModelViewOffsetRect(0, 0, Rect(0, 0, 0, 0))
            .build();
            .build();
    renderGlop(glop);
    renderGlop(glop, GlopRenderType::Multi);
}
}


void OpenGLRenderer::drawVertexBuffer(float translateX, float translateY,
void OpenGLRenderer::drawVertexBuffer(float translateX, float translateY,
+7 −1
Original line number Original line Diff line number Diff line
@@ -535,7 +535,13 @@ protected:
    RenderState& mRenderState;
    RenderState& mRenderState;


private:
private:
    void renderGlop(const Glop& glop, bool clearLayer = true);
    enum class GlopRenderType {
        Standard,
        Multi,
        LayerClear
    };

    void renderGlop(const Glop& glop, GlopRenderType type = GlopRenderType::Standard);


    /**
    /**
     * Discards the content of the framebuffer if supported by the driver.
     * Discards the content of the framebuffer if supported by the driver.