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

Commit 7909a89b authored by Yiwei Zhang's avatar Yiwei Zhang Committed by Android (Google) Code Review
Browse files

Merge "Implement Display Layer Stats V0.1"

parents 24b1ea12 60d1a193
Loading
Loading
Loading
Loading
+27 −0
Original line number Original line Diff line number Diff line
@@ -234,6 +234,33 @@ std::string decodeColorMode(ColorMode colorMode) {
    return android::base::StringPrintf("Unknown color mode %d", colorMode);
    return android::base::StringPrintf("Unknown color mode %d", colorMode);
}
}


std::string decodeColorTransform(android_color_transform colorTransform) {
    switch (colorTransform) {
        case HAL_COLOR_TRANSFORM_IDENTITY:
            return std::string("Identity");

        case HAL_COLOR_TRANSFORM_ARBITRARY_MATRIX:
            return std::string("Arbitrary matrix");

        case HAL_COLOR_TRANSFORM_VALUE_INVERSE:
            return std::string("Inverse value");

        case HAL_COLOR_TRANSFORM_GRAYSCALE:
            return std::string("Grayscale");

        case HAL_COLOR_TRANSFORM_CORRECT_PROTANOPIA:
            return std::string("Correct protanopia");

        case HAL_COLOR_TRANSFORM_CORRECT_DEUTERANOPIA:
            return std::string("Correct deuteranopia");

        case HAL_COLOR_TRANSFORM_CORRECT_TRITANOPIA:
            return std::string("Correct tritanopia");
    }

    return android::base::StringPrintf("Unknown color transform %d", colorTransform);
}

// Converts a PixelFormat to a human-readable string.  Max 11 chars.
// Converts a PixelFormat to a human-readable string.  Max 11 chars.
// (Could use a table of prefab String8 objects.)
// (Could use a table of prefab String8 objects.)
std::string decodePixelFormat(android::PixelFormat format) {
std::string decodePixelFormat(android::PixelFormat format) {
+1 −0
Original line number Original line Diff line number Diff line
@@ -30,5 +30,6 @@ std::string decodeTransfer(android_dataspace dataspace);
std::string decodeRange(android_dataspace dataspace);
std::string decodeRange(android_dataspace dataspace);
std::string dataspaceDetails(android_dataspace dataspace);
std::string dataspaceDetails(android_dataspace dataspace);
std::string decodeColorMode(android::ColorMode colormode);
std::string decodeColorMode(android::ColorMode colormode);
std::string decodeColorTransform(android_color_transform colorTransform);
std::string decodePixelFormat(android::PixelFormat format);
std::string decodePixelFormat(android::PixelFormat format);
std::string to_string(const android::Rect& rect);
std::string to_string(const android::Rect& rect);
+11 −0
Original line number Original line Diff line number Diff line
@@ -98,6 +98,7 @@ DisplayDevice::DisplayDevice(
      mPowerMode(initialPowerMode),
      mPowerMode(initialPowerMode),
      mActiveConfig(0),
      mActiveConfig(0),
      mActiveColorMode(ColorMode::NATIVE),
      mActiveColorMode(ColorMode::NATIVE),
      mColorTransform(HAL_COLOR_TRANSFORM_IDENTITY),
      mDisplayHasWideColor(supportWideColor),
      mDisplayHasWideColor(supportWideColor),
      mDisplayHasHdr(supportHdr)
      mDisplayHasHdr(supportHdr)
{
{
@@ -268,6 +269,16 @@ ColorMode DisplayDevice::getActiveColorMode() const {
    return mActiveColorMode;
    return mActiveColorMode;
}
}


void DisplayDevice::setColorTransform(const mat4& transform) {
    const bool isIdentity = (transform == mat4());
    mColorTransform =
            isIdentity ? HAL_COLOR_TRANSFORM_IDENTITY : HAL_COLOR_TRANSFORM_ARBITRARY_MATRIX;
}

android_color_transform_t DisplayDevice::getColorTransform() const {
    return mColorTransform;
}

void DisplayDevice::setCompositionDataSpace(android_dataspace dataspace) {
void DisplayDevice::setCompositionDataSpace(android_dataspace dataspace) {
    ANativeWindow* const window = mNativeWindow.get();
    ANativeWindow* const window = mNativeWindow.get();
    native_window_set_buffers_data_space(window, dataspace);
    native_window_set_buffers_data_space(window, dataspace);
+6 −0
Original line number Original line Diff line number Diff line
@@ -21,6 +21,8 @@


#include <stdlib.h>
#include <stdlib.h>


#include <math/mat4.h>

#include <ui/Region.h>
#include <ui/Region.h>


#include <binder/IBinder.h>
#include <binder/IBinder.h>
@@ -163,6 +165,8 @@ public:


    ColorMode getActiveColorMode() const;
    ColorMode getActiveColorMode() const;
    void setActiveColorMode(ColorMode mode);
    void setActiveColorMode(ColorMode mode);
    android_color_transform_t getColorTransform() const;
    void setColorTransform(const mat4& transform);
    void setCompositionDataSpace(android_dataspace dataspace);
    void setCompositionDataSpace(android_dataspace dataspace);


    /* ------------------------------------------------------------------------
    /* ------------------------------------------------------------------------
@@ -237,6 +241,8 @@ private:
    int mActiveConfig;
    int mActiveConfig;
    // current active color mode
    // current active color mode
    ColorMode mActiveColorMode;
    ColorMode mActiveColorMode;
    // Current color transform
    android_color_transform_t mColorTransform;


    // Need to know if display is wide-color capable or not.
    // Need to know if display is wide-color capable or not.
    // Initialized by SurfaceFlinger when the DisplayDevice is created.
    // Initialized by SurfaceFlinger when the DisplayDevice is created.
+11 −0
Original line number Original line Diff line number Diff line
@@ -42,6 +42,7 @@
#include <gui/LayerDebugInfo.h>
#include <gui/LayerDebugInfo.h>
#include <gui/Surface.h>
#include <gui/Surface.h>


#include "BufferLayer.h"
#include "Colorizer.h"
#include "Colorizer.h"
#include "DisplayDevice.h"
#include "DisplayDevice.h"
#include "Layer.h"
#include "Layer.h"
@@ -1929,6 +1930,16 @@ void Layer::writeToProto(LayerProto* layerInfo, int32_t hwcId) {


    const int32_t transform = static_cast<int32_t>(hwcInfo.transform);
    const int32_t transform = static_cast<int32_t>(hwcInfo.transform);
    layerInfo->set_hwc_transform(transform);
    layerInfo->set_hwc_transform(transform);

    const int32_t compositionType = static_cast<int32_t>(hwcInfo.compositionType);
    layerInfo->set_hwc_composition_type(compositionType);

    if (std::strcmp(getTypeId(), "BufferLayer") == 0 &&
        static_cast<BufferLayer*>(this)->isProtected()) {
        layerInfo->set_is_protected(true);
    } else {
        layerInfo->set_is_protected(false);
    }
}
}


// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
Loading