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

Commit 45a165a5 authored by Lloyd Pique's avatar Lloyd Pique
Browse files

SF: Setup CompositionEngine::Display

Add a Display class to CompositionEngine, and modify DisplayDevice to
create it.

The Display instance holds only some basic data about the display to
start.

Test: atest libsurfaceflinger_unittest libcompositionengine_test
Bug: 121291683
Change-Id: I2a81817c97519c29759cc62b019c9a3c0aee2b93
parent 6b99b499
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ cc_library {
    defaults: ["libcompositionengine_defaults"],
    srcs: [
        "src/CompositionEngine.cpp",
        "src/Display.cpp",
    ],
    local_include_dirs: ["include"],
    export_include_dirs: ["include"],
@@ -45,6 +46,7 @@ cc_library {
    defaults: ["libcompositionengine_defaults"],
    srcs: [
        "mock/CompositionEngine.cpp",
        "mock/Display.cpp",
    ],
    static_libs: [
        "libgtest",
@@ -61,6 +63,7 @@ cc_test {
    defaults: ["libcompositionengine_defaults"],
    srcs: [
        "tests/CompositionEngineTest.cpp",
        "tests/DisplayTest.cpp",
        "tests/MockHWComposer.cpp",
    ],
    static_libs: [
+7 −0
Original line number Diff line number Diff line
@@ -28,6 +28,10 @@ class RenderEngine;

namespace compositionengine {

class Display;

struct DisplayCreationArgs;

/**
 * Encapsulates all the interfaces and implementation details for performing
 * display output composition.
@@ -36,6 +40,9 @@ class CompositionEngine {
public:
    virtual ~CompositionEngine();

    // Create a composition Display
    virtual std::shared_ptr<Display> createDisplay(DisplayCreationArgs&&) = 0;

    virtual HWComposer& getHwComposer() const = 0;
    virtual void setHwComposer(std::unique_ptr<HWComposer>) = 0;

+48 −0
Original line number Diff line number Diff line
/*
 * Copyright 2019 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.
 */

#pragma once

#include <cstdint>
#include <optional>

#include "DisplayHardware/DisplayIdentification.h"

namespace android::compositionengine {

/**
 * A display is a composition target which may be backed by a hardware composer
 * display device
 */
class Display {
public:
    // Gets the HWC DisplayId for the display if there is one
    virtual const std::optional<DisplayId>& getId() const = 0;

    // True if the display is secure
    virtual bool isSecure() const = 0;

    // True if the display is virtual
    virtual bool isVirtual() const = 0;

    // Releases the use of the HWC display, if any
    virtual void disconnect() = 0;

protected:
    ~Display() = default;
};

} // namespace android::compositionengine
+76 −0
Original line number Diff line number Diff line
/*
 * Copyright 2019 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.
 */

#pragma once

#include <cstdint>
#include <optional>

#include "DisplayHardware/DisplayIdentification.h"

namespace android::compositionengine {

class CompositionEngine;

/**
 * A parameter object for creating Display instances
 */
struct DisplayCreationArgs {
    // True if this display is secure
    bool isSecure = false;

    // True if this display is a virtual display
    bool isVirtual = false;

    // Identifies the display to the HWC, if composition is supported by it
    std::optional<DisplayId> displayId;
};

/**
 * A helper for setting up a DisplayCreationArgs value in-line.
 * Prefer this builder over raw structure initialization.
 *
 * Instead of:
 *
 *   DisplayCreationArgs{false, false, displayId}
 *
 * Prefer:
 *
 *  DisplayCreationArgsBuilder().setIsSecure(false).setIsVirtual(false)
 *      .setDisplayId(displayId).build();
 */
class DisplayCreationArgsBuilder {
public:
    DisplayCreationArgs build() { return std::move(mArgs); }

    DisplayCreationArgsBuilder& setIsSecure(bool isSecure) {
        mArgs.isSecure = isSecure;
        return *this;
    }
    DisplayCreationArgsBuilder& setIsVirtual(bool isVirtual) {
        mArgs.isVirtual = isVirtual;
        return *this;
    }
    DisplayCreationArgsBuilder& setDisplayId(std::optional<DisplayId> displayId) {
        mArgs.displayId = displayId;
        return *this;
    }

private:
    DisplayCreationArgs mArgs;
};

} // namespace android::compositionengine
+3 −0
Original line number Diff line number Diff line
@@ -25,6 +25,9 @@ public:
    CompositionEngine();
    ~CompositionEngine() override;

    std::shared_ptr<compositionengine::Display> createDisplay(
            compositionengine::DisplayCreationArgs&&) override;

    HWComposer& getHwComposer() const override;
    void setHwComposer(std::unique_ptr<HWComposer>) override;

Loading