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

Commit 7adb0f8a authored by Jesse Hall's avatar Jesse Hall
Browse files

Minor cleanups/fixes before virtual display refactoring

None of these should change behavior, except for removing some
incorrect log messages when using a virtual display.

- HWComposer::getAndResetReleaseFenceFd() checks the HWC version, so
  no need to do that in the DisplayDevice::onSwapBuffersCompleted().
  However, it should check that mFramebufferSurface is not NULL like
  it is for virtual displays.
- Comment that FramebufferSurface::dump() overrides the non-virtual
  ConsumerBase::dump(), and fix it so the right thing happens
  regardless of the static type of the pointer/reference the callee
  has. FramebufferSurface::dump() could be removed right now, but I'd
  need to bring it back in a later change.
- Use the right enum for validating display type ids.
- Don't try to send hotplug events for virtual displays.
- Mark virtual displays as connected so HWComposer::prepare() doesn't
  think something is wrong when it gets a non-NULL layer list.
- Remove unused FramebufferSurface methods.

Bug: 8384764
Change-Id: Id28a2f9be86b45f4bb7915fdf7752157035f4294
parent e81421e1
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -69,10 +69,9 @@ public:
    // ConsumerBase is connected.
    sp<BufferQueue> getBufferQueue() const;

    // dump writes the current state to a string.  These methods should NOT be
    // overridden by child classes.  Instead they should override the
    // dumpLocked method, which is called by these methods after locking the
    // mutex.
    // dump writes the current state to a string. Child classes should add
    // their state to the dump by overriding the dumpLocked method, which is
    // called by these methods after locking the mutex.
    void dump(String8& result) const;
    void dump(String8& result, const char* prefix, char* buffer, size_t SIZE) const;

+1 −1
Original line number Diff line number Diff line
@@ -244,7 +244,7 @@ void DisplayDevice::swapBuffers(HWComposer& hwc) const {

void DisplayDevice::onSwapBuffersCompleted(HWComposer& hwc) const {
    if (hwc.initCheck() == NO_ERROR) {
        if (hwc.supportsFramebufferTarget()) {
        if (mFramebufferSurface != NULL) {
            int fd = hwc.getAndResetReleaseFenceFd(mType);
            mFramebufferSurface->setReleaseFenceFd(fd);
        }
+8 −7
Original line number Diff line number Diff line
@@ -134,7 +134,7 @@ status_t FramebufferSurface::setReleaseFenceFd(int fenceFd) {
    if (fenceFd >= 0) {
        sp<Fence> fence(new Fence(fenceFd));
        if (mCurrentBufferSlot != BufferQueue::INVALID_BUFFER_SLOT) {
            status_t err = addReleaseFence(mCurrentBufferSlot, fence);
            err = addReleaseFence(mCurrentBufferSlot, fence);
            ALOGE_IF(err, "setReleaseFenceFd: failed to add the fence: %s (%d)",
                    strerror(-err), err);
        }
@@ -142,21 +142,22 @@ status_t FramebufferSurface::setReleaseFenceFd(int fenceFd) {
    return err;
}

status_t FramebufferSurface::setUpdateRectangle(const Rect& r)
{
    return INVALID_OPERATION;
}

status_t FramebufferSurface::compositionComplete()
{
    return mHwc.fbCompositionComplete();
}

void FramebufferSurface::dump(String8& result) {
    mHwc.fbDump(result);
    ConsumerBase::dump(result);
}

void FramebufferSurface::dumpLocked(String8& result, const char* prefix,
            char* buffer, size_t SIZE) const
{
    mHwc.fbDump(result);
    ConsumerBase::dumpLocked(result, prefix, buffer, SIZE);
}

// ----------------------------------------------------------------------------
}; // namespace android
// ----------------------------------------------------------------------------
+6 −3
Original line number Diff line number Diff line
@@ -36,11 +36,11 @@ class FramebufferSurface : public ConsumerBase {
public:
    FramebufferSurface(HWComposer& hwc, int disp);

    bool isUpdateOnDemand() const { return false; }
    status_t setUpdateRectangle(const Rect& updateRect);
    status_t compositionComplete();

    virtual void dump(String8& result);
    // TODO(jessehall): This overrides the non-virtual ConsumerBase version.
    // Will rework slightly in a following change.
    void dump(String8& result);

    // setReleaseFenceFd stores a fence file descriptor that will signal when the
    // current buffer is no longer being read. This fence will be returned to
@@ -56,6 +56,9 @@ private:
    virtual void onFrameAvailable();
    virtual void freeBufferLocked(int slotIndex);

    virtual void dumpLocked(String8& result, const char* prefix,
            char* buffer, size_t SIZE) const;

    // nextBuffer waits for and then latches the next buffer from the
    // BufferQueue and releases the previously latched buffer to the
    // BufferQueue.  The new buffer is returned in the 'buffer' argument.
+2 −0
Original line number Diff line number Diff line
@@ -380,6 +380,7 @@ int32_t HWComposer::allocateDisplayId() {
    }
    int32_t id = mAllocatedDisplayIDs.firstUnmarkedBit();
    mAllocatedDisplayIDs.markBit(id);
    mDisplayData[id].connected = true;
    return id;
}

@@ -392,6 +393,7 @@ status_t HWComposer::freeDisplayId(int32_t id) {
        return BAD_INDEX;
    }
    mAllocatedDisplayIDs.clearBit(id);
    mDisplayData[id].connected = false;
    return NO_ERROR;
}

Loading