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

Commit a8f66857 authored by Huihong Luo's avatar Huihong Luo
Browse files

Fix color sampling for landscape

Region sampling listener accepts coordinates already in the correct orientation, no additional transforms are needed.

Bug: 178777512
Test: download Google I/O 2019 app, check system gesture navigation bar
color

Change-Id: I73f78a2a8390beb29b7ab33b2bed2b0326d367b1
parent 9345fd4c
Loading
Loading
Loading
Loading
+3 −24
Original line number Diff line number Diff line
@@ -287,33 +287,12 @@ void RegionSamplingThread::captureSample() {
        descriptors.emplace_back(descriptor);
    }

    auto dx = 0;
    auto dy = 0;
    switch (orientation) {
        case ui::Transform::ROT_90:
            dx = displaySize.getWidth();
            break;
        case ui::Transform::ROT_180:
            dx = displaySize.getWidth();
            dy = displaySize.getHeight();
            break;
        case ui::Transform::ROT_270:
            dy = displaySize.getHeight();
            break;
        default:
            break;
    }

    ui::Transform t(orientation);
    auto screencapRegion = t.transform(sampleRegion);
    screencapRegion = screencapRegion.translate(dx, dy);

    const Rect sampledBounds = sampleRegion.bounds();
    constexpr bool kUseIdentityTransform = false;

    SurfaceFlinger::RenderAreaFuture renderAreaFuture = ftl::defer([=] {
        return DisplayRenderArea::create(displayWeak, screencapRegion.bounds(),
                                         sampledBounds.getSize(), ui::Dataspace::V0_SRGB,
                                         orientation);
        return DisplayRenderArea::create(displayWeak, sampledBounds, sampledBounds.getSize(),
                                         ui::Dataspace::V0_SRGB, kUseIdentityTransform);
    });

    std::unordered_set<sp<IRegionSamplingListener>, SpHash<IRegionSamplingListener>> listeners;