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

Commit 95582564 authored by Chia-I Wu's avatar Chia-I Wu Committed by Android (Google) Code Review
Browse files

Merge changes from topic "renderarea-2"

* changes:
  surfaceflinger: improve RenderArea needsFiltering
  surfaceflinger: respect install orientation in DisplayRenderArea
  surfaceflinger: add install orientation to DisplayDevice
  surfaceflinger: make mPrimaryDisplayOrientation static
  surfaceflinger: clean up captureScreen
  surfaceflinger: silence some RenderArea errors
parents 9ab9711e 5f6664c1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -180,7 +180,7 @@ void BufferLayer::onDraw(const RenderArea& renderArea, const Region& clip,

    if (!blackOutLayer) {
        // TODO: we could be more subtle with isFixedSize()
        const bool useFiltering = getFiltering() || needsFiltering(renderArea) || isFixedSize();
        const bool useFiltering = needsFiltering(renderArea) || isFixedSize();

        // Query the texture matrix given our current filtering mode.
        float textureMatrix[16];
+3 −2
Original line number Diff line number Diff line
@@ -218,6 +218,7 @@ DisplayDevice::DisplayDevice(
        std::unique_ptr<renderengine::Surface> renderSurface,
        int displayWidth,
        int displayHeight,
        int displayInstallOrientation,
        bool hasWideColorGamut,
        const HdrCapabilities& hdrCapabilities,
        const int32_t supportedPerFrameMetadata,
@@ -233,6 +234,7 @@ DisplayDevice::DisplayDevice(
      mSurface{std::move(renderSurface)},
      mDisplayWidth(displayWidth),
      mDisplayHeight(displayHeight),
      mDisplayInstallOrientation(displayInstallOrientation),
      mPageFlipCount(0),
      mIsSecure(isSecure),
      mLayerStack(NO_LAYER_STACK),
@@ -604,9 +606,8 @@ void DisplayDevice::setProjection(int orientation,
    // need to take care of primary display rotation for mGlobalTransform
    // for case if the panel is not installed aligned with device orientation
    if (mType == DisplayType::DISPLAY_PRIMARY) {
        int primaryDisplayOrientation = mFlinger->getPrimaryDisplayOrientation();
        DisplayDevice::orientationToTransfrom(
                (orientation + primaryDisplayOrientation) % (DisplayState::eOrientation270 + 1),
                (orientation + mDisplayInstallOrientation) % (DisplayState::eOrientation270 + 1),
                w, h, &R);
    }

+81 −4
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include <unordered_map>

#include <binder/IBinder.h>
#include <gui/LayerState.h>
#include <hardware/hwcomposer_defs.h>
#include <math/mat4.h>
#include <renderengine/Surface.h>
@@ -87,6 +88,7 @@ public:
            std::unique_ptr<renderengine::Surface> renderSurface,
            int displayWidth,
            int displayHeight,
            int displayInstallOrientation,
            bool hasWideColorGamut,
            const HdrCapabilities& hdrCapabilities,
            const int32_t supportedPerFrameMetadata,
@@ -110,6 +112,7 @@ public:

    int         getWidth() const;
    int         getHeight() const;
    int         getInstallOrientation() const { return mDisplayInstallOrientation; }

    void                    setVisibleLayersSortedByZ(const Vector< sp<Layer> >& layers);
    const Vector< sp<Layer> >& getVisibleLayersSortedByZ() const;
@@ -234,6 +237,7 @@ private:
    std::unique_ptr<renderengine::Surface> mSurface;
    int             mDisplayWidth;
    int             mDisplayHeight;
    const int       mDisplayInstallOrientation;
    mutable uint32_t mPageFlipCount;
    std::string     mDisplayName;
    bool            mIsSecure;
@@ -339,7 +343,9 @@ public:
                              rotation) {}
    DisplayRenderArea(const sp<const DisplayDevice> device, Rect sourceCrop, uint32_t reqWidth,
                      uint32_t reqHeight, ui::Transform::orientation_flags rotation)
          : RenderArea(reqWidth, reqHeight, CaptureFill::OPAQUE, rotation), mDevice(device),
          : RenderArea(reqWidth, reqHeight, CaptureFill::OPAQUE,
                       getDisplayRotation(rotation, device->getInstallOrientation())),
            mDevice(device),
            mSourceCrop(sourceCrop) {}

    const ui::Transform& getTransform() const override { return mDevice->getTransform(); }
@@ -347,10 +353,81 @@ public:
    int getHeight() const override { return mDevice->getHeight(); }
    int getWidth() const override { return mDevice->getWidth(); }
    bool isSecure() const override { return mDevice->isSecure(); }
    bool needsFiltering() const override { return mDevice->needsFiltering(); }
    Rect getSourceCrop() const override { return mSourceCrop; }

    bool needsFiltering() const override {
        if (mDevice->needsFiltering()) {
            return true;
        }

        const Rect sourceCrop = getSourceCrop();
        int width = sourceCrop.width();
        int height = sourceCrop.height();
        if (getRotationFlags() & ui::Transform::ROT_90) {
            std::swap(width, height);
        }
        return width != getReqWidth() || height != getReqHeight();
    }

    Rect getSourceCrop() const override {
        const int orientation = mDevice->getInstallOrientation();
        if (orientation == DisplayState::eOrientationDefault) {
            return mSourceCrop;
        }

        uint32_t flags = 0x00;
        switch (orientation) {
            case DisplayState::eOrientation90:
                flags = ui::Transform::ROT_90;
                break;
            case DisplayState::eOrientation180:
                flags = ui::Transform::ROT_180;
                break;
            case DisplayState::eOrientation270:
                flags = ui::Transform::ROT_270;
                break;
        }
        ui::Transform tr;
        tr.set(flags, getWidth(), getHeight());
        return tr.transform(mSourceCrop);
    }

private:
    static ui::Transform::orientation_flags getDisplayRotation(
            ui::Transform::orientation_flags rotation, int orientation) {
        if (orientation == DisplayState::eOrientationDefault) {
            return rotation;
        }

        // convert hw orientation into flag presentation
        // here inverse transform needed
        uint8_t hw_rot_90 = 0x00;
        uint8_t hw_flip_hv = 0x00;
        switch (orientation) {
            case DisplayState::eOrientation90:
                hw_rot_90 = ui::Transform::ROT_90;
                hw_flip_hv = ui::Transform::ROT_180;
                break;
            case DisplayState::eOrientation180:
                hw_flip_hv = ui::Transform::ROT_180;
                break;
            case DisplayState::eOrientation270:
                hw_rot_90 = ui::Transform::ROT_90;
                break;
        }

        // transform flags operation
        // 1) flip H V if both have ROT_90 flag
        // 2) XOR these flags
        uint8_t rotation_rot_90 = rotation & ui::Transform::ROT_90;
        uint8_t rotation_flip_hv = rotation & ui::Transform::ROT_180;
        if (rotation_rot_90 & hw_rot_90) {
            rotation_flip_hv = (~rotation_flip_hv) & ui::Transform::ROT_180;
        }

        return static_cast<ui::Transform::orientation_flags>(
                (rotation_rot_90 ^ hw_rot_90) | (rotation_flip_hv ^ hw_flip_hv));
    }

    const sp<const DisplayDevice> mDevice;
    const Rect mSourceCrop;
};
+0 −9
Original line number Diff line number Diff line
@@ -78,7 +78,6 @@ Layer::Layer(SurfaceFlinger* flinger, const sp<Client>& client, const String8& n
        mOverrideScalingMode(-1),
        mCurrentFrameNumber(0),
        mFrameLatencyNeeded(false),
        mFiltering(false),
        mNeedsFiltering(false),
        mProtectedByApp(false),
        mClientRef(client),
@@ -768,14 +767,6 @@ bool Layer::addSyncPoint(const std::shared_ptr<SyncPoint>& point) {
    return true;
}

void Layer::setFiltering(bool filtering) {
    mFiltering = filtering;
}

bool Layer::getFiltering() const {
    return mFiltering;
}

// ----------------------------------------------------------------------------
// local state
// ----------------------------------------------------------------------------
+0 −5
Original line number Diff line number Diff line
@@ -513,9 +513,6 @@ public:
    // -----------------------------------------------------------------------

    void clearWithOpenGL(const RenderArea& renderArea) const;
    void setFiltering(bool filtering);
    bool getFiltering() const;


    inline const State& getDrawingState() const { return mDrawingState; }
    inline const State& getCurrentState() const { return mCurrentState; }
@@ -732,8 +729,6 @@ protected:
    int32_t mOverrideScalingMode;
    std::atomic<uint64_t> mCurrentFrameNumber;
    bool mFrameLatencyNeeded;
    // Whether filtering is forced on or not
    bool mFiltering;
    // Whether filtering is needed b/c of the drawingstate
    bool mNeedsFiltering;

Loading