Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Android/device/device/generic/goldfish/hals/hwc3/     Datei vom 26.5.2026 mit Größe 4 kB image not shown  

Quelle:  Common.cpp  Sprache: C


/*
 * 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.
 */


#include "Common.h"

#include <android-base/properties.h>

namespace aidl::android::hardware::graphics::composer3::impl {

bool IsAutoDevice() {
    // gcar_emu_x86_64, sdk_car_md_x86_64, cf_x86_64_auto, cf_x86_64_only_auto_md
    const std::string product_name = ::android::base::GetProperty("ro.product.name", "");
    return product_name.find("car_") != std::string::npos ||
        product_name.find("_auto") != std::string::npos;
}

bool IsCuttlefish() { return ::android::base::GetProperty("ro.product.board", "") == "cutf"; }

bool IsCuttlefishFoldable() {
    return IsCuttlefish() && ::android::base::GetProperty("ro.product.name", "").find("foldable") !=
                                 std::string::npos;
}

bool IsInNoOpCompositionMode() {
    const std::string mode = ::android::base::GetProperty("ro.vendor.hwcomposer.mode", "");
    DEBUG_LOG("%s: sysprop ro.vendor.hwcomposer.mode is %s", __FUNCTION__, mode.c_str());
    return mode == "noop";
}

bool IsInClientCompositionMode() {
    const std::string mode = ::android::base::GetProperty("ro.vendor.hwcomposer.mode", "");
    DEBUG_LOG("%s: sysprop ro.vendor.hwcomposer.mode is %s", __FUNCTION__, mode.c_str());
    return mode == "client";
}

bool IsInGem5DisplayFinderMode() {
    const std::string mode =
        ::android::base::GetProperty("ro.vendor.hwcomposer.display_finder_mode", "");
    DEBUG_LOG("%s: sysprop ro.vendor.hwcomposer.display_finder_mode is %s", __FUNCTION__,
              mode.c_str());
    return mode == "gem5";
}

bool IsInNoOpDisplayFinderMode() {
    const std::string mode =
        ::android::base::GetProperty("ro.vendor.hwcomposer.display_finder_mode", "");
    DEBUG_LOG("%s: sysprop ro.vendor.hwcomposer.display_finder_mode is %s", __FUNCTION__,
              mode.c_str());
    return mode == "noop";
}

bool IsInDrmDisplayFinderMode() {
    const std::string mode =
        ::android::base::GetProperty("ro.vendor.hwcomposer.display_finder_mode", "");
    DEBUG_LOG("%s: sysprop ro.vendor.hwcomposer.display_finder_mode is %s", __FUNCTION__,
              mode.c_str());
    return mode == "drm";
}

std::string toString(HWC3::Error error) {
    switch (error) {
        case HWC3::Error::None:
            return "None";
        case HWC3::Error::BadConfig:
            return "BadConfig";
        case HWC3::Error::BadDisplay:
            return "BadDisplay";
        case HWC3::Error::BadLayer:
            return "BadLayer";
        case HWC3::Error::BadParameter:
            return "BadParameter";
        case HWC3::Error::NoResources:
            return "NoResources";
        case HWC3::Error::NotValidated:
            return "NotValidated";
        case HWC3::Error::Unsupported:
            return "Unsupported";
        case HWC3::Error::SeamlessNotAllowed:
            return "SeamlessNotAllowed";
    }
}

common::PixelFormat GetHostDisplayPixelFormat() {
    // The virtio gpu kernel module only supports the BGRA and BGRX formats
    // (see drivers/gpu/drm/virtio/virtgpu_display.c). Historically, Cuttlefish
    // maintained an out of tree patch (aosp/1106608) to allow using RGBA and
    // the Cuttlefish webrtc server treated all buffers as RGBA. In order to
    // not break older guests and to not break Goldfish which may not yet be
    // on virtio gpu, the format is configurable here.

    const std::string framebufferFormat =
        ::android::base::GetProperty(
            "ro.vendor.hwcomposer.display_framebuffer_format", "");

    if (framebufferFormat == "bgra") {
        return common::PixelFormat::BGRA_8888;
    }

    return common::PixelFormat::RGBA_8888;
}

}  // namespace aidl::android::hardware::graphics::composer3::impl

Messung
CHZG
899910096

¤ Dauer der Verarbeitung: 0.5 Sekunden  ¤

*© Formatika GbR, Deutschland