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

Commit 34590013 authored by Pablo Ceballos's avatar Pablo Ceballos Committed by Android (Google) Code Review
Browse files

Merge "BQ: Conditionally compile validateConsistencyLocked"

parents 858a4332 9e314337
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -126,9 +126,11 @@ private:
    // waitWhileAllocatingLocked blocks until mIsAllocating is false.
    void waitWhileAllocatingLocked() const;

#if DEBUG_ONLY_CODE
    // validateConsistencyLocked ensures that the free lists are in sync with
    // the information stored in mSlots
    void validateConsistencyLocked() const;
#endif

    // mAllocator is the connection to SurfaceFlinger that is used to allocate
    // new GraphicBuffer objects.
+2 −0
Original line number Diff line number Diff line
@@ -36,6 +36,8 @@ LOCAL_CPPFLAGS += -Wno-gnu-zero-variadic-macro-arguments
# Don't warn about struct padding
LOCAL_CPPFLAGS += -Wno-padded

LOCAL_CPPFLAGS += -DDEBUG_ONLY_CODE=$(if $(filter userdebug eng,$(TARGET_BUILD_VARIANT)),1,0)

LOCAL_SRC_FILES := \
	IGraphicBufferConsumer.cpp \
	IConsumerListener.cpp \
+11 −5
Original line number Diff line number Diff line
@@ -20,6 +20,12 @@
#define ATRACE_TAG ATRACE_TAG_GRAPHICS
//#define LOG_NDEBUG 0

#if DEBUG_ONLY_CODE
#define VALIDATE_CONSISTENCY() do { mCore->validateConsistencyLocked(); } while (0)
#else
#define VALIDATE_CONSISTENCY()
#endif

#include <gui/BufferItem.h>
#include <gui/BufferQueueConsumer.h>
#include <gui/BufferQueueCore.h>
@@ -252,7 +258,7 @@ status_t BufferQueueConsumer::acquireBuffer(BufferItem* outBuffer,

        ATRACE_INT(mCore->mConsumerName.string(), mCore->mQueue.size());

        mCore->validateConsistencyLocked();
        VALIDATE_CONSISTENCY();
    }

    if (listener != NULL) {
@@ -296,7 +302,7 @@ status_t BufferQueueConsumer::detachBuffer(int slot) {
    mCore->mFreeSlots.insert(slot);
    mCore->clearBufferSlotLocked(slot);
    mCore->mDequeueCondition.broadcast();
    mCore->validateConsistencyLocked();
    VALIDATE_CONSISTENCY();

    return NO_ERROR;
}
@@ -386,7 +392,7 @@ status_t BufferQueueConsumer::attachBuffer(int* outSlot,
    // for attached buffers.
    mSlots[*outSlot].mAcquireCalled = false;

    mCore->validateConsistencyLocked();
    VALIDATE_CONSISTENCY();

    return NO_ERROR;
}
@@ -446,7 +452,7 @@ status_t BufferQueueConsumer::releaseBuffer(int slot, uint64_t frameNumber,
        BQ_LOGV("releaseBuffer: releasing slot %d", slot);

        mCore->mDequeueCondition.broadcast();
        mCore->validateConsistencyLocked();
        VALIDATE_CONSISTENCY();
    } // Autolock scope

    // Call back without lock held
@@ -633,7 +639,7 @@ status_t BufferQueueConsumer::setMaxAcquiredBufferCount(

    BQ_LOGV("setMaxAcquiredBufferCount: %d", maxAcquiredBuffers);
    mCore->mMaxAcquiredBufferCount = maxAcquiredBuffers;
    mCore->validateConsistencyLocked();
    VALIDATE_CONSISTENCY();
    return NO_ERROR;
}

+9 −1
Original line number Diff line number Diff line
@@ -20,6 +20,12 @@

#define EGL_EGLEXT_PROTOTYPES

#if DEBUG_ONLY_CODE
#define VALIDATE_CONSISTENCY() do { validateConsistencyLocked(); } while (0)
#else
#define VALIDATE_CONSISTENCY()
#endif

#include <inttypes.h>

#include <gui/BufferItem.h>
@@ -216,7 +222,7 @@ void BufferQueueCore::freeAllBuffersLocked() {
        b.mIsStale = true;
    }

    validateConsistencyLocked();
    VALIDATE_CONSISTENCY();
}

bool BufferQueueCore::adjustAvailableSlotsLocked(int delta) {
@@ -258,6 +264,7 @@ void BufferQueueCore::waitWhileAllocatingLocked() const {
    }
}

#if DEBUG_ONLY_CODE
void BufferQueueCore::validateConsistencyLocked() const {
    static const useconds_t PAUSE_TIME = 0;
    int allocatedSlots = 0;
@@ -382,5 +389,6 @@ void BufferQueueCore::validateConsistencyLocked() const {
                mUnusedSlots.size());
    }
}
#endif

} // namespace android
+18 −11
Original line number Diff line number Diff line
@@ -20,6 +20,12 @@
#define ATRACE_TAG ATRACE_TAG_GRAPHICS
//#define LOG_NDEBUG 0

#if DEBUG_ONLY_CODE
#define VALIDATE_CONSISTENCY() do { mCore->validateConsistencyLocked(); } while (0)
#else
#define VALIDATE_CONSISTENCY()
#endif

#define EGL_EGLEXT_PROTOTYPES

#include <gui/BufferItem.h>
@@ -140,7 +146,7 @@ status_t BufferQueueProducer::setMaxDequeuedBufferCount(
            return BAD_VALUE;
        }
        mCore->mMaxDequeuedBufferCount = maxDequeuedBuffers;
        mCore->validateConsistencyLocked();
        VALIDATE_CONSISTENCY();
        mCore->mDequeueCondition.broadcast();
        listener = mCore->mConsumerListener;
    } // Autolock scope
@@ -189,7 +195,7 @@ status_t BufferQueueProducer::setAsyncMode(bool async) {
            return BAD_VALUE;
        }
        mCore->mAsyncMode = async;
        mCore->validateConsistencyLocked();
        VALIDATE_CONSISTENCY();
        mCore->mDequeueCondition.broadcast();
        listener = mCore->mConsumerListener;
    } // Autolock scope
@@ -495,7 +501,7 @@ status_t BufferQueueProducer::dequeueBuffer(int *outSlot,
                return NO_INIT;
            }

            mCore->validateConsistencyLocked();
            VALIDATE_CONSISTENCY();
        } // Autolock scope
    }

@@ -566,7 +572,7 @@ status_t BufferQueueProducer::detachBuffer(int slot) {
    mCore->mFreeSlots.insert(slot);
    mCore->clearBufferSlotLocked(slot);
    mCore->mDequeueCondition.broadcast();
    mCore->validateConsistencyLocked();
    VALIDATE_CONSISTENCY();

    return NO_ERROR;
}
@@ -616,7 +622,7 @@ status_t BufferQueueProducer::detachNextBuffer(sp<GraphicBuffer>* outBuffer,
    *outBuffer = mSlots[found].mGraphicBuffer;
    *outFence = mSlots[found].mFence;
    mCore->clearBufferSlotLocked(found);
    mCore->validateConsistencyLocked();
    VALIDATE_CONSISTENCY();

    return NO_ERROR;
}
@@ -684,7 +690,7 @@ status_t BufferQueueProducer::attachBuffer(int* outSlot,
    mSlots[*outSlot].mRequestBufferCalled = true;
    mSlots[*outSlot].mAcquireCalled = false;
    mCore->mActiveBuffers.insert(found);
    mCore->validateConsistencyLocked();
    VALIDATE_CONSISTENCY();

    return returnFlags;
}
@@ -861,7 +867,7 @@ status_t BufferQueueProducer::queueBuffer(int slot,
        // Take a ticket for the callback functions
        callbackTicket = mNextCallbackTicket++;

        mCore->validateConsistencyLocked();
        VALIDATE_CONSISTENCY();
    } // Autolock scope

    // Don't send the GraphicBuffer through the callback, and don't send
@@ -948,7 +954,7 @@ status_t BufferQueueProducer::cancelBuffer(int slot, const sp<Fence>& fence) {

    mSlots[slot].mFence = fence;
    mCore->mDequeueCondition.broadcast();
    mCore->validateConsistencyLocked();
    VALIDATE_CONSISTENCY();

    return NO_ERROR;
}
@@ -1087,7 +1093,7 @@ status_t BufferQueueProducer::connect(const sp<IProducerListener>& listener,
    }

    mCore->mAllowAllocation = true;
    mCore->validateConsistencyLocked();
    VALIDATE_CONSISTENCY();
    return status;
}

@@ -1252,7 +1258,7 @@ void BufferQueueProducer::allocateBuffers(uint32_t width, uint32_t height,

            mCore->mIsAllocating = false;
            mCore->mIsAllocatingCondition.broadcast();
            mCore->validateConsistencyLocked();
            VALIDATE_CONSISTENCY();
        } // Autolock scope
    }
}
@@ -1316,7 +1322,8 @@ status_t BufferQueueProducer::setDequeueTimeout(nsecs_t timeout) {

    mDequeueTimeout = timeout;
    mCore->mDequeueBufferCannotBlock = false;
    mCore->validateConsistencyLocked();

    VALIDATE_CONSISTENCY();
    return NO_ERROR;
}