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

Commit e09f1e87 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Clear region before drawing layers."

parents 30f231ca ac335531
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -714,6 +714,10 @@ status_t GLESRenderEngine::drawLayers(const DisplaySettings& display,
    setDisplayMaxLuminance(display.maxLuminance);

    mat4 projectionMatrix = mState.projectionMatrix * display.globalTransform;
    mState.projectionMatrix = projectionMatrix;
    if (!display.clearRegion.isEmpty()) {
        fillRegionWithColor(display.clearRegion, 0.0, 0.0, 0.0, 1.0);
    }

    Mesh mesh(Mesh::TRIANGLE_FAN, 4, 2, 2);
    for (auto layer : layers) {
+4 −3
Original line number Diff line number Diff line
@@ -51,9 +51,10 @@ struct DisplaySettings {
    // to the output dataspace.
    mat4 colorTransform = mat4();

    // Region that will be cleared to (0, 0, 0, 0) prior to rendering.
    // clearRegion will first be transformed by globalTransform so that it will
    // be in the same coordinate space as the rendered layers.
    // Region that will be cleared to (0, 0, 0, 1) prior to rendering.
    // RenderEngine will transform the clearRegion passed in here, by
    // globalTransform, so that it will be in the same coordinate space as the
    // rendered layers.
    Region clearRegion = Region::INVALID_REGION;
};

+2 −2
Original line number Diff line number Diff line
@@ -94,11 +94,11 @@ struct LayerSettings {
    half alpha = half(0.0);

    // Color space describing how the source pixels should be interpreted.
    ui::Dataspace sourceDataspace;
    ui::Dataspace sourceDataspace = ui::Dataspace::UNKNOWN;

    // Additional layer-specific color transform to be applied before the global
    // transform.
    mat4 colorTransform;
    mat4 colorTransform = mat4();
};

} // namespace renderengine
+34 −0
Original line number Diff line number Diff line
@@ -184,6 +184,12 @@ struct RenderEngineTest : public ::testing::Test {

    void fillBufferWithoutPremultiplyAlpha();

    void fillGreenColorBufferThenClearRegion();

    void clearLeftRegion();

    void fillBufferThenClearRegion();

    // Dumb hack to get aroud the fact that tear-down for renderengine isn't
    // well defined right now, so we can't create multiple instances
    static std::unique_ptr<renderengine::RenderEngine> sRE;
@@ -623,6 +629,30 @@ void RenderEngineTest::fillBufferWithoutPremultiplyAlpha() {
    expectBufferColor(fullscreenRect(), 128, 0, 0, 64, 1);
}

void RenderEngineTest::clearLeftRegion() {
    renderengine::DisplaySettings settings;
    settings.physicalDisplay = fullscreenRect();
    // Here logical space is 4x4
    settings.clip = Rect(4, 4);
    settings.globalTransform = mat4::scale(vec4(2, 4, 0, 1));
    settings.clearRegion = Region(Rect(1, 1));
    std::vector<renderengine::LayerSettings> layers;
    // dummy layer, without bounds should not render anything
    renderengine::LayerSettings layer;
    layers.push_back(layer);
    invokeDraw(settings, layers, mBuffer);
}

void RenderEngineTest::fillBufferThenClearRegion() {
    fillGreenBuffer<ColorSourceVariant>();
    // Reuse mBuffer
    clearLeftRegion();
    expectBufferColor(Rect(DEFAULT_DISPLAY_WIDTH / 2, DEFAULT_DISPLAY_HEIGHT), 0, 0, 0, 255);
    expectBufferColor(Rect(DEFAULT_DISPLAY_WIDTH / 2, 0, DEFAULT_DISPLAY_WIDTH,
                           DEFAULT_DISPLAY_HEIGHT),
                      0, 255, 0, 255);
}

TEST_F(RenderEngineTest, drawLayers_noLayersToDraw) {
    drawEmptyLayers();
}
@@ -771,4 +801,8 @@ TEST_F(RenderEngineTest, drawLayers_fillBuffer_withoutPremultiplyingAlpha) {
    fillBufferWithoutPremultiplyAlpha();
}

TEST_F(RenderEngineTest, drawLayers_fillBufferThenClearRegion) {
    fillBufferThenClearRegion();
}

} // namespace android