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

Commit 82144eb9 authored by Chia-I Wu's avatar Chia-I Wu Committed by Yiwei Zhang
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
Merged-In: I16e1392d5c92c2f423f98307e867918415404d26
parent 07f190f7
Loading
Loading
Loading
Loading
+2 −3
Original line number Original line Diff line number Diff line
@@ -25,7 +25,6 @@
#include <math/mat4.h>
#include <math/mat4.h>


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


+7 −8
Original line number Original line Diff line number Diff line
#pragma once
#pragma once


#include <ui/GraphicTypes.h>

#include "Transform.h"
#include "Transform.h"


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


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


    virtual ~RenderArea() = default;
    virtual ~RenderArea() = default;


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


} // namespace android
} // namespace android
+25 −1
Original line number Original line Diff line number Diff line
@@ -75,6 +75,7 @@
#include "LayerVector.h"
#include "LayerVector.h"
#include "MonitoredProducer.h"
#include "MonitoredProducer.h"
#include "SurfaceFlinger.h"
#include "SurfaceFlinger.h"
#include "Transform.h"
#include "clz.h"
#include "clz.h"


#include "DisplayHardware/ComposerHal.h"
#include "DisplayHardware/ComposerHal.h"
@@ -112,6 +113,27 @@ using ui::Hdr;
using ui::RenderIntent;
using ui::RenderIntent;


namespace {
namespace {

#pragma clang diagnostic push
#pragma clang diagnostic error "-Wswitch-enum"

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

#pragma clang diagnostic pop

class ConditionalLock {
class ConditionalLock {
public:
public:
    ConditionalLock(Mutex& mutex, bool lock) : mMutex(mutex), mLocked(lock) {
    ConditionalLock(Mutex& mutex, bool lock) : mMutex(mutex), mLocked(lock) {
@@ -4832,6 +4854,8 @@ status_t SurfaceFlinger::captureScreen(const sp<IBinder>& display, sp<GraphicBuf


    if (CC_UNLIKELY(display == 0)) return BAD_VALUE;
    if (CC_UNLIKELY(display == 0)) return BAD_VALUE;


    auto renderAreaRotation = fromSurfaceComposerRotation(rotation);

    const sp<const DisplayDevice> device(getDisplayDeviceLocked(display));
    const sp<const DisplayDevice> device(getDisplayDeviceLocked(display));
    if (CC_UNLIKELY(device == 0)) return BAD_VALUE;
    if (CC_UNLIKELY(device == 0)) return BAD_VALUE;


@@ -4845,7 +4869,7 @@ status_t SurfaceFlinger::captureScreen(const sp<IBinder>& display, sp<GraphicBuf
        }
        }
    }
    }


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


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