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

Commit 888c822c authored by Mathias Agopian's avatar Mathias Agopian
Browse files

remove a dependency of DisplayDevice on the refresh rate

this remove a dependency (not all) on FramebufferSurface

Change-Id: Ie07ce70760cdcedfb41b5b41bea8da45637bf474
parent 72131d9e
Loading
Loading
Loading
Loading
+0 −30
Original line number Diff line number Diff line
@@ -117,12 +117,10 @@ DisplayDevice::DisplayDevice(
      mSurface(EGL_NO_SURFACE),
      mContext(EGL_NO_CONTEXT),
      mDpiX(), mDpiY(),
      mRefreshRate(),
      mDensity(),
      mDisplayWidth(), mDisplayHeight(), mFormat(),
      mFlags(),
      mPageFlipCount(),
      mRefreshPeriod(),
      mSecureLayerVisible(false),
      mScreenAcquired(false),
      mOrientation(),
@@ -160,10 +158,6 @@ float DisplayDevice::getDensity() const {
    return mDensity;
}

float DisplayDevice::getRefreshRate() const {
    return mRefreshRate;
}

int DisplayDevice::getWidth() const {
    return mDisplayWidth;
}
@@ -180,19 +174,6 @@ EGLSurface DisplayDevice::getEGLSurface() const {
    return mSurface;
}

status_t DisplayDevice::getInfo(DisplayInfo* info) const {
    info->w = getWidth();
    info->h = getHeight();
    info->xdpi = getDpiX();
    info->ydpi = getDpiY();
    info->fps = getRefreshRate();
    info->density = getDensity();
    info->orientation = getOrientation();
    // TODO: this needs to go away (currently needed only by webkit)
    getPixelFormatInfo(getFormat(), &info->pixelFormatInfo);
    return NO_ERROR;
}

void DisplayDevice::init(EGLConfig config)
{
    ANativeWindow* const window = mNativeWindow.get();
@@ -207,13 +188,6 @@ void DisplayDevice::init(EGLConfig config)
    window->query(window, NATIVE_WINDOW_FORMAT, &format);
    mDpiX = window->xdpi;
    mDpiY = window->ydpi;
    if (mFramebufferSurface != NULL) {
        mRefreshRate = mFramebufferSurface->getRefreshRate();
    } else {
        mRefreshRate = 60;
    }
    mRefreshPeriod = nsecs_t(1e9 / mRefreshRate);


    // TODO: Not sure if display density should handled by SF any longer
    class Density {
@@ -279,10 +253,6 @@ uint32_t DisplayDevice::getPageFlipCount() const {
    return mPageFlipCount;
}

nsecs_t DisplayDevice::getRefreshPeriod() const {
    return mRefreshPeriod;
}

status_t DisplayDevice::compositionComplete() const {
    if (mFramebufferSurface == NULL) {
        return NO_ERROR;
+0 −5
Original line number Diff line number Diff line
@@ -82,14 +82,11 @@ public:

    float       getDpiX() const;
    float       getDpiY() const;
    float       getRefreshRate() const;
    float       getDensity() const;
    int         getWidth() const;
    int         getHeight() const;
    PixelFormat getFormat() const;
    uint32_t    getFlags() const;
    nsecs_t     getRefreshPeriod() const;
    status_t    getInfo(DisplayInfo* info) const;

    EGLSurface  getEGLSurface() const;

@@ -149,14 +146,12 @@ private:
    EGLContext      mContext;
    float           mDpiX;
    float           mDpiY;
    float           mRefreshRate;
    float           mDensity;
    int             mDisplayWidth;
    int             mDisplayHeight;
    PixelFormat     mFormat;
    uint32_t        mFlags;
    mutable uint32_t mPageFlipCount;
    nsecs_t         mRefreshPeriod;

    /*
     * Can only accessed from the main thread, these members
+31 −4
Original line number Diff line number Diff line
@@ -101,14 +101,12 @@ struct HWComposer::cb_context {

HWComposer::HWComposer(
        const sp<SurfaceFlinger>& flinger,
        EventHandler& handler,
        nsecs_t refreshPeriod)
        EventHandler& handler)
    : mFlinger(flinger),
      mModule(0), mHwc(0), mList(0), mCapacity(0),
      mNumOVLayers(0), mNumFBLayers(0),
      mCBContext(new cb_context),
      mEventHandler(handler),
      mRefreshPeriod(refreshPeriod),
      mEventHandler(handler), mRefreshPeriod(0),
      mVSyncCount(0), mDebugForceFakeVSync(false)
{
    char value[PROPERTY_VALUE_MAX];
@@ -137,6 +135,11 @@ HWComposer::HWComposer(
                // always turn vsync off when we start
                mHwc->methods->eventControl(mHwc, HWC_EVENT_VSYNC, 0);
                needVSyncThread = false;

                int period;
                if (mHwc->query(mHwc, HWC_VSYNC_PERIOD, &period) == NO_ERROR) {
                    mRefreshPeriod = nsecs_t(period);
                }
            }
            if (mHwc->registerProcs) {
                mCBContext->hwc = this;
@@ -148,6 +151,26 @@ HWComposer::HWComposer(
        }
    }

    if (mRefreshPeriod == 0) {
        // for compatibility, we attempt to get the refresh rate from
        // the FB HAL if we couldn't get it from the HWC HAL.
        hw_module_t const* module;
        if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module) == 0) {
            framebuffer_device_t* fbDev;
            int err = framebuffer_open(module, &fbDev);
            if (!err && fbDev) {
                mRefreshPeriod = nsecs_t(1e9 / fbDev->fps);
                framebuffer_close(fbDev);
            }
        }
        ALOGW("getting VSYNC period from fb HAL: %lld", mRefreshPeriod);
    }

    if (mRefreshPeriod == 0) {
        mRefreshPeriod = nsecs_t(1e9 / 60.0);
        ALOGW("getting VSYNC period thin air: %lld", mRefreshPeriod);
    }

    if (needVSyncThread) {
        // we don't have VSYNC support, we need to fake it
        mVSyncThread = new VSyncThread(*this);
@@ -189,6 +212,10 @@ void HWComposer::vsync(int dpy, int64_t timestamp) {
    mLastHwVSync = timestamp;
}

nsecs_t HWComposer::getRefreshPeriod() const {
    return mRefreshPeriod;
}

nsecs_t HWComposer::getRefreshTimestamp() const {
    // this returns the last refresh timestamp.
    // if the last one is not available, we estimate it based on
+2 −2
Original line number Diff line number Diff line
@@ -55,8 +55,7 @@ public:
        virtual ~EventHandler() {}
    };

    HWComposer(const sp<SurfaceFlinger>& flinger,
            EventHandler& handler, nsecs_t refreshPeriod);
    HWComposer(const sp<SurfaceFlinger>& flinger, EventHandler& handler);
    ~HWComposer();

    status_t initCheck() const;
@@ -189,6 +188,7 @@ public:

    void eventControl(int event, int enabled);

    nsecs_t getRefreshPeriod() const;
    nsecs_t getRefreshTimestamp() const;

    // this class is only used to fake the VSync event on systems that don't
+1 −1
Original line number Diff line number Diff line
@@ -729,7 +729,7 @@ void Layer::dumpStats(String8& result, char* buffer, size_t SIZE) const
    LayerBaseClient::dumpStats(result, buffer, SIZE);
    const size_t o = mFrameLatencyOffset;
    const DisplayDevice& hw(mFlinger->getDefaultDisplayDevice());
    const nsecs_t period = hw.getRefreshPeriod();
    const nsecs_t period = mFlinger->getHwComposer().getRefreshPeriod();
    result.appendFormat("%lld\n", period);
    for (size_t i=0 ; i<128 ; i++) {
        const size_t index = (o+i) % 128;
Loading