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

Commit 8f090650 authored by Ricardo Cerqueira's avatar Ricardo Cerqueira
Browse files

surfaceflinger: Consolidate display orientation compensation hooks

Dedupe rotation calculation code and make rotation a statically
available property in the DisplayDevice
Change-Id: Ic517ab0d2c05026cd6fa46d664aab7926be17b62
parent 3e92eef1
Loading
Loading
Loading
Loading
+12 −8
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ DisplayDevice::DisplayDevice(
      mSecureLayerVisible(false),
      mScreenAcquired(false),
      mLayerStack(NO_LAYER_STACK),
      mHardwareOrientation(0),
      mOrientation()
{
    mNativeWindow = new Surface(producer, false);
@@ -114,7 +115,12 @@ DisplayDevice::DisplayDevice(
    // was created with createDisplay().
    switch (mType) {
        case DISPLAY_PRIMARY:
            char value[PROPERTY_VALUE_MAX];
            mDisplayName = "Built-in Screen";

            /* hwrotation applies only to the primary display */
            property_get("ro.sf.hwrotation", value, "0");
            mHardwareOrientation = atoi(value);
            break;
        case DISPLAY_EXTERNAL:
            mDisplayName = "HDMI Screen";
@@ -367,9 +373,7 @@ status_t DisplayDevice::orientationToTransfrom(
        int orientation, int w, int h, Transform* tr)
{
    uint32_t flags = 0;
    char value[PROPERTY_VALUE_MAX];
    property_get("ro.sf.hwrotation", value, "0");
    int additionalRot = atoi(value);
    int additionalRot = this->getHardwareOrientation();

    if (additionalRot) {
        additionalRot /= 90;
@@ -416,11 +420,7 @@ void DisplayDevice::setProjection(int orientation,
    if (!frame.isValid()) {
        // the destination frame can be invalid if it has never been set,
        // in that case we assume the whole display frame.
        char value[PROPERTY_VALUE_MAX];
        property_get("ro.sf.hwrotation", value, "0");
        int additionalRot = atoi(value);

        if (additionalRot == 90 || additionalRot == 270) {
        if ((mHardwareOrientation/90) & DisplayState::eOrientationSwapMask) {
            frame = Rect(h, w);
        } else {
            frame = Rect(w, h);
@@ -479,6 +479,10 @@ void DisplayDevice::setProjection(int orientation,
    mFrame = frame;
}

int DisplayDevice::getHardwareOrientation() {
    return mHardwareOrientation;
}

void DisplayDevice::dump(String8& result) const {
    const Transform& tr(mGlobalTransform);
    result.appendFormat(
+3 −1
Original line number Diff line number Diff line
@@ -159,6 +159,7 @@ public:
     */
    uint32_t getPageFlipCount() const;
    void dump(String8& result) const;
    int getHardwareOrientation();

private:
    /*
@@ -201,10 +202,11 @@ private:
    /*
     * Transaction state
     */
    static status_t orientationToTransfrom(int orientation,
    status_t orientationToTransfrom(int orientation,
            int w, int h, Transform* tr);

    uint32_t mLayerStack;
    int mHardwareOrientation;
    int mOrientation;
    // user-provided visible area of the layer stack
    Rect mViewport;
+1 −3
Original line number Diff line number Diff line
@@ -739,9 +739,7 @@ status_t SurfaceFlinger::getDisplayInfo(const sp<IBinder>& display, DisplayInfo*
        info->orientation = 0;
    }

    char value[PROPERTY_VALUE_MAX];
    property_get("ro.sf.hwrotation", value, "0");
    int additionalRot = atoi(value) / 90;
    int additionalRot = mDisplays[0]->getHardwareOrientation() / 90;
    if ((type == DisplayDevice::DISPLAY_PRIMARY) && (additionalRot & DisplayState::eOrientationSwapMask)) {
        info->h = hwc.getWidth(type);
        info->w = hwc.getHeight(type);