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

Commit 8caf2848 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6392464 from 748bae0b to rvc-release

Change-Id: Ie98be43d3b4a026e85827b693ed81564fb1ee3f0
parents 451e8cfa 748bae0b
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -82,12 +82,12 @@ bool ClientCounterCallback::registerService(const sp<IBinder>& service, const st
        return false;
    }

    if (!reRegister) {
        if (!manager->registerClientCallback(name, service, this).isOk()) {
            ALOGE("Failed to add client callback for service %s", name.c_str());
            return false;
        }

    if (!reRegister) {
        // Only add this when a service is added for the first time, as it is not removed
        mRegisteredServices[name] = {service, allowIsolated, dumpFlags};
    }
+29 −4
Original line number Diff line number Diff line
@@ -241,8 +241,31 @@ void TransactionCompletedListener::onTransactionCompleted(ListenerStats listener

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

void bufferCacheCallback(void* /*context*/, uint64_t graphicBufferId);

void removeDeadBufferCallback(void* /*context*/, uint64_t graphicBufferId);

/**
 * We use the BufferCache to reduce the overhead of exchanging GraphicBuffers with
 * the server. If we were to simply parcel the GraphicBuffer we would pay two overheads
 *     1. Cost of sending the FD
 *     2. Cost of importing the GraphicBuffer with the mapper in the receiving process.
 * To ease this cost we implement the following scheme of caching buffers to integers,
 * or said-otherwise, naming them with integers. This is the scheme known as slots in
 * the legacy BufferQueue system.
 *     1. When sending Buffers to SurfaceFlinger we look up the Buffer in the cache.
 *     2. If there is a cache-hit we remove the Buffer from the Transaction and instead
 *        send the cached integer.
 *     3. If there is a cache miss, we cache the new buffer and send the integer
 *        along with the Buffer, SurfaceFlinger on it's side creates a new cache
 *        entry, and we use the integer for further communication.
 * A few details about lifetime:
 *     1. The cache evicts by LRU. The server side cache is keyed by BufferCache::getToken
 *        which is per process Unique. The server side cache is larger than the client side
 *        cache so that the server will never evict entries before the client.
 *     2. When the client evicts an entry it notifies the server via an uncacheBuffer
 *        transaction.
 *     3. The client only references the Buffers by ID, and uses buffer->addDeathCallback
 *        to auto-evict destroyed buffers.
 */
class BufferCache : public Singleton<BufferCache> {
public:
    BufferCache() : token(new BBinder()) {}
@@ -270,7 +293,7 @@ public:
            evictLeastRecentlyUsedBuffer();
        }

        buffer->addDeathCallback(bufferCacheCallback, nullptr);
        buffer->addDeathCallback(removeDeadBufferCallback, nullptr);

        mBuffers[buffer->getId()] = getCounter();
        return buffer->getId();
@@ -318,7 +341,7 @@ private:

ANDROID_SINGLETON_STATIC_INSTANCE(BufferCache);

void bufferCacheCallback(void* /*context*/, uint64_t graphicBufferId) {
void removeDeadBufferCallback(void* /*context*/, uint64_t graphicBufferId) {
    // GraphicBuffer id's are used as the cache ids.
    BufferCache::getInstance().uncache(graphicBufferId);
}
@@ -576,9 +599,11 @@ void SurfaceComposerClient::Transaction::cacheBuffers() {
        uint64_t cacheId = 0;
        status_t ret = BufferCache::getInstance().getCacheId(s->buffer, &cacheId);
        if (ret == NO_ERROR) {
            // Cache-hit. Strip the buffer and send only the id.
            s->what &= ~static_cast<uint64_t>(layer_state_t::eBufferChanged);
            s->buffer = nullptr;
        } else {
            // Cache-miss. Include the buffer and send the new cacheId.
            cacheId = BufferCache::getInstance().cache(s->buffer);
        }
        s->what |= layer_state_t::eCachedBufferChanged;
+7 −0
Original line number Diff line number Diff line
@@ -294,6 +294,7 @@ void BufferLayer::preparePerFrameCompositionState() {
    auto* compositionState = editCompositionState();
    if (compositionState->sidebandStream.get()) {
        compositionState->compositionType = Hwc2::IComposerClient::Composition::SIDEBAND;
        return;
    } else {
        // Normal buffer layers
        compositionState->hdrMetadata = mBufferInfo.mHdrMetadata;
@@ -301,6 +302,12 @@ void BufferLayer::preparePerFrameCompositionState() {
                ? Hwc2::IComposerClient::Composition::CURSOR
                : Hwc2::IComposerClient::Composition::DEVICE;
    }

    compositionState->buffer = mBufferInfo.mBuffer;
    compositionState->bufferSlot = (mBufferInfo.mBufferSlot == BufferQueue::INVALID_BUFFER_SLOT)
            ? 0
            : mBufferInfo.mBufferSlot;
    compositionState->acquireFence = mBufferInfo.mFence;
}

bool BufferLayer::onPreComposition(nsecs_t refreshStartTime) {
+0 −15
Original line number Diff line number Diff line
@@ -365,21 +365,6 @@ status_t BufferQueueLayer::updateFrameNumber(nsecs_t latchTime) {
    return NO_ERROR;
}

void BufferQueueLayer::preparePerFrameCompositionState() {
    BufferLayer::preparePerFrameCompositionState();

    auto* compositionState = editCompositionState();
    if (compositionState->compositionType == Hwc2::IComposerClient::Composition::SIDEBAND) {
        return;
    }

    compositionState->buffer = mBufferInfo.mBuffer;
    compositionState->bufferSlot = (mBufferInfo.mBufferSlot == BufferQueue::INVALID_BUFFER_SLOT)
            ? 0
            : mBufferInfo.mBufferSlot;
    compositionState->acquireFence = mBufferInfo.mFence;
}

// -----------------------------------------------------------------------
// Interface implementation for BufferLayerConsumer::ContentsChangedListener
// -----------------------------------------------------------------------
+0 −1
Original line number Diff line number Diff line
@@ -82,7 +82,6 @@ private:
    status_t updateActiveBuffer() override;
    status_t updateFrameNumber(nsecs_t latchTime) override;

    void preparePerFrameCompositionState() override;
    sp<Layer> createClone() override;

    void onFrameAvailable(const BufferItem& item);
Loading