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

Commit ce0ad96d authored by Alec Mouri's avatar Alec Mouri
Browse files

Remove gl surfaces from DisplayDevice.

These are already subverted by rendering to a FBO.

Bug: 117680609
Change-Id: Ib5b446f30a73a36d8f1c759edf458eb3d06a97ed
Test: libsurfaceflinger_unittest, SurfaceFlinger_test
parent 8147b0ea
Loading
Loading
Loading
Loading
+7 −20
Original line number Diff line number Diff line
@@ -225,7 +225,6 @@ DisplayDevice::DisplayDevice(DisplayDeviceCreationArgs&& args)
        mNativeWindow(args.nativeWindow),
        mGraphicBuffer(nullptr),
        mDisplaySurface(args.displaySurface),
        mSurface{std::move(args.renderSurface)},
        mDisplayInstallOrientation(args.displayInstallOrientation),
        mPageFlipCount(0),
        mIsVirtual(args.isVirtual),
@@ -247,7 +246,6 @@ DisplayDevice::DisplayDevice(DisplayDeviceCreationArgs&& args)

    ALOGE_IF(!mNativeWindow, "No native window was set for display");
    ALOGE_IF(!mDisplaySurface, "No display surface was set for display");
    ALOGE_IF(!mSurface, "No render surface was set for display");

    std::vector<Hdr> types = args.hdrCapabilities.getSupportedHdrTypes();
    for (Hdr hdrType : types) {
@@ -439,12 +437,6 @@ void DisplayDevice::onPresentDisplayCompleted() {
    mDisplaySurface->onFrameCommitted();
}

bool DisplayDevice::makeCurrent() const {
    bool success = mFlinger->getRenderEngine().setCurrentSurface(*mSurface);
    setViewportAndProjection();
    return success;
}

void DisplayDevice::setViewportAndProjection() const {
    size_t w = mDisplayWidth;
    size_t h = mDisplayHeight;
@@ -607,12 +599,8 @@ status_t DisplayDevice::orientationToTransfrom(
void DisplayDevice::setDisplaySize(const int newWidth, const int newHeight) {
    dirtyRegion.set(getBounds());

    mSurface->setNativeWindow(nullptr);

    mDisplaySurface->resizeBuffers(newWidth, newHeight);

    ANativeWindow* const window = mNativeWindow.get();
    mSurface->setNativeWindow(window);
    mDisplayWidth = newWidth;
    mDisplayHeight = newHeight;
}
@@ -728,12 +716,11 @@ void DisplayDevice::dump(String8& result) const {
    ANativeWindow* const window = mNativeWindow.get();
    result.appendFormat("+ %s\n", getDebugName().c_str());
    result.appendFormat("  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",
                        "format=%d, orient=%2d (type=%08x), flips=%u, isSecure=%d, "
                        "powerMode=%d, activeConfig=%d, numLayers=%zu\n",
                        mLayerStack, mDisplayWidth, mDisplayHeight, window,
                        mSurface->queryRedSize(), mSurface->queryGreenSize(),
                        mSurface->queryBlueSize(), mSurface->queryAlphaSize(), mOrientation,
                        tr.getType(), getPageFlipCount(), mIsSecure, mPowerMode, mActiveConfig,
                        ANativeWindow_getFormat(window), mOrientation, tr.getType(),
                        getPageFlipCount(), mIsSecure, mPowerMode, mActiveConfig,
                        mVisibleLayersSortedByZ.size());
    result.appendFormat("   v:[%d,%d,%d,%d], f:[%d,%d,%d,%d], s:[%d,%d,%d,%d],"
                        "transform:[[%0.3f,%0.3f,%0.3f][%0.3f,%0.3f,%0.3f][%0.3f,%0.3f,%0.3f]]\n",
@@ -744,9 +731,9 @@ void DisplayDevice::dump(String8& result) const {
    auto const surface = static_cast<Surface*>(window);
    ui::Dataspace dataspace = surface->getBuffersDataSpace();
    result.appendFormat("   wideColorGamut=%d, hdr10=%d, colorMode=%s, dataspace: %s (%d)\n",
                        mHasWideColorGamut, mHasHdr10,
                        decodeColorMode(mActiveColorMode).c_str(),
                        dataspaceDetails(static_cast<android_dataspace>(dataspace)).c_str(), dataspace);
                        mHasWideColorGamut, mHasHdr10, decodeColorMode(mActiveColorMode).c_str(),
                        dataspaceDetails(static_cast<android_dataspace>(dataspace)).c_str(),
                        dataspace);

    String8 surfaceDump;
    mDisplaySurface->dumpAsString(surfaceDump);
+2 −6
Original line number Diff line number Diff line
@@ -24,12 +24,13 @@
#include <string>
#include <unordered_map>

#include <android/native_window.h>
#include <binder/IBinder.h>
#include <gui/LayerState.h>
#include <hardware/hwcomposer_defs.h>
#include <math/mat4.h>
#include <renderengine/RenderEngine.h>
#include <renderengine/Surface.h>
#include <system/window.h>
#include <ui/GraphicTypes.h>
#include <ui/HdrCapabilities.h>
#include <ui/Region.h>
@@ -42,8 +43,6 @@
#include "DisplayHardware/DisplayIdentification.h"
#include "RenderArea.h"

struct ANativeWindow;

namespace android {

class DisplaySurface;
@@ -163,7 +162,6 @@ public:
    void setDisplayName(const std::string& displayName);
    const std::string& getDisplayName() const { return mDisplayName; }

    bool makeCurrent() const;
    // Acquires a new buffer for GPU composition.
    void readyNewBuffer();
    // Marks the current buffer has finished, so that it can be presented and
@@ -220,7 +218,6 @@ private:
    // that drawing to the buffer is now complete.
    base::unique_fd mBufferReady;

    std::unique_ptr<renderengine::Surface> mSurface;
    int             mDisplayWidth;
    int             mDisplayHeight;
    const int       mDisplayInstallOrientation;
@@ -340,7 +337,6 @@ struct DisplayDeviceCreationArgs {
    bool isSecure{false};
    sp<ANativeWindow> nativeWindow;
    sp<DisplaySurface> displaySurface;
    std::unique_ptr<renderengine::Surface> renderSurface;
    int displayInstallOrientation{DisplayState::eOrientationDefault};
    bool hasWideColorGamut{false};
    HdrCapabilities hdrCapabilities;
+0 −8
Original line number Diff line number Diff line
@@ -2330,14 +2330,6 @@ sp<DisplayDevice> SurfaceFlinger::setupNewDisplayDeviceInternal(
    auto nativeWindow = nativeWindowSurface->getNativeWindow();
    creationArgs.nativeWindow = nativeWindow;

    /*
     * Create our display's surface
     */
    std::unique_ptr<renderengine::Surface> renderSurface = getRenderEngine().createSurface();
    renderSurface->setCritical(isInternalDisplay);
    renderSurface->setAsync(state.isVirtual());
    creationArgs.renderSurface = std::move(renderSurface);

    // Make sure that composition can never be stalled by a virtual display
    // consumer that isn't processing buffers fast enough. We have to do this
    // here, in case the display is composed entirely by HWC.
+4 −3
Original line number Diff line number Diff line
@@ -94,6 +94,10 @@ public:
        EXPECT_CALL(*mPrimaryDispSync, computeNextRefresh(0)).WillRepeatedly(Return(0));
        EXPECT_CALL(*mPrimaryDispSync, getPeriod())
                .WillRepeatedly(Return(FakeHwcDisplayInjector::DEFAULT_REFRESH_RATE));
        EXPECT_CALL(*mNativeWindow, query(NATIVE_WINDOW_WIDTH, _))
                .WillRepeatedly(DoAll(SetArgPointee<1>(DEFAULT_DISPLAY_WIDTH), Return(0)));
        EXPECT_CALL(*mNativeWindow, query(NATIVE_WINDOW_HEIGHT, _))
                .WillRepeatedly(DoAll(SetArgPointee<1>(DEFAULT_DISPLAY_HEIGHT), Return(0)));

        mFlinger.setupRenderEngine(std::unique_ptr<renderengine::RenderEngine>(mRenderEngine));
        setupComposer(0);
@@ -140,7 +144,6 @@ public:
    sp<DisplayDevice> mDisplay;
    sp<DisplayDevice> mExternalDisplay;
    sp<mock::DisplaySurface> mDisplaySurface = new mock::DisplaySurface();
    renderengine::mock::Surface* mRenderSurface = new renderengine::mock::Surface();
    mock::NativeWindow* mNativeWindow = new mock::NativeWindow();

    sp<GraphicBuffer> mBuffer = new GraphicBuffer();
@@ -246,8 +249,6 @@ struct BaseDisplayVariant {
        test->mDisplay = FakeDisplayDeviceInjector(test->mFlinger, DEFAULT_DISPLAY_ID,
                                                   false /* isVirtual */, true /* isPrimary */)
                                 .setDisplaySurface(test->mDisplaySurface)
                                 .setRenderSurface(std::unique_ptr<renderengine::Surface>(
                                         test->mRenderSurface))
                                 .setNativeWindow(test->mNativeWindow)
                                 .setSecure(Derived::IS_SECURE)
                                 .setPowerMode(Derived::INIT_POWER_MODE)
+0 −17
Original line number Diff line number Diff line
@@ -135,7 +135,6 @@ public:
    sp<mock::GraphicBufferConsumer> mConsumer;
    sp<mock::GraphicBufferProducer> mProducer;
    surfaceflinger::mock::NativeWindowSurface* mNativeWindowSurface = nullptr;
    renderengine::mock::Surface* mRenderSurface = nullptr;
};

DisplayTransactionTest::DisplayTransactionTest() {
@@ -342,22 +341,10 @@ struct DisplayVariant {
        EXPECT_CALL(*test->mNativeWindowSurface, getNativeWindow())
                .WillOnce(Return(test->mNativeWindow));

        // For simplicity, we only expect to create a single render surface for
        // each test.
        ASSERT_TRUE(test->mRenderSurface == nullptr);
        test->mRenderSurface = new renderengine::mock::Surface();
        EXPECT_CALL(*test->mRenderEngine, createSurface())
                .WillOnce(Return(ByMove(
                        std::unique_ptr<renderengine::Surface>(test->mRenderSurface))));
        EXPECT_CALL(*test->mNativeWindow, query(NATIVE_WINDOW_WIDTH, _))
                .WillRepeatedly(DoAll(SetArgPointee<1>(WIDTH), Return(0)));
        EXPECT_CALL(*test->mNativeWindow, query(NATIVE_WINDOW_HEIGHT, _))
                .WillRepeatedly(DoAll(SetArgPointee<1>(HEIGHT), Return(0)));

        // Creating a DisplayDevice requires getting default dimensions from the
        // native window.
        EXPECT_CALL(*test->mRenderSurface, setAsync(static_cast<bool>(ASYNC))).Times(1);
        EXPECT_CALL(*test->mRenderSurface, setCritical(static_cast<bool>(CRITICAL))).Times(1);
    }

    static void setupFramebufferConsumerBufferQueueCallExpectations(DisplayTransactionTest* test) {
@@ -1944,12 +1931,10 @@ TEST_F(HandleTransactionLockedTest, processesDisplayWidthChanges) {
    // A display is set up
    auto nativeWindow = new mock::NativeWindow();
    auto displaySurface = new mock::DisplaySurface();
    auto renderSurface = new renderengine::mock::Surface();
    sp<GraphicBuffer> buf = new GraphicBuffer();
    auto display = Case::Display::makeFakeExistingDisplayInjector(this);
    display.setNativeWindow(nativeWindow);
    display.setDisplaySurface(displaySurface);
    display.setRenderSurface(std::unique_ptr<renderengine::Surface>(renderSurface));
    // Setup injection expections
    EXPECT_CALL(*nativeWindow, query(NATIVE_WINDOW_WIDTH, _))
            .WillOnce(DoAll(SetArgPointee<1>(oldWidth), Return(0)));
@@ -1988,12 +1973,10 @@ TEST_F(HandleTransactionLockedTest, processesDisplayHeightChanges) {
    // A display is set up
    auto nativeWindow = new mock::NativeWindow();
    auto displaySurface = new mock::DisplaySurface();
    auto renderSurface = new renderengine::mock::Surface();
    sp<GraphicBuffer> buf = new GraphicBuffer();
    auto display = Case::Display::makeFakeExistingDisplayInjector(this);
    display.setNativeWindow(nativeWindow);
    display.setDisplaySurface(displaySurface);
    display.setRenderSurface(std::unique_ptr<renderengine::Surface>(renderSurface));
    // Setup injection expections
    EXPECT_CALL(*nativeWindow, query(NATIVE_WINDOW_WIDTH, _))
            .WillOnce(DoAll(SetArgPointee<1>(oldWidth), Return(0)));
Loading