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

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

Add unit tests for planner's LayerState

Bug: 180639488
Test: libcompositionengine_test

Change-Id: I3660d58c0c8e17b5e9a6378e5c9a5ca5842f2cad
parent 9b24e29e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -105,6 +105,7 @@ cc_test {
    srcs: [
        "tests/planner/CachedSetTest.cpp",
        "tests/planner/FlattenerTest.cpp",
        "tests/planner/LayerStateTest.cpp",
        "tests/CompositionEngineTest.cpp",
        "tests/DisplayColorProfileTest.cpp",
        "tests/DisplayTest.cpp",
+6 −13
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ using LayerId = int32_t;

// clang-format off
enum class LayerStateField : uint32_t {
    None            = 0u,
    Id              = 1u << 0,
    Name            = 1u << 1,
    DisplayFrame    = 1u << 2,
@@ -173,8 +174,12 @@ public:
    // Returns which fields were updated
    Flags<LayerStateField> update(compositionengine::OutputLayer*);

    // Computes a hash for this LayerState.
    // The hash is only computed from NonUniqueFields.
    size_t getHash(Flags<LayerStateField> skipFields) const;

    // Returns the bit-set of differing fields between this LayerState and another LayerState.
    // This bit-set is based on NonUniqueFields only
    Flags<LayerStateField> getDifferingFields(const LayerState& other,
                                              Flags<LayerStateField> skipFields) const;

@@ -280,19 +285,7 @@ private:

    // Output-independent per-frame state

    OutputLayerState<mat4, LayerStateField::ColorTransform>
            mColorTransform{[](auto layer) {
                                const auto state = layer->getLayerFE().getCompositionState();
                                return state->colorTransformIsIdentity ? mat4{}
                                                                       : state->colorTransform;
                            },
                            [](const mat4& mat) {
                                using namespace std::string_literals;
                                std::vector<std::string> split =
                                        base::Split(std::string(mat.asString().string()), "\n"s);
                                split.pop_back(); // Strip the last (empty) line
                                return split;
                            }};
    OutputLayerState<mat4, LayerStateField::ColorTransform> mColorTransform;

    // TODO(b/180638831): Surface damage

+20 −1
Original line number Diff line number Diff line
@@ -16,9 +16,28 @@

#include <compositionengine/impl/planner/LayerState.h>

namespace {
extern "C" const char* __attribute__((unused)) __asan_default_options() {
    return "detect_container_overflow=0";
}
} // namespace

namespace android::compositionengine::impl::planner {

LayerState::LayerState(compositionengine::OutputLayer* layer) : mOutputLayer(layer) {
LayerState::LayerState(compositionengine::OutputLayer* layer)
      : mOutputLayer(layer),
        mColorTransform({[](auto layer) {
                             const auto state = layer->getLayerFE().getCompositionState();
                             return state->colorTransformIsIdentity ? mat4{}
                                                                    : state->colorTransform;
                         },
                         [](const mat4& mat) {
                             using namespace std::string_literals;
                             std::vector<std::string> split =
                                     base::Split(std::string(mat.asString().string()), "\n"s);
                             split.pop_back(); // Strip the last (empty) line
                             return split;
                         }}) {
    update(layer);
}

+1020 −0

File added.

Preview size limit exceeded, changes collapsed.