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

Commit 08626ec0 authored by Irvel Nduva Matias Vega's avatar Irvel Nduva Matias Vega Committed by Android (Google) Code Review
Browse files

Merge changes from topic 'Add display tracing to SurfaceInterceptor'

* changes:
  Add display tracing to SurfaceInterceptor
  Add display tracing to the surfacecapturereplay proto
parents d9f628e4 ffc9efc4
Loading
Loading
Loading
Loading
+84 −42
Original line number Diff line number Diff line
@@ -9,24 +9,28 @@ message Increment {

    oneof increment {
        Transaction        transaction          = 2;
        Create       create         = 3;
        Delete       delete         = 4;
        SurfaceCreation    surface_creation     = 3;
        SurfaceDeletion    surface_deletion     = 4;
        BufferUpdate       buffer_update        = 5;
        VSyncEvent         vsync_event          = 6;
        DisplayCreation    display_creation     = 7;
        DisplayDeletion    display_deletion     = 8;
        PowerModeUpdate    power_mode_update    = 9;
    }
}

message Transaction {
    repeated Change change      = 1;
    repeated SurfaceChange surface_change = 1;
    repeated DisplayChange display_change = 2;

    required bool   synchronous = 2;
    required bool   animation   = 3;
    required bool synchronous = 3;
    required bool animation   = 4;
}

message Change {
    required uint32 id = 1;
message SurfaceChange {
    required int32 id = 1;

    oneof Change {
    oneof SurfaceChange {
        PositionChange              position                = 2;
        SizeChange                  size                    = 3;
        AlphaChange                 alpha                   = 4;
@@ -102,10 +106,32 @@ message SecureFlagChange {
}

message DeferredTransactionChange {
    required uint32 layer_id     = 1;
    required int32  layer_id     = 1;
    required uint64 frame_number = 2;
}

message DisplayChange {
    required int32 id = 1;

    oneof DisplayChange {
        DispSurfaceChange surface     = 2;
        LayerStackChange  layer_stack = 3;
        SizeChange        size        = 4;
        ProjectionChange  projection  = 5;
    }
}

message DispSurfaceChange {
    required uint64 buffer_queue_id   = 1;
    required string buffer_queue_name = 2;
}

message ProjectionChange {
    required int32     orientation = 1;
    required Rectangle viewport    = 2;
    required Rectangle frame       = 3;
}

message Rectangle {
    required int32 left   = 1;
    required int32 top    = 2;
@@ -113,19 +139,19 @@ message Rectangle {
    required int32 bottom = 4;
}

message Create {
    required uint32 id    = 1;
message SurfaceCreation {
    required int32  id   = 1;
    required string name = 2;
    required uint32 w    = 3;
    required uint32 h    = 4;
}

message Delete {
    required uint32 id = 1;
message SurfaceDeletion {
    required int32 id = 1;
}

message BufferUpdate {
    required uint32 id            = 1;
    required int32  id           = 1;
    required uint32 w            = 2;
    required uint32 h            = 3;
    required uint64 frame_number = 4;
@@ -134,3 +160,19 @@ message BufferUpdate {
message VSyncEvent {
    required int64 when = 1;
}

message DisplayCreation {
    required int32     id                = 1;
    required string    name              = 2;
    required int32     type              = 3;
    required bool      is_secure         = 4;
}

message DisplayDeletion {
    required int32 id = 1;
}

message PowerModeUpdate {
    required int32  id   = 1;
    required int32  mode = 2;
}
+14 −0
Original line number Diff line number Diff line
@@ -613,3 +613,17 @@ void DisplayDevice::dump(String8& result) const {
    mDisplaySurface->dumpAsString(surfaceDump);
    result.append(surfaceDump);
}

std::atomic<int32_t> DisplayDeviceState::nextDisplayId(1);

DisplayDeviceState::DisplayDeviceState(DisplayDevice::DisplayType type, bool isSecure)
    : type(type),
      layerStack(DisplayDevice::NO_LAYER_STACK),
      orientation(0),
      width(0),
      height(0),
      isSecure(isSecure)
{
    viewport.makeInvalid();
    frame.makeInvalid();
}
+22 −0
Original line number Diff line number Diff line
@@ -263,6 +263,28 @@ private:
#endif
};

struct DisplayDeviceState {
    DisplayDeviceState() = default;
    DisplayDeviceState(DisplayDevice::DisplayType type, bool isSecure);

    bool isValid() const { return type >= 0; }
    bool isMainDisplay() const { return type == DisplayDevice::DISPLAY_PRIMARY; }
    bool isVirtualDisplay() const { return type >= DisplayDevice::DISPLAY_VIRTUAL; }

    static std::atomic<int32_t> nextDisplayId;
    int32_t displayId = nextDisplayId++;
    DisplayDevice::DisplayType type = DisplayDevice::DISPLAY_ID_INVALID;
    sp<IGraphicBufferProducer> surface;
    uint32_t layerStack = DisplayDevice::NO_LAYER_STACK;
    Rect viewport;
    Rect frame;
    uint8_t orientation = 0;
    uint32_t width = 0;
    uint32_t height = 0;
    String8 displayName;
    bool isSecure = false;
};

}; // namespace android

#endif // ANDROID_DISPLAY_DEVICE_H
+19 −31
Original line number Diff line number Diff line
@@ -261,7 +261,7 @@ sp<IBinder> SurfaceFlinger::createDisplay(const String8& displayName,
    DisplayDeviceState info(DisplayDevice::DISPLAY_VIRTUAL, secure);
    info.displayName = displayName;
    mCurrentState.displays.add(token, info);

    mInterceptor.saveDisplayCreation(info);
    return token;
}

@@ -279,7 +279,7 @@ void SurfaceFlinger::destroyDisplay(const sp<IBinder>& display) {
        ALOGE("destroyDisplay called for non-virtual display");
        return;
    }

    mInterceptor.saveDisplayDeletion(info.displayId);
    mCurrentState.displays.removeItemsAt(idx);
    setTransactionFlags(eDisplayTransactionNeeded);
}
@@ -292,6 +292,7 @@ void SurfaceFlinger::createBuiltinDisplayLocked(DisplayDevice::DisplayType type)
    // All non-virtual displays are currently considered secure.
    DisplayDeviceState info(type, true);
    mCurrentState.displays.add(mBuiltinDisplays[type], info);
    mInterceptor.saveDisplayCreation(info);
}

sp<IBinder> SurfaceFlinger::getBuiltInDisplay(int32_t id) {
@@ -2371,7 +2372,9 @@ void SurfaceFlinger::setTransactionState(
    }

    if (transactionFlags) {
        mInterceptor.saveLayerUpdates(state, flags);
        if (mInterceptor.isEnabled()) {
            mInterceptor.saveTransaction(state, mCurrentState.displays, displays, flags);
        }

        // this triggers the transaction
        setTransactionFlags(transactionFlags);
@@ -2567,7 +2570,7 @@ status_t SurfaceFlinger::createLayer(
    if (result != NO_ERROR) {
        return result;
    }
    mInterceptor.saveLayerCreate(layer);
    mInterceptor.saveSurfaceCreation(layer);

    setTransactionFlags(eTransactionNeeded);
    return result;
@@ -2615,7 +2618,7 @@ status_t SurfaceFlinger::onLayerRemoved(const sp<Client>& client, const sp<IBind
    status_t err = NO_ERROR;
    sp<Layer> l(client->getLayerUser(handle));
    if (l != NULL) {
        mInterceptor.saveLayerDelete(l);
        mInterceptor.saveSurfaceDeletion(l);
        err = removeLayer(l);
        ALOGE_IF(err<0 && err != NAME_NOT_FOUND,
                "error removing layer=%p (%s)", l.get(), strerror(-err));
@@ -2694,6 +2697,16 @@ void SurfaceFlinger::setPowerModeInternal(const sp<DisplayDevice>& hw,
        return;
    }

    if (mInterceptor.isEnabled()) {
        Mutex::Autolock _l(mStateLock);
        ssize_t idx = mCurrentState.displays.indexOfKey(hw->getDisplayToken());
        if (idx < 0) {
            ALOGW("Surface Interceptor SavePowerMode: invalid display token");
            return;
        }
        mInterceptor.savePowerModeUpdate(mCurrentState.displays.valueAt(idx).displayId, mode);
    }

    if (currentMode == HWC_POWER_MODE_OFF) {
        // Turn on the display
        getHwComposer().setPowerMode(type, mode);
@@ -3363,7 +3376,7 @@ status_t SurfaceFlinger::onTransact(
                n = data.readInt32();
                if (n) {
                    ALOGV("Interceptor enabled");
                    mInterceptor.enable(mDrawingState.layersSortedByZ);
                    mInterceptor.enable(mDrawingState.layersSortedByZ, mDrawingState.displays);
                }
                else{
                    ALOGV("Interceptor disabled");
@@ -3896,31 +3909,6 @@ int SurfaceFlinger::LayerVector::do_compare(const void* lhs,
    return l->sequence - r->sequence;
}

// ---------------------------------------------------------------------------

SurfaceFlinger::DisplayDeviceState::DisplayDeviceState()
    : type(DisplayDevice::DISPLAY_ID_INVALID),
      layerStack(DisplayDevice::NO_LAYER_STACK),
      orientation(0),
      width(0),
      height(0),
      isSecure(false) {
}

SurfaceFlinger::DisplayDeviceState::DisplayDeviceState(
    DisplayDevice::DisplayType type, bool isSecure)
    : type(type),
      layerStack(DisplayDevice::NO_LAYER_STACK),
      orientation(0),
      width(0),
      height(0),
      isSecure(isSecure) {
    viewport.makeInvalid();
    frame.makeInvalid();
}

// ---------------------------------------------------------------------------

}; // namespace android


+0 −17
Original line number Diff line number Diff line
@@ -175,23 +175,6 @@ private:
        virtual int do_compare(const void* lhs, const void* rhs) const;
    };

    struct DisplayDeviceState {
        DisplayDeviceState();
        DisplayDeviceState(DisplayDevice::DisplayType type, bool isSecure);
        bool isValid() const { return type >= 0; }
        bool isMainDisplay() const { return type == DisplayDevice::DISPLAY_PRIMARY; }
        bool isVirtualDisplay() const { return type >= DisplayDevice::DISPLAY_VIRTUAL; }
        DisplayDevice::DisplayType type;
        sp<IGraphicBufferProducer> surface;
        uint32_t layerStack;
        Rect viewport;
        Rect frame;
        uint8_t orientation;
        uint32_t width, height;
        String8 displayName;
        bool isSecure;
    };

    struct State {
        LayerVector layersSortedByZ;
        DefaultKeyedVector< wp<IBinder>, DisplayDeviceState> displays;
Loading