diff options
| author | 2019-03-07 20:59:59 -0800 | |
|---|---|---|
| committer | 2019-08-29 12:39:38 -0700 | |
| commit | c7b0c75f80c5cd5e1de1b7911981061bfd672f6e (patch) | |
| tree | 0da678446f4ceef8e92ba8aa9e2e0c7e913d4ac9 /services/surfaceflinger/Layer.cpp | |
| parent | 6a3b44698f365cb608f43df6e45844b4e18d3064 (diff) | |
SF: Move/Refactor updateCursorAsync to CompositionEngine
As part of this change, the existing LayerFE::latchCompositionState is
extended to allow for more state types to be fetched.
Test: atest libsurfaceflinger_unittest libcompositionengine_test
Bug: 121291683
Change-Id: I71e0f547440a64c1025f36741beb68e72c18e475
Diffstat (limited to 'services/surfaceflinger/Layer.cpp')
| -rw-r--r-- | services/surfaceflinger/Layer.cpp | 47 |
1 files changed, 15 insertions, 32 deletions
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index 5121835cae..557d0bba27 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -464,6 +464,21 @@ void Layer::latchPerFrameState(compositionengine::LayerFECompositionState& compo } } +void Layer::latchCursorCompositionState( + compositionengine::LayerFECompositionState& compositionState) const { + // This gives us only the "orientation" component of the transform + const State& drawingState{getDrawingState()}; + + // Apply the layer's transform, followed by the display's global transform + // Here we're guaranteed that the layer's transform preserves rects + Rect win = getCroppedBufferSize(drawingState); + // Subtract the transparent region and snap to the bounds + Rect bounds = reduce(win, getActiveTransparentRegion(drawingState)); + Rect frame(getTransform().transform(bounds)); + + compositionState.cursorFrame = frame; +} + bool Layer::onPreComposition(nsecs_t) { return false; } @@ -481,38 +496,6 @@ const char* Layer::getDebugName() const { return mName.string(); } -void Layer::updateCursorPosition(const sp<const DisplayDevice>& display) { - const auto outputLayer = findOutputLayerForDisplay(display); - LOG_FATAL_IF(!outputLayer); - - if (!outputLayer->getState().hwc || - (*outputLayer->getState().hwc).hwcCompositionType != - Hwc2::IComposerClient::Composition::CURSOR) { - return; - } - - // This gives us only the "orientation" component of the transform - const State& s(getDrawingState()); - - // Apply the layer's transform, followed by the display's global transform - // Here we're guaranteed that the layer's transform preserves rects - Rect win = getCroppedBufferSize(s); - // Subtract the transparent region and snap to the bounds - Rect bounds = reduce(win, getActiveTransparentRegion(s)); - Rect frame(getTransform().transform(bounds)); - frame.intersect(display->getViewport(), &frame); - auto& displayTransform = display->getTransform(); - auto position = displayTransform.transform(frame); - - auto error = - (*outputLayer->getState().hwc).hwcLayer->setCursorPosition(position.left, position.top); - ALOGE_IF(error != HWC2::Error::None, - "[%s] Failed to set cursor position " - "to (%d, %d): %s (%d)", - mName.string(), position.left, position.top, to_string(error).c_str(), - static_cast<int32_t>(error)); -} - // --------------------------------------------------------------------------- // drawing... // --------------------------------------------------------------------------- |