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

Commit d3ee231e authored by Mathias Agopian's avatar Mathias Agopian
Browse files

cleanups in preparation of bigger changes

- fix typo drawForSreenshot misspelled
- get rid of DisplayDeviceBase
- removed unused or unneeded code
- always pass a DisplayDevice to Layer methods that are called
  on a per-display basis (to make it clear that this could be
  called more than once per composition).

Change-Id: Id948b7e09fe5c06db0e42d40d6ed75dd095c7f44
parent 0f2f5ff7
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -9,7 +9,6 @@ LOCAL_SRC_FILES:= \
    LayerBase.cpp                           \
    LayerDim.cpp                            \
    LayerScreenshot.cpp                     \
    DisplayHardware/DisplayDeviceBase.cpp   \
    DisplayHardware/FramebufferSurface.cpp  \
    DisplayHardware/HWComposer.cpp          \
    DisplayHardware/PowerHAL.cpp            \
+35 −22
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@
#include <hardware/gralloc.h>

#include "DisplayHardware/FramebufferSurface.h"
#include "DisplayHardware/DisplayDeviceBase.h"
#include "DisplayHardware/HWComposer.h"

#include "DisplayDevice.h"
@@ -103,12 +102,22 @@ DisplayDevice::DisplayDevice(
        int display,
        const sp<SurfaceTextureClient>& surface,
        EGLConfig config)
    : DisplayDeviceBase(display),
      mFlinger(flinger),
    :   mFlinger(flinger),
        mDisplayId(display),
        mNativeWindow(surface),
      mFlags(0),
        mDisplay(EGL_NO_DISPLAY),
        mSurface(EGL_NO_SURFACE),
        mContext(EGL_NO_CONTEXT),
        mDpiX(), mDpiY(),
        mRefreshRate(),
        mDensity(),
        mDisplayWidth(), mDisplayHeight(), mFormat(),
        mFlags(),
        mPageFlipCount(),
        mRefreshPeriod(),
        mSecureLayerVisible(false),
        mScreenAcquired(false),
        mOrientation(),
        mLayerStack(0)
{
    init(config);
@@ -248,15 +257,6 @@ uint32_t DisplayDevice::getPageFlipCount() const {
    return mPageFlipCount;
}

nsecs_t DisplayDevice::getRefreshTimestamp() const {
    // this returns the last refresh timestamp.
    // if the last one is not available, we estimate it based on
    // the refresh period and whatever closest timestamp we have.
    Mutex::Autolock _l(mLock);
    nsecs_t now = systemTime(CLOCK_MONOTONIC);
    return now - ((now - mLastHwVSync) %  mRefreshPeriod);
}

nsecs_t DisplayDevice::getRefreshPeriod() const {
    return mRefreshPeriod;
}
@@ -268,11 +268,6 @@ status_t DisplayDevice::compositionComplete() const {
    return mFramebufferSurface->compositionComplete();
}

void DisplayDevice::onVSyncReceived(nsecs_t timestamp) {
    Mutex::Autolock _l(mLock);
    mLastHwVSync = timestamp;
}

void DisplayDevice::flip(const Region& dirty) const
{
    checkGLErrors();
@@ -340,6 +335,24 @@ bool DisplayDevice::getSecureLayerVisible() const {

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

bool DisplayDevice::canDraw() const {
    return mScreenAcquired;
}

void DisplayDevice::releaseScreen() const {
    mScreenAcquired = false;
}

void DisplayDevice::acquireScreen() const {
    mScreenAcquired = true;
}

bool DisplayDevice::isScreenAcquired() const {
    return mScreenAcquired;
}

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

status_t DisplayDevice::orientationToTransfrom(
        int orientation, int w, int h, Transform* tr)
{
+30 −29
Original line number Diff line number Diff line
@@ -14,16 +14,14 @@
 * limitations under the License.
 */

#ifndef ANDROID_DISPLAY_HARDWARE_H
#define ANDROID_DISPLAY_HARDWARE_H
#ifndef ANDROID_DISPLAY_DEVICE_H
#define ANDROID_DISPLAY_DEVICE_H

#include <stdlib.h>

#include <ui/PixelFormat.h>
#include <ui/Region.h>

#include <GLES/gl.h>
#include <GLES/glext.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>

@@ -32,8 +30,6 @@

#include "Transform.h"

#include "DisplayHardware/DisplayDeviceBase.h"

namespace android {

class DisplayInfo;
@@ -42,7 +38,7 @@ class LayerBase;
class SurfaceFlinger;
class SurfaceTextureClient;

class DisplayDevice : public DisplayDeviceBase
class DisplayDevice
{
public:
    // region in layer-stack space
@@ -63,14 +59,12 @@ public:
            const sp<SurfaceTextureClient>& surface,
            EGLConfig config);

    virtual ~DisplayDevice();
    ~DisplayDevice();

    // Flip the front and back buffers if the back buffer is "dirty".  Might
    // be instantaneous, might involve copying the frame buffer around.
    void flip(const Region& dirty) const;

    void onVSyncReceived(nsecs_t timestamp);

    float       getDpiX() const;
    float       getDpiY() const;
    float       getRefreshRate() const;
@@ -80,7 +74,6 @@ public:
    PixelFormat getFormat() const;
    uint32_t    getFlags() const;
    nsecs_t     getRefreshPeriod() const;
    nsecs_t     getRefreshTimestamp() const;
    status_t    getInfo(DisplayInfo* info) const;

    EGLSurface  getEGLSurface() const;
@@ -94,12 +87,6 @@ public:
    const Transform&        getTransform() const { return mGlobalTransform; }
    uint32_t                getLayerStack() const { return mLayerStack; }


    uint32_t getPageFlipCount() const;
    EGLDisplay getEGLDisplay() const { return mDisplay; }

    void dump(String8& res) const;

    status_t compositionComplete() const;
    
    Rect getBounds() const {
@@ -109,6 +96,21 @@ public:

    static void makeCurrent(const DisplayDevice& hw, EGLContext ctx);

    /* ------------------------------------------------------------------------
     * blank / unplank management
     */
    void releaseScreen() const;
    void acquireScreen() const;
    bool isScreenAcquired() const;
    bool canDraw() const;

    /* ------------------------------------------------------------------------
     * Debugging
     */
    uint32_t getPageFlipCount() const;
    void dump(String8& res) const;


private:
    void init(EGLConfig config);

@@ -117,12 +119,13 @@ private:
     */
    sp<SurfaceFlinger> mFlinger;
    int mDisplayId;

    // ANativeWindow this display is rendering into
    sp<SurfaceTextureClient> mNativeWindow;

    // set if mNativeWindow is a FramebufferSurface
    sp<FramebufferSurface> mFramebufferSurface;


    EGLDisplay      mDisplay;
    EGLSurface      mSurface;
    EGLContext      mContext;
@@ -135,35 +138,33 @@ private:
    PixelFormat     mFormat;
    uint32_t        mFlags;
    mutable uint32_t mPageFlipCount;

    nsecs_t         mRefreshPeriod;

    /*
     * Can only accessed from the main thread, these members
     * don't need synchronization.
     */

    // list of visible layers on that display
    Vector< sp<LayerBase> > mVisibleLayersSortedByZ;

    // Whether we have a visible secure layer on this display
    bool mSecureLayerVisible;

    // Whether the screen is blanked;
    mutable int mScreenAcquired;


    // this used to be in GraphicPlane
    /*
     * Transaction state
     */
    static status_t orientationToTransfrom(int orientation, int w, int h,
            Transform* tr);
    Transform mGlobalTransform;
    int mOrientation;

    uint32_t mLayerStack;


    /*
     *  protected by mLock
     */
    mutable Mutex mLock;
    mutable nsecs_t mLastHwVSync;
};

}; // namespace android

#endif // ANDROID_DISPLAY_HARDWARE_H
#endif // ANDROID_DISPLAY_DEVICE_H
+0 −48
Original line number Diff line number Diff line
/*
 * Copyright (C) 2012 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <stdint.h>
#include <sys/types.h>

#include "DisplayHardware/DisplayDeviceBase.h"

// ----------------------------------------------------------------------------
namespace android {

DisplayDeviceBase::DisplayDeviceBase(uint32_t displayIndex) {
    mScreenAcquired = true;
}

DisplayDeviceBase::~DisplayDeviceBase() {
}

bool DisplayDeviceBase::canDraw() const {
    return mScreenAcquired;
}

void DisplayDeviceBase::releaseScreen() const {
    mScreenAcquired = false;
}

void DisplayDeviceBase::acquireScreen() const {
    mScreenAcquired = true;
}

bool DisplayDeviceBase::isScreenAcquired() const {
    return mScreenAcquired;
}

}; // namespace android
+0 −42
Original line number Diff line number Diff line
/*
 * Copyright (C) 2012 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef ANDROID_DISPLAY_HARDWARE_BASE_H
#define ANDROID_DISPLAY_HARDWARE_BASE_H

#include <stdint.h>

namespace android {

class DisplayDeviceBase {
public:
    DisplayDeviceBase(uint32_t displayIndex);
    ~DisplayDeviceBase();

    // console management
    void releaseScreen() const;
    void acquireScreen() const;
    bool isScreenAcquired() const;

    bool canDraw() const;

private:
    mutable int mScreenAcquired;
};

}; // namespace android

#endif // ANDROID_DISPLAY_HARDWARE_BASE_H
Loading