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

Commit 6ad317c0 authored by Marin Shalamanov's avatar Marin Shalamanov
Browse files

[SF, CE] Rename viewport, frame and destinationClip

This change introduces a new class ProjectionSpace and uses
it in OutputCompositionState to describe the layer stack space,
the physical display space and the oriented display space.
We rename viewport to layerStackSpaceRect, frame to
orientedDisplaySpaceRect and destinationClip displaySpaceRect.
This aims to provide better readibility of the code and
it's also consistent with SurfaceControl.setDisplayProjction
where layerStackRect and displayRect are used for viewport
and frame.

Bug: 161793589
Bug: 160404780
Test: m && flash device
Test: atest libsurfaceflinger_unittest libcompositionengine_test
Test: adb shell dumpsys SurfaceFlinger
Change-Id: Iee20b908157cbef4de4d9addf429f98356ec942d
parent 14195920
Loading
Loading
Loading
Loading
+16 −18
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ status_t layer_state_t::write(Parcel& output) const
    output.writeUint32(transform);
    output.writeBool(transformToDisplayInverse);
    output.write(crop);
    output.write(frame);
    output.write(orientedDisplaySpaceRect);
    if (buffer) {
        output.writeBool(true);
        output.write(*buffer);
@@ -159,7 +159,7 @@ status_t layer_state_t::read(const Parcel& input)
    transform = input.readUint32();
    transformToDisplayInverse = input.readBool();
    input.read(crop);
    input.read(frame);
    input.read(orientedDisplaySpaceRect);
    buffer = new GraphicBuffer();
    if (input.readBool()) {
        input.read(*buffer);
@@ -216,15 +216,13 @@ status_t ComposerState::read(const Parcel& input) {
    return state.read(input);
}


DisplayState::DisplayState() :
    what(0),
DisplayState::DisplayState()
      : what(0),
        layerStack(0),
    viewport(Rect::EMPTY_RECT),
    frame(Rect::EMPTY_RECT),
        layerStackSpaceRect(Rect::EMPTY_RECT),
        orientedDisplaySpaceRect(Rect::EMPTY_RECT),
        width(0),
    height(0) {
}
        height(0) {}

status_t DisplayState::write(Parcel& output) const {
    output.writeStrongBinder(token);
@@ -232,8 +230,8 @@ status_t DisplayState::write(Parcel& output) const {
    output.writeUint32(what);
    output.writeUint32(layerStack);
    output.writeUint32(toRotationInt(orientation));
    output.write(viewport);
    output.write(frame);
    output.write(layerStackSpaceRect);
    output.write(orientedDisplaySpaceRect);
    output.writeUint32(width);
    output.writeUint32(height);
    return NO_ERROR;
@@ -245,8 +243,8 @@ status_t DisplayState::read(const Parcel& input) {
    what = input.readUint32();
    layerStack = input.readUint32();
    orientation = ui::toRotation(input.readUint32());
    input.read(viewport);
    input.read(frame);
    input.read(layerStackSpaceRect);
    input.read(orientedDisplaySpaceRect);
    width = input.readUint32();
    height = input.readUint32();
    return NO_ERROR;
@@ -264,8 +262,8 @@ void DisplayState::merge(const DisplayState& other) {
    if (other.what & eDisplayProjectionChanged) {
        what |= eDisplayProjectionChanged;
        orientation = other.orientation;
        viewport = other.viewport;
        frame = other.frame;
        layerStackSpaceRect = other.layerStackSpaceRect;
        orientedDisplaySpaceRect = other.orientedDisplaySpaceRect;
    }
    if (other.what & eDisplaySizeChanged) {
        what |= eDisplaySizeChanged;
@@ -368,7 +366,7 @@ void layer_state_t::merge(const layer_state_t& other) {
    }
    if (other.what & eFrameChanged) {
        what |= eFrameChanged;
        frame = other.frame;
        orientedDisplaySpaceRect = other.orientedDisplaySpaceRect;
    }
    if (other.what & eBufferChanged) {
        what |= eBufferChanged;
+3 −3
Original line number Diff line number Diff line
@@ -1137,7 +1137,7 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setFrame
        return *this;
    }
    s->what |= layer_state_t::eFrameChanged;
    s->frame = frame;
    s->orientedDisplaySpaceRect = frame;

    registerSurfaceControlForCallback(sc);
    return *this;
@@ -1545,8 +1545,8 @@ void SurfaceComposerClient::Transaction::setDisplayProjection(const sp<IBinder>&
                                                              const Rect& displayRect) {
    DisplayState& s(getDisplayState(token));
    s.orientation = orientation;
    s.viewport = layerStackRect;
    s.frame = displayRect;
    s.layerStackSpaceRect = layerStackRect;
    s.orientedDisplaySpaceRect = displayRect;
    s.what |= DisplayState::eDisplayProjectionChanged;
    mForceSynchronous = true; // TODO: do we actually still need this?
}
+12 −12
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ struct layer_state_t {
            transform(0),
            transformToDisplayInverse(false),
            crop(Rect::INVALID_RECT),
            frame(Rect::INVALID_RECT),
            orientedDisplaySpaceRect(Rect::INVALID_RECT),
            dataspace(ui::Dataspace::UNKNOWN),
            surfaceDamageRegion(),
            api(-1),
@@ -192,7 +192,7 @@ struct layer_state_t {
    uint32_t transform;
    bool transformToDisplayInverse;
    Rect crop;
    Rect frame;
    Rect orientedDisplaySpaceRect;
    sp<GraphicBuffer> buffer;
    sp<Fence> acquireFence;
    ui::Dataspace dataspace;
@@ -265,18 +265,18 @@ struct DisplayState {

    // These states define how layers are projected onto the physical display.
    //
    // Layers are first clipped to `viewport'.  They are then translated and
    // scaled from `viewport' to `frame'.  Finally, they are rotated according
    // to `orientation', `width', and `height'.
    // Layers are first clipped to `layerStackSpaceRect'.  They are then translated and
    // scaled from `layerStackSpaceRect' to `orientedDisplaySpaceRect'.  Finally, they are rotated
    // according to `orientation', `width', and `height'.
    //
    // For example, assume viewport is Rect(0, 0, 200, 100), frame is Rect(20,
    // 10, 420, 210), and the size of the display is WxH.  When orientation is
    // 0, layers will be scaled by a factor of 2 and translated by (20, 10).
    // When orientation is 1, layers will be additionally rotated by 90
    // degrees around the origin clockwise and translated by (W, 0).
    // For example, assume layerStackSpaceRect is Rect(0, 0, 200, 100), orientedDisplaySpaceRect is
    // Rect(20, 10, 420, 210), and the size of the display is WxH.  When orientation is 0, layers
    // will be scaled by a factor of 2 and translated by (20, 10). When orientation is 1, layers
    // will be additionally rotated by 90 degrees around the origin clockwise and translated by (W,
    // 0).
    ui::Rotation orientation = ui::ROTATION_0;
    Rect viewport;
    Rect frame;
    Rect layerStackSpaceRect;
    Rect orientedDisplaySpaceRect;

    uint32_t width, height;

+0 −4
Original line number Diff line number Diff line
@@ -321,10 +321,6 @@ std::string decodeRenderIntent(RenderIntent renderIntent) {
    return std::string("Unknown RenderIntent");
}

std::string to_string(const android::Rect& rect) {
    return StringPrintf("(%4d,%4d,%4d,%4d)", rect.left, rect.top, rect.right, rect.bottom);
}

std::string toString(const android::DeviceProductInfo::ManufactureOrModelDate& date) {
    using ModelYear = android::DeviceProductInfo::ModelYear;
    using ManufactureYear = android::DeviceProductInfo::ManufactureYear;
+10 −0
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
 * limitations under the License.
 */

#include <android-base/stringprintf.h>
#include <system/graphics.h>
#include <ui/Rect.h>

@@ -149,4 +150,13 @@ Rect Rect::reduce(const Rect& exclude) const {
    return result;
}

std::string to_string(const android::Rect& rect) {
    return android::base::StringPrintf("Rect(%d, %d, %d, %d)", rect.left, rect.top, rect.right,
                                       rect.bottom);
}

void PrintTo(const Rect& rect, ::std::ostream* os) {
    *os << to_string(rect);
}

}; // namespace android
Loading