diff options
4 files changed, 44 insertions, 5 deletions
diff --git a/libs/renderengine/gl/GLESRenderEngine.cpp b/libs/renderengine/gl/GLESRenderEngine.cpp index d0a0ac859c..c5c4cc4fc3 100644 --- a/libs/renderengine/gl/GLESRenderEngine.cpp +++ b/libs/renderengine/gl/GLESRenderEngine.cpp @@ -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) { diff --git a/libs/renderengine/include/renderengine/DisplaySettings.h b/libs/renderengine/include/renderengine/DisplaySettings.h index 0c923535bb..af8de2363c 100644 --- a/libs/renderengine/include/renderengine/DisplaySettings.h +++ b/libs/renderengine/include/renderengine/DisplaySettings.h @@ -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; }; diff --git a/libs/renderengine/include/renderengine/LayerSettings.h b/libs/renderengine/include/renderengine/LayerSettings.h index a37a16340c..a1ee37dc1a 100644 --- a/libs/renderengine/include/renderengine/LayerSettings.h +++ b/libs/renderengine/include/renderengine/LayerSettings.h @@ -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 diff --git a/libs/renderengine/tests/RenderEngineTest.cpp b/libs/renderengine/tests/RenderEngineTest.cpp index e43ee37ebc..b6e4edbb09 100644 --- a/libs/renderengine/tests/RenderEngineTest.cpp +++ b/libs/renderengine/tests/RenderEngineTest.cpp @@ -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 |