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

Commit 40fd295c authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I99404218,Ic07b3851

* changes:
  SF: Clean up DisplayDeviceState
  SF: Use std::string for display name
parents b83fc811 663bd28f
Loading
Loading
Loading
Loading
+5 −18
Original line number Diff line number Diff line
@@ -149,8 +149,8 @@ int DisplayDevice::getHeight() const {
    return mDisplayHeight;
}

void DisplayDevice::setDisplayName(const String8& displayName) {
    if (!displayName.isEmpty()) {
void DisplayDevice::setDisplayName(const std::string& displayName) {
    if (!displayName.empty()) {
        // never override the name with an empty name
        mDisplayName = displayName;
    }
@@ -201,8 +201,7 @@ void DisplayDevice::swapBuffers(HWComposer& hwc) const {

    status_t result = mDisplaySurface->advanceFrame();
    if (result != NO_ERROR) {
        ALOGE("[%s] failed pushing new frame to HWC: %d",
                mDisplayName.string(), result);
        ALOGE("[%s] failed pushing new frame to HWC: %d", mDisplayName.c_str(), result);
    }
}

@@ -481,7 +480,7 @@ uint32_t DisplayDevice::getPrimaryDisplayOrientationTransform() {
void DisplayDevice::dump(String8& result) const {
    const Transform& tr(mGlobalTransform);
    ANativeWindow* const window = mNativeWindow.get();
    result.appendFormat("+ DisplayDevice: %s\n", mDisplayName.string());
    result.appendFormat("+ DisplayDevice: %s\n", mDisplayName.c_str());
    result.appendFormat("   type=%x, hwcId=%d, layerStack=%u, (%4dx%4d), ANativeWindow=%p "
                        "(%d:%d:%d:%d), orient=%2d (type=%08x), "
                        "flips=%u, isSecure=%d, powerMode=%d, activeConfig=%d, numLayers=%zu\n",
@@ -508,18 +507,6 @@ void DisplayDevice::dump(String8& result) const {
    result.append(surfaceDump);
}

std::atomic<int32_t> DisplayDeviceState::nextDisplayId(1);

DisplayDeviceState::DisplayDeviceState(DisplayDevice::DisplayType type, bool isSecure)
    : type(type),
      layerStack(DisplayDevice::NO_LAYER_STACK),
      orientation(0),
      width(0),
      height(0),
      isSecure(isSecure)
{
    viewport.makeInvalid();
    frame.makeInvalid();
}
std::atomic<int32_t> DisplayDeviceState::sNextSequenceId(1);

}  // namespace android
+10 −11
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@
#include "RenderEngine/Surface.h"

#include <memory>
#include <string>

struct ANativeWindow;

@@ -152,8 +153,8 @@ public:
    }
    inline Rect bounds() const { return getBounds(); }

    void setDisplayName(const String8& displayName);
    const String8& getDisplayName() const { return mDisplayName; }
    void setDisplayName(const std::string& displayName);
    const std::string& getDisplayName() const { return mDisplayName; }

    bool makeCurrent() const;
    void setViewportAndProjection() const;
@@ -208,7 +209,7 @@ private:
    int             mDisplayWidth;
    int             mDisplayHeight;
    mutable uint32_t mPageFlipCount;
    String8         mDisplayName;
    std::string     mDisplayName;
    bool            mIsSecure;

    /*
@@ -266,15 +267,10 @@ private:
};

struct DisplayDeviceState {
    DisplayDeviceState() = default;
    DisplayDeviceState(DisplayDevice::DisplayType type, bool isSecure);

    bool isValid() const { return type >= 0; }
    bool isMainDisplay() const { return type == DisplayDevice::DISPLAY_PRIMARY; }
    bool isVirtualDisplay() const { return type >= DisplayDevice::DISPLAY_VIRTUAL; }
    bool isVirtual() const { return type >= DisplayDevice::DISPLAY_VIRTUAL; }

    static std::atomic<int32_t> nextDisplayId;
    int32_t displayId = nextDisplayId++;
    int32_t sequenceId = sNextSequenceId++;
    DisplayDevice::DisplayType type = DisplayDevice::DISPLAY_ID_INVALID;
    sp<IGraphicBufferProducer> surface;
    uint32_t layerStack = DisplayDevice::NO_LAYER_STACK;
@@ -283,8 +279,11 @@ struct DisplayDeviceState {
    uint8_t orientation = 0;
    uint32_t width = 0;
    uint32_t height = 0;
    String8 displayName;
    std::string displayName;
    bool isSecure = false;

private:
    static std::atomic<int32_t> sNextSequenceId;
};

class DisplayRenderArea : public RenderArea {
+5 −5
Original line number Diff line number Diff line
@@ -32,11 +32,11 @@ namespace android {
// ---------------------------------------------------------------------------

#define VDS_LOGE(msg, ...) ALOGE("[%s] " msg, \
        mDisplayName.string(), ##__VA_ARGS__)
        mDisplayName.c_str(), ##__VA_ARGS__)
#define VDS_LOGW_IF(cond, msg, ...) ALOGW_IF(cond, "[%s] " msg, \
        mDisplayName.string(), ##__VA_ARGS__)
        mDisplayName.c_str(), ##__VA_ARGS__)
#define VDS_LOGV(msg, ...) ALOGV("[%s] " msg, \
        mDisplayName.string(), ##__VA_ARGS__)
        mDisplayName.c_str(), ##__VA_ARGS__)

static const char* dbgCompositionTypeStr(DisplaySurface::CompositionType type) {
    switch (type) {
@@ -52,7 +52,7 @@ VirtualDisplaySurface::VirtualDisplaySurface(HWComposer& hwc, int32_t dispId,
        const sp<IGraphicBufferProducer>& sink,
        const sp<IGraphicBufferProducer>& bqProducer,
        const sp<IGraphicBufferConsumer>& bqConsumer,
        const String8& name)
        const std::string& name)
:   ConsumerBase(bqConsumer),
    mHwc(hwc),
    mDisplayId(dispId),
@@ -102,7 +102,7 @@ VirtualDisplaySurface::VirtualDisplaySurface(HWComposer& hwc, int32_t dispId,
    }
    mOutputFormat = mDefaultOutputFormat;

    ConsumerBase::mName = String8::format("VDS: %s", mDisplayName.string());
    ConsumerBase::mName = String8::format("VDS: %s", mDisplayName.c_str());
    mConsumer->setConsumerName(ConsumerBase::mName);
    mConsumer->setConsumerUsageBits(GRALLOC_USAGE_HW_COMPOSER);
    mConsumer->setDefaultBufferSize(sinkWidth, sinkHeight);
+4 −2
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
#ifndef ANDROID_SF_VIRTUAL_DISPLAY_SURFACE_H
#define ANDROID_SF_VIRTUAL_DISPLAY_SURFACE_H

#include <string>

#include "DisplaySurface.h"
#include "HWComposerBufferCache.h"

@@ -77,7 +79,7 @@ public:
            const sp<IGraphicBufferProducer>& sink,
            const sp<IGraphicBufferProducer>& bqProducer,
            const sp<IGraphicBufferConsumer>& bqConsumer,
            const String8& name);
            const std::string& name);

    //
    // DisplaySurface interface
@@ -153,7 +155,7 @@ private:
    //
    HWComposer& mHwc;
    const int32_t mDisplayId;
    const String8 mDisplayName;
    const std::string mDisplayName;
    sp<IGraphicBufferProducer> mSource[2]; // indexed by SOURCE_*
    uint32_t mDefaultOutputFormat;

+13 −10
Original line number Diff line number Diff line
@@ -408,8 +408,10 @@ sp<IBinder> SurfaceFlinger::createDisplay(const String8& displayName,
    sp<BBinder> token = new DisplayToken(this);

    Mutex::Autolock _l(mStateLock);
    DisplayDeviceState info(DisplayDevice::DISPLAY_VIRTUAL, secure);
    DisplayDeviceState info;
    info.type = DisplayDevice::DISPLAY_VIRTUAL;
    info.displayName = displayName;
    info.isSecure = secure;
    mCurrentState.displays.add(token, info);
    mInterceptor->saveDisplayCreation(info);
    return token;
@@ -425,11 +427,11 @@ void SurfaceFlinger::destroyDisplay(const sp<IBinder>& display) {
    }

    const DisplayDeviceState& info(mCurrentState.displays.valueAt(idx));
    if (!info.isVirtualDisplay()) {
    if (!info.isVirtual()) {
        ALOGE("destroyDisplay called for non-virtual display");
        return;
    }
    mInterceptor->saveDisplayDeletion(info.displayId);
    mInterceptor->saveDisplayDeletion(info.sequenceId);
    mCurrentState.displays.removeItemsAt(idx);
    setTransactionFlags(eDisplayTransactionNeeded);
}
@@ -2239,10 +2241,11 @@ void SurfaceFlinger::processDisplayHotplugEventsLocked() {
            if (!mBuiltinDisplays[displayType].get()) {
                ALOGV("Creating built in display %d", displayType);
                mBuiltinDisplays[displayType] = new BBinder();
                // All non-virtual displays are currently considered secure.
                DisplayDeviceState info(displayType, true);
                DisplayDeviceState info;
                info.type = displayType;
                info.displayName = displayType == DisplayDevice::DISPLAY_PRIMARY ?
                        "Built-in Screen" : "External Screen";
                info.isSecure = true; // All physical displays are currently considered secure.
                mCurrentState.displays.add(mBuiltinDisplays[displayType], info);
                mInterceptor->saveDisplayCreation(info);
            }
@@ -2252,7 +2255,7 @@ void SurfaceFlinger::processDisplayHotplugEventsLocked() {
            ssize_t idx = mCurrentState.displays.indexOfKey(mBuiltinDisplays[displayType]);
            if (idx >= 0) {
                const DisplayDeviceState& info(mCurrentState.displays.valueAt(idx));
                mInterceptor->saveDisplayDeletion(info.displayId);
                mInterceptor->saveDisplayDeletion(info.sequenceId);
                mCurrentState.displays.removeItemsAt(idx);
            }
            mBuiltinDisplays[displayType].clear();
@@ -2430,7 +2433,7 @@ void SurfaceFlinger::processDisplayChangesLocked() {
                mCreateBufferQueue(&bqProducer, &bqConsumer, false);

                int32_t hwcId = -1;
                if (state.isVirtualDisplay()) {
                if (state.isVirtual()) {
                    // Virtual displays without a surface are dormant:
                    // they have external state (layer stack, projection,
                    // etc.) but no internal state (i.e. a DisplayDevice).
@@ -2477,7 +2480,7 @@ void SurfaceFlinger::processDisplayChangesLocked() {
                    mDisplays.add(display,
                                  setupNewDisplayDeviceInternal(display, hwcId, state, dispSurface,
                                                                producer));
                    if (!state.isVirtualDisplay()) {
                    if (!state.isVirtual()) {
                        mEventThread->onHotplugReceived(state.type, true);
                    }
                }
@@ -2920,7 +2923,7 @@ bool SurfaceFlinger::doComposeSurfaces(const sp<const DisplayDevice>& displayDev

        if (!displayDevice->makeCurrent()) {
            ALOGW("DisplayDevice::makeCurrent failed. Aborting surface composition for display %s",
                  displayDevice->getDisplayName().string());
                  displayDevice->getDisplayName().c_str());
            getRenderEngine().resetCurrentSurface();

            // |mStateLock| not needed as we are on the main thread
@@ -3716,7 +3719,7 @@ void SurfaceFlinger::setPowerModeInternal(const sp<DisplayDevice>& hw,
            ALOGW("Surface Interceptor SavePowerMode: invalid display token");
            return;
        }
        mInterceptor->savePowerModeUpdate(mCurrentState.displays.valueAt(idx).displayId, mode);
        mInterceptor->savePowerModeUpdate(mCurrentState.displays.valueAt(idx).sequenceId, mode);
    }

    if (currentMode == HWC_POWER_MODE_OFF) {
Loading