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

Commit 0ce27830 authored by Rachel Lee's avatar Rachel Lee Committed by Android (Google) Code Review
Browse files

Merge "Framework code for Attached Choreographer."

parents 6c7fc9db 2248f52c
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -101,8 +101,9 @@ Choreographer* Choreographer::getForThread() {
    return gChoreographer;
}

Choreographer::Choreographer(const sp<Looper>& looper)
      : DisplayEventDispatcher(looper, gui::ISurfaceComposer::VsyncSource::eVsyncSourceApp),
Choreographer::Choreographer(const sp<Looper>& looper, const sp<IBinder>& layerHandle)
      : DisplayEventDispatcher(looper, gui::ISurfaceComposer::VsyncSource::eVsyncSourceApp, {},
                               layerHandle),
        mLooper(looper),
        mThreadId(std::this_thread::get_id()) {
    std::lock_guard<std::mutex> _l(gChoreographers.lock);
+3 −2
Original line number Diff line number Diff line
@@ -37,9 +37,10 @@ static constexpr nsecs_t WAITING_FOR_VSYNC_TIMEOUT = ms2ns(300);

DisplayEventDispatcher::DisplayEventDispatcher(const sp<Looper>& looper,
                                               gui::ISurfaceComposer::VsyncSource vsyncSource,
                                               EventRegistrationFlags eventRegistration)
                                               EventRegistrationFlags eventRegistration,
                                               const sp<IBinder>& layerHandle)
      : mLooper(looper),
        mReceiver(vsyncSource, eventRegistration),
        mReceiver(vsyncSource, eventRegistration, layerHandle),
        mWaitingForVsync(false),
        mLastVsyncCount(0),
        mLastScheduleVsyncTime(0) {
+8 −3
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@
 * limitations under the License.
 */

#define LOG_TAG "DisplayEventReceiver"

#include <string.h>

#include <utils/Errors.h>
@@ -32,7 +34,8 @@ namespace android {
// ---------------------------------------------------------------------------

DisplayEventReceiver::DisplayEventReceiver(gui::ISurfaceComposer::VsyncSource vsyncSource,
                                           EventRegistrationFlags eventRegistration) {
                                           EventRegistrationFlags eventRegistration,
                                           const sp<IBinder>& layerHandle) {
    sp<gui::ISurfaceComposer> sf(ComposerServiceAIDL::getComposerService());
    if (sf != nullptr) {
        mEventConnection = nullptr;
@@ -41,8 +44,8 @@ DisplayEventReceiver::DisplayEventReceiver(gui::ISurfaceComposer::VsyncSource vs
                                                 static_cast<
                                                         gui::ISurfaceComposer::EventRegistration>(
                                                         eventRegistration.get()),
                                                 &mEventConnection);
        if (mEventConnection != nullptr) {
                                                 layerHandle, &mEventConnection);
        if (status.isOk() && mEventConnection != nullptr) {
            mDataChannel = std::make_unique<gui::BitTube>();
            status = mEventConnection->stealReceiveChannel(mDataChannel.get());
            if (!status.isOk()) {
@@ -51,6 +54,8 @@ DisplayEventReceiver::DisplayEventReceiver(gui::ISurfaceComposer::VsyncSource vs
                mDataChannel.reset();
                mEventConnection.clear();
            }
        } else {
            ALOGE("DisplayEventConnection creation failed: status=%s", status.toString8().c_str());
        }
    }
}
+21 −1
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
#include <utils/Errors.h>
#include <utils/KeyedVector.h>
#include <utils/Log.h>
#include <utils/Looper.h>
#include <utils/threads.h>

#include <binder/IPCThreadState.h>
@@ -34,8 +35,9 @@
#include <ui/Rect.h>
#include <ui/StaticDisplayInfo.h>

#include <gui/BufferQueueCore.h>
#include <gui/BLASTBufferQueue.h>
#include <gui/BufferQueueCore.h>
#include <gui/Choreographer.h>
#include <gui/ISurfaceComposer.h>
#include <gui/Surface.h>
#include <gui/SurfaceComposerClient.h>
@@ -191,6 +193,24 @@ const std::string& SurfaceControl::getName() const {
    return mName;
}

std::shared_ptr<Choreographer> SurfaceControl::getChoreographer() {
    if (mChoreographer) {
        return mChoreographer;
    }
    sp<Looper> looper = Looper::getForThread();
    if (!looper.get()) {
        ALOGE("%s: No looper prepared for thread", __func__);
        return nullptr;
    }
    mChoreographer = std::make_shared<Choreographer>(looper, getHandle());
    status_t result = mChoreographer->initialize();
    if (result != OK) {
        ALOGE("Failed to initialize choreographer");
        mChoreographer = nullptr;
    }
    return mChoreographer;
}

sp<IGraphicBufferProducer> SurfaceControl::getIGraphicBufferProducer()
{
    getSurface();
+7 −1
Original line number Diff line number Diff line
@@ -68,9 +68,15 @@ interface ISurfaceComposer {

    /**
     * Create a display event connection
     *
     * layerHandle
     *     Optional binder handle representing a Layer in SF to associate the new
     *     DisplayEventConnection with. This handle can be found inside a surface control after
     *     surface creation, see ISurfaceComposerClient::createSurface. Set to null if no layer
     *     association should be made.
     */
    @nullable IDisplayEventConnection createDisplayEventConnection(VsyncSource vsyncSource,
            EventRegistration eventRegistration);
            EventRegistration eventRegistration, @nullable IBinder layerHandle);

    /**
     * Create a connection with SurfaceFlinger.
Loading