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

Commit c80dcbb5 authored by Chia-I Wu's avatar Chia-I Wu
Browse files

surfaceflinger: remove ISurfaceComposer.h from RenderArea

RenderArea can be made more generic by removing ISurfaceComposer.h
dependency.  The caller also prefers to work with
ui::Transform::orientation_flags than ISurfaceComposer::Rotation (we
want to move updateDimensions to the caller).

Bug: 113041375
Test: take screenshot, rotate screen, screencap
Change-Id: I16e1392d5c92c2f423f98307e867918415404d26
parent 9d1abea9
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@

#include <binder/IBinder.h>
#include <hardware/hwcomposer_defs.h>
#include <gui/ISurfaceComposer.h>
#include <math/mat4.h>
#include <renderengine/Surface.h>
#include <ui/GraphicTypes.h>
@@ -334,11 +333,11 @@ private:
class DisplayRenderArea : public RenderArea {
public:
    DisplayRenderArea(const sp<const DisplayDevice> device,
                      ISurfaceComposer::Rotation rotation = ISurfaceComposer::eRotateNone)
                      ui::Transform::orientation_flags rotation = ui::Transform::ROT_0)
          : DisplayRenderArea(device, device->getBounds(), device->getWidth(), device->getHeight(),
                              rotation) {}
    DisplayRenderArea(const sp<const DisplayDevice> device, Rect sourceCrop, uint32_t reqWidth,
                      uint32_t reqHeight, ISurfaceComposer::Rotation rotation)
                      uint32_t reqHeight, ui::Transform::orientation_flags rotation)
          : RenderArea(reqWidth, reqHeight, CaptureFill::OPAQUE, rotation), mDevice(device),
                              mSourceCrop(sourceCrop) {}

+0 −21
Original line number Diff line number Diff line
@@ -4,27 +4,6 @@

namespace android {

ui::Transform::orientation_flags fromRotation(ISurfaceComposer::Rotation rotation) {
    switch (rotation) {
        case ISurfaceComposer::eRotateNone:
            return ui::Transform::ROT_0;
        case ISurfaceComposer::eRotate90:
            return ui::Transform::ROT_90;
        case ISurfaceComposer::eRotate180:
            return ui::Transform::ROT_180;
        case ISurfaceComposer::eRotate270:
            return ui::Transform::ROT_270;
    }
    ALOGE("Invalid rotation passed to captureScreen(): %d\n", rotation);
    return ui::Transform::ROT_0;
}

RenderArea::RenderArea(uint32_t reqWidth, uint32_t reqHeight, CaptureFill captureFill,
                       ISurfaceComposer::Rotation rotation)
      : mReqWidth(reqWidth), mReqHeight(reqHeight), mCaptureFill(captureFill) {
    mRotationFlags = fromRotation(rotation);
}

float RenderArea::getCaptureFillValue(CaptureFill captureFill) {
    switch(captureFill) {
        case CaptureFill::CLEAR:
+7 −5
Original line number Diff line number Diff line
#pragma once

#include <gui/ISurfaceComposer.h>
#include <ui/GraphicTypes.h>
#include <ui/Transform.h>

#include <functional>
@@ -21,7 +19,11 @@ public:
    static float getCaptureFillValue(CaptureFill captureFill);

    RenderArea(uint32_t reqWidth, uint32_t reqHeight, CaptureFill captureFill,
               ISurfaceComposer::Rotation rotation = ISurfaceComposer::eRotateNone);
               ui::Transform::orientation_flags rotation = ui::Transform::ROT_0)
          : mReqWidth(reqWidth),
            mReqHeight(reqHeight),
            mCaptureFill(captureFill),
            mRotationFlags(rotation) {}

    virtual ~RenderArea() = default;

@@ -73,8 +75,8 @@ public:
private:
    uint32_t mReqWidth;
    uint32_t mReqHeight;
    ui::Transform::orientation_flags mRotationFlags;
    CaptureFill mCaptureFill;
    const CaptureFill mCaptureFill;
    const ui::Transform::orientation_flags mRotationFlags;
};

} // namespace android
+18 −1
Original line number Diff line number Diff line
@@ -143,6 +143,21 @@ bool isWideColorMode(const ColorMode colorMode) {
    return false;
}

ui::Transform::orientation_flags fromSurfaceComposerRotation(ISurfaceComposer::Rotation rotation) {
    switch (rotation) {
        case ISurfaceComposer::eRotateNone:
            return ui::Transform::ROT_0;
        case ISurfaceComposer::eRotate90:
            return ui::Transform::ROT_90;
        case ISurfaceComposer::eRotate180:
            return ui::Transform::ROT_180;
        case ISurfaceComposer::eRotate270:
            return ui::Transform::ROT_270;
    }
    ALOGE("Invalid rotation passed to captureScreen(): %d\n", rotation);
    return ui::Transform::ROT_0;
}

#pragma clang diagnostic pop

class ConditionalLock {
@@ -4902,6 +4917,8 @@ status_t SurfaceFlinger::captureScreen(const sp<IBinder>& displayToken,

    if (!displayToken) return BAD_VALUE;

    auto renderAreaRotation = fromSurfaceComposerRotation(rotation);

    const auto display = getDisplayDeviceLocked(displayToken);
    if (!display) return BAD_VALUE;

@@ -4915,7 +4932,7 @@ status_t SurfaceFlinger::captureScreen(const sp<IBinder>& displayToken,
        }
    }

    DisplayRenderArea renderArea(display, sourceCrop, reqWidth, reqHeight, rotation);
    DisplayRenderArea renderArea(display, sourceCrop, reqWidth, reqHeight, renderAreaRotation);

    auto traverseLayers = std::bind(std::mem_fn(&SurfaceFlinger::traverseLayersInDisplay), this,
                                    display, minLayerZ, maxLayerZ, std::placeholders::_1);