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

Commit 88fa9327 authored by Leon Scroggins's avatar Leon Scroggins Committed by Automerger Merge Worker
Browse files

Merge "Improve printing of Display- and Layer- Settings" into tm-dev am: a1349142

parents 77ba9244 a1349142
Loading
Loading
Loading
Loading
+42 −5
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@
#include <iosfwd>
#include <iosfwd>


#include <math/mat4.h>
#include <math/mat4.h>
#include <renderengine/PrintMatrix.h>
#include <ui/GraphicTypes.h>
#include <ui/GraphicTypes.h>
#include <ui/Rect.h>
#include <ui/Rect.h>
#include <ui/Region.h>
#include <ui/Region.h>
@@ -82,11 +83,38 @@ struct DisplaySettings {


static inline bool operator==(const DisplaySettings& lhs, const DisplaySettings& rhs) {
static inline bool operator==(const DisplaySettings& lhs, const DisplaySettings& rhs) {
    return lhs.physicalDisplay == rhs.physicalDisplay && lhs.clip == rhs.clip &&
    return lhs.physicalDisplay == rhs.physicalDisplay && lhs.clip == rhs.clip &&
            lhs.maxLuminance == rhs.maxLuminance && lhs.outputDataspace == rhs.outputDataspace &&
            lhs.maxLuminance == rhs.maxLuminance &&
            lhs.colorTransform == rhs.colorTransform && lhs.orientation == rhs.orientation;
            lhs.currentLuminanceNits == rhs.currentLuminanceNits &&
            lhs.outputDataspace == rhs.outputDataspace &&
            lhs.colorTransform == rhs.colorTransform &&
            lhs.deviceHandlesColorTransform == rhs.deviceHandlesColorTransform &&
            lhs.orientation == rhs.orientation &&
            lhs.targetLuminanceNits == rhs.targetLuminanceNits &&
            lhs.dimmingStage == rhs.dimmingStage && lhs.renderIntent == rhs.renderIntent;
}

static const char* orientation_to_string(uint32_t orientation) {
    switch (orientation) {
        case ui::Transform::ROT_0:
            return "ROT_0";
        case ui::Transform::FLIP_H:
            return "FLIP_H";
        case ui::Transform::FLIP_V:
            return "FLIP_V";
        case ui::Transform::ROT_90:
            return "ROT_90";
        case ui::Transform::ROT_180:
            return "ROT_180";
        case ui::Transform::ROT_270:
            return "ROT_270";
        case ui::Transform::ROT_INVALID:
            return "ROT_INVALID";
        default:
            ALOGE("invalid orientation!");
            return "invalid orientation";
    }
}
}


// Defining PrintTo helps with Google Tests.
static inline void PrintTo(const DisplaySettings& settings, ::std::ostream* os) {
static inline void PrintTo(const DisplaySettings& settings, ::std::ostream* os) {
    *os << "DisplaySettings {";
    *os << "DisplaySettings {";
    *os << "\n    .physicalDisplay = ";
    *os << "\n    .physicalDisplay = ";
@@ -94,10 +122,19 @@ static inline void PrintTo(const DisplaySettings& settings, ::std::ostream* os)
    *os << "\n    .clip = ";
    *os << "\n    .clip = ";
    PrintTo(settings.clip, os);
    PrintTo(settings.clip, os);
    *os << "\n    .maxLuminance = " << settings.maxLuminance;
    *os << "\n    .maxLuminance = " << settings.maxLuminance;
    *os << "\n    .currentLuminanceNits = " << settings.currentLuminanceNits;
    *os << "\n    .outputDataspace = ";
    *os << "\n    .outputDataspace = ";
    PrintTo(settings.outputDataspace, os);
    PrintTo(settings.outputDataspace, os);
    *os << "\n    .colorTransform = " << settings.colorTransform;
    *os << "\n    .colorTransform = ";
    *os << "\n    .clearRegion = ";
    PrintMatrix(settings.colorTransform, os);
    *os << "\n    .deviceHandlesColorTransform = " << settings.deviceHandlesColorTransform;
    *os << "\n    .orientation = " << orientation_to_string(settings.orientation);
    *os << "\n    .targetLuminanceNits = " << settings.targetLuminanceNits;
    *os << "\n    .dimmingStage = "
        << aidl::android::hardware::graphics::composer3::toString(settings.dimmingStage).c_str();
    *os << "\n    .renderIntent = "
        << aidl::android::hardware::graphics::composer3::toString(settings.renderIntent).c_str();
    *os << "\n}";
}
}


} // namespace renderengine
} // namespace renderengine
+40 −18
Original line number Original line Diff line number Diff line
@@ -19,7 +19,9 @@
#include <math/mat4.h>
#include <math/mat4.h>
#include <math/vec3.h>
#include <math/vec3.h>
#include <renderengine/ExternalTexture.h>
#include <renderengine/ExternalTexture.h>
#include <renderengine/PrintMatrix.h>
#include <ui/BlurRegion.h>
#include <ui/BlurRegion.h>
#include <ui/DebugUtils.h>
#include <ui/Fence.h>
#include <ui/Fence.h>
#include <ui/FloatRect.h>
#include <ui/FloatRect.h>
#include <ui/GraphicBuffer.h>
#include <ui/GraphicBuffer.h>
@@ -208,6 +210,10 @@ static inline bool operator==(const ShadowSettings& lhs, const ShadowSettings& r
            lhs.casterIsTranslucent == rhs.casterIsTranslucent;
            lhs.casterIsTranslucent == rhs.casterIsTranslucent;
}
}


static inline bool operator!=(const ShadowSettings& lhs, const ShadowSettings& rhs) {
    return !(operator==(lhs, rhs));
}

static inline bool operator==(const LayerSettings& lhs, const LayerSettings& rhs) {
static inline bool operator==(const LayerSettings& lhs, const LayerSettings& rhs) {
    if (lhs.blurRegions.size() != rhs.blurRegions.size()) {
    if (lhs.blurRegions.size() != rhs.blurRegions.size()) {
        return false;
        return false;
@@ -226,18 +232,19 @@ static inline bool operator==(const LayerSettings& lhs, const LayerSettings& rhs
            lhs.skipContentDraw == rhs.skipContentDraw && lhs.shadow == rhs.shadow &&
            lhs.skipContentDraw == rhs.skipContentDraw && lhs.shadow == rhs.shadow &&
            lhs.backgroundBlurRadius == rhs.backgroundBlurRadius &&
            lhs.backgroundBlurRadius == rhs.backgroundBlurRadius &&
            lhs.blurRegionTransform == rhs.blurRegionTransform &&
            lhs.blurRegionTransform == rhs.blurRegionTransform &&
            lhs.stretchEffect == rhs.stretchEffect;
            lhs.stretchEffect == rhs.stretchEffect && lhs.whitePointNits == rhs.whitePointNits;
}
}


// Defining PrintTo helps with Google Tests.

static inline void PrintTo(const Buffer& settings, ::std::ostream* os) {
static inline void PrintTo(const Buffer& settings, ::std::ostream* os) {
    *os << "Buffer {";
    *os << "Buffer {";
    *os << "\n    .buffer = " << settings.buffer.get();
    *os << "\n    .buffer = " << settings.buffer.get() << " "
        << (settings.buffer.get() ? decodePixelFormat(settings.buffer->getPixelFormat()).c_str()
                                  : "");
    *os << "\n    .fence = " << settings.fence.get();
    *os << "\n    .fence = " << settings.fence.get();
    *os << "\n    .textureName = " << settings.textureName;
    *os << "\n    .textureName = " << settings.textureName;
    *os << "\n    .useTextureFiltering = " << settings.useTextureFiltering;
    *os << "\n    .useTextureFiltering = " << settings.useTextureFiltering;
    *os << "\n    .textureTransform = " << settings.textureTransform;
    *os << "\n    .textureTransform = ";
    PrintMatrix(settings.textureTransform, os);
    *os << "\n    .usePremultipliedAlpha = " << settings.usePremultipliedAlpha;
    *os << "\n    .usePremultipliedAlpha = " << settings.usePremultipliedAlpha;
    *os << "\n    .isOpaque = " << settings.isOpaque;
    *os << "\n    .isOpaque = " << settings.isOpaque;
    *os << "\n    .isY410BT2020 = " << settings.isY410BT2020;
    *os << "\n    .isY410BT2020 = " << settings.isY410BT2020;
@@ -249,7 +256,8 @@ static inline void PrintTo(const Geometry& settings, ::std::ostream* os) {
    *os << "Geometry {";
    *os << "Geometry {";
    *os << "\n    .boundaries = ";
    *os << "\n    .boundaries = ";
    PrintTo(settings.boundaries, os);
    PrintTo(settings.boundaries, os);
    *os << "\n    .positionTransform = " << settings.positionTransform;
    *os << "\n    .positionTransform = ";
    PrintMatrix(settings.positionTransform, os);
    *os << "\n    .roundedCornersRadius = " << settings.roundedCornersRadius;
    *os << "\n    .roundedCornersRadius = " << settings.roundedCornersRadius;
    *os << "\n    .roundedCornersCrop = ";
    *os << "\n    .roundedCornersCrop = ";
    PrintTo(settings.roundedCornersCrop, os);
    PrintTo(settings.roundedCornersCrop, os);
@@ -258,11 +266,15 @@ static inline void PrintTo(const Geometry& settings, ::std::ostream* os) {


static inline void PrintTo(const PixelSource& settings, ::std::ostream* os) {
static inline void PrintTo(const PixelSource& settings, ::std::ostream* os) {
    *os << "PixelSource {";
    *os << "PixelSource {";
    if (settings.buffer.buffer) {
        *os << "\n    .buffer = ";
        *os << "\n    .buffer = ";
        PrintTo(settings.buffer, os);
        PrintTo(settings.buffer, os);
        *os << "\n}";
    } else {
        *os << "\n    .solidColor = " << settings.solidColor;
        *os << "\n    .solidColor = " << settings.solidColor;
        *os << "\n}";
        *os << "\n}";
    }
    }
}


static inline void PrintTo(const ShadowSettings& settings, ::std::ostream* os) {
static inline void PrintTo(const ShadowSettings& settings, ::std::ostream* os) {
    *os << "ShadowSettings {";
    *os << "ShadowSettings {";
@@ -301,18 +313,28 @@ static inline void PrintTo(const LayerSettings& settings, ::std::ostream* os) {
    *os << "\n    .alpha = " << settings.alpha;
    *os << "\n    .alpha = " << settings.alpha;
    *os << "\n    .sourceDataspace = ";
    *os << "\n    .sourceDataspace = ";
    PrintTo(settings.sourceDataspace, os);
    PrintTo(settings.sourceDataspace, os);
    *os << "\n    .colorTransform = " << settings.colorTransform;
    *os << "\n    .colorTransform = ";
    PrintMatrix(settings.colorTransform, os);
    *os << "\n    .disableBlending = " << settings.disableBlending;
    *os << "\n    .disableBlending = " << settings.disableBlending;
    *os << "\n    .skipContentDraw = " << settings.skipContentDraw;
    *os << "\n    .skipContentDraw = " << settings.skipContentDraw;
    if (settings.shadow != ShadowSettings()) {
        *os << "\n    .shadow = ";
        PrintTo(settings.shadow, os);
    }
    *os << "\n    .backgroundBlurRadius = " << settings.backgroundBlurRadius;
    *os << "\n    .backgroundBlurRadius = " << settings.backgroundBlurRadius;
    if (settings.blurRegions.size()) {
        *os << "\n    .blurRegions =";
        for (auto blurRegion : settings.blurRegions) {
        for (auto blurRegion : settings.blurRegions) {
            *os << "\n";
            *os << "\n";
            PrintTo(blurRegion, os);
            PrintTo(blurRegion, os);
        }
        }
    *os << "\n    .shadow = ";
    }
    PrintTo(settings.shadow, os);
    *os << "\n    .blurRegionTransform = ";
    PrintMatrix(settings.blurRegionTransform, os);
    if (settings.stretchEffect != StretchEffect()) {
        *os << "\n    .stretchEffect = ";
        *os << "\n    .stretchEffect = ";
        PrintTo(settings.stretchEffect, os);
        PrintTo(settings.stretchEffect, os);
    }
    *os << "\n    .whitePointNits = " << settings.whitePointNits;
    *os << "\n    .whitePointNits = " << settings.whitePointNits;
    *os << "\n}";
    *os << "\n}";
}
}
+36 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright 2022 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 <math/mat4.h>
#include <iosfwd>

namespace android::renderengine {

// This method simplifies printing the identity matrix, so it can be easily
// skipped over visually.
inline void PrintMatrix(const mat4& matrix, ::std::ostream* os) {
    if (matrix == mat4()) {
        *os << "I";
    } else {
        // Print the matrix starting on a new line. This ensures that all lines
        // are aligned.
        *os << "\n" << matrix;
    }
}

} // namespace android::renderengine
+22 −9
Original line number Original line Diff line number Diff line
@@ -67,7 +67,7 @@
namespace {
namespace {
// Debugging settings
// Debugging settings
static const bool kPrintLayerSettings = false;
static const bool kPrintLayerSettings = false;
static const bool kFlushAfterEveryLayer = false;
static const bool kFlushAfterEveryLayer = kPrintLayerSettings;
} // namespace
} // namespace


bool checkGlError(const char* op, int lineNumber);
bool checkGlError(const char* op, int lineNumber);
@@ -740,6 +740,23 @@ static bool equalsWithinMargin(float expected, float value, float margin = kDefa
    return std::abs(expected - value) < margin;
    return std::abs(expected - value) < margin;
}
}


namespace {
template <typename T>
void logSettings(const T& t) {
    std::stringstream stream;
    PrintTo(t, &stream);
    auto string = stream.str();
    size_t pos = 0;
    // Perfetto ignores \n, so split up manually into separate ALOGD statements.
    const size_t size = string.size();
    while (pos < size) {
        const size_t end = std::min(string.find("\n", pos), size);
        ALOGD("%s", string.substr(pos, end - pos).c_str());
        pos = end + 1;
    }
}
} // namespace

void SkiaGLRenderEngine::drawLayersInternal(
void SkiaGLRenderEngine::drawLayersInternal(
        const std::shared_ptr<std::promise<RenderEngineResult>>&& resultPromise,
        const std::shared_ptr<std::promise<RenderEngineResult>>&& resultPromise,
        const DisplaySettings& display, const std::vector<LayerSettings>& layers,
        const DisplaySettings& display, const std::vector<LayerSettings>& layers,
@@ -849,18 +866,14 @@ void SkiaGLRenderEngine::drawLayersInternal(
    canvas->clear(SK_ColorTRANSPARENT);
    canvas->clear(SK_ColorTRANSPARENT);
    initCanvas(canvas, display);
    initCanvas(canvas, display);


    if (kPrintLayerSettings) {
        logSettings(display);
    }
    for (const auto& layer : layers) {
    for (const auto& layer : layers) {
        ATRACE_FORMAT("DrawLayer: %s", layer.name.c_str());
        ATRACE_FORMAT("DrawLayer: %s", layer.name.c_str());


        if (kPrintLayerSettings) {
        if (kPrintLayerSettings) {
            std::stringstream ls;
            logSettings(layer);
            PrintTo(layer, &ls);
            auto debugs = ls.str();
            int pos = 0;
            while (pos < debugs.size()) {
                ALOGD("cache_debug %s", debugs.substr(pos, 1000).c_str());
                pos += 1000;
            }
        }
        }


        sk_sp<SkImage> blurInput;
        sk_sp<SkImage> blurInput;
+2 −0
Original line number Original line Diff line number Diff line
@@ -29,6 +29,8 @@ cc_test {
    ],
    ],
    test_suites: ["device-tests"],
    test_suites: ["device-tests"],
    srcs: [
    srcs: [
        "DisplaySettingsTest.cpp",
        "LayerSettingsTest.cpp",
        "RenderEngineTest.cpp",
        "RenderEngineTest.cpp",
        "RenderEngineThreadedTest.cpp",
        "RenderEngineThreadedTest.cpp",
    ],
    ],
Loading