Loading libs/renderengine/gl/GLESRenderEngine.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -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) { Loading libs/renderengine/include/renderengine/DisplaySettings.h +4 −3 Original line number Diff line number Diff line Loading @@ -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; }; Loading libs/renderengine/include/renderengine/LayerSettings.h +2 −2 Original line number Diff line number Diff line Loading @@ -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 Loading libs/renderengine/tests/RenderEngineTest.cpp +34 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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(); } Loading Loading @@ -771,4 +801,8 @@ TEST_F(RenderEngineTest, drawLayers_fillBuffer_withoutPremultiplyingAlpha) { fillBufferWithoutPremultiplyAlpha(); } TEST_F(RenderEngineTest, drawLayers_fillBufferThenClearRegion) { fillBufferThenClearRegion(); } } // namespace android Loading
libs/renderengine/gl/GLESRenderEngine.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -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) { Loading
libs/renderengine/include/renderengine/DisplaySettings.h +4 −3 Original line number Diff line number Diff line Loading @@ -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; }; Loading
libs/renderengine/include/renderengine/LayerSettings.h +2 −2 Original line number Diff line number Diff line Loading @@ -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 Loading
libs/renderengine/tests/RenderEngineTest.cpp +34 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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(); } Loading Loading @@ -771,4 +801,8 @@ TEST_F(RenderEngineTest, drawLayers_fillBuffer_withoutPremultiplyingAlpha) { fillBufferWithoutPremultiplyAlpha(); } TEST_F(RenderEngineTest, drawLayers_fillBufferThenClearRegion) { fillBufferThenClearRegion(); } } // namespace android