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

Commit 3d556521 authored by Robert Carr's avatar Robert Carr Committed by android-build-merger
Browse files

SurfaceFlinger: Expose construction of container layers.

am: d6f7035d

Change-Id: Icb370d034c03eacc8c06b0f6fbb00292b6f8508b
parents 984538bf d6f7035d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ public:

        eFXSurfaceNormal = 0x00000000,
        eFXSurfaceColor = 0x00020000,
        eFXSurfaceContainer = 0x00080000,
        eFXSurfaceMask = 0x000F0000,
    };

+1 −16
Original line number Diff line number Diff line
@@ -133,22 +133,7 @@ Layer::Layer(SurfaceFlinger* flinger, const sp<Client>& client, const String8& n
    CompositorTiming compositorTiming;
    flinger->getCompositorTiming(&compositorTiming);
    mFrameEventHistory.initializeCompositorTiming(compositorTiming);
}

void Layer::onFirstRef() NO_THREAD_SAFETY_ANALYSIS {
    if (!isCreatedFromMainThread()) {
        // Grab the SF state lock during this since it's the only way to safely access HWC
        mFlinger->mStateLock.lock();
    }

    const auto& hwc = mFlinger->getHwComposer();
    const auto& activeConfig = hwc.getActiveConfig(HWC_DISPLAY_PRIMARY);
    nsecs_t displayPeriod = activeConfig->getVsyncPeriod();
    mFrameTracker.setDisplayRefreshPeriod(displayPeriod);

    if (!isCreatedFromMainThread()) {
        mFlinger->mStateLock.unlock();
    }
    mFrameTracker.setDisplayRefreshPeriod(compositorTiming.interval);
}

Layer::~Layer() {
+0 −2
Original line number Diff line number Diff line
@@ -618,8 +618,6 @@ protected:
              : mFlinger(flinger), mLayer(layer) {}
    };

    virtual void onFirstRef();

    friend class impl::SurfaceInterceptor;

    void commitTransaction(const State& stateToCommit);
+15 −0
Original line number Diff line number Diff line
@@ -3645,6 +3645,11 @@ status_t SurfaceFlinger::createLayer(
                    uniqueName, w, h, flags,
                    handle, &layer);
            break;
        case ISurfaceComposerClient::eFXSurfaceContainer:
            result = createContainerLayer(client,
                    uniqueName, w, h, flags,
                    handle, &layer);
            break;
        default:
            result = BAD_VALUE;
            break;
@@ -3736,6 +3741,16 @@ status_t SurfaceFlinger::createColorLayer(const sp<Client>& client,
    return NO_ERROR;
}

status_t SurfaceFlinger::createContainerLayer(const sp<Client>& client,
        const String8& name, uint32_t w, uint32_t h, uint32_t flags,
        sp<IBinder>* handle, sp<Layer>* outLayer)
{
    *outLayer = new ContainerLayer(this, client, name, w, h, flags);
    *handle = (*outLayer)->getHandle();
    return NO_ERROR;
}


status_t SurfaceFlinger::onLayerRemoved(const sp<Client>& client, const sp<IBinder>& handle)
{
    // called by a client when it wants to remove a Layer
+4 −0
Original line number Diff line number Diff line
@@ -541,6 +541,10 @@ private:
            uint32_t w, uint32_t h, uint32_t flags, sp<IBinder>* outHandle,
            sp<Layer>* outLayer);

    status_t createContainerLayer(const sp<Client>& client, const String8& name,
            uint32_t w, uint32_t h, uint32_t flags, sp<IBinder>* outHandle,
            sp<Layer>* outLayer);

    String8 getUniqueLayerName(const String8& name);

    // called in response to the window-manager calling