Add FlattenReason to Backend
This change adds a new enum FlattenReason which describes possible reasons that a given composition would be flattened. The flatten reason is now returned with the ValidationComposition. Change-Id: Ia7ba2ffbdc3512fea9cb19ab6be63a99eaa3f367
This commit is contained in:
parent
9a76e062b6
commit
8ec71d2657
3 changed files with 33 additions and 15 deletions
|
|
@ -17,12 +17,13 @@
|
|||
|
||||
#include "Backend.h"
|
||||
|
||||
#include <climits>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
#include "BackendManager.h"
|
||||
#include "bufferinfo/BufferInfoGetter.h"
|
||||
#include "drm/DrmHwc.h"
|
||||
#include "compositor/LayerData.h"
|
||||
#include "hwc/HwcDisplay.h"
|
||||
#include "hwc/HwcLayer.h"
|
||||
|
||||
namespace android::drm_hwcomposer {
|
||||
|
||||
|
|
@ -43,14 +44,12 @@ const HwcLayer* GetCursorLayer(const std::vector<const HwcLayer*>& layers) {
|
|||
} // namespace
|
||||
|
||||
auto Backend::ValidateDisplay(HwcDisplay* display) -> ValidatedComposition {
|
||||
auto layers = display->GetOrderLayersByZPos();
|
||||
const auto layers = display->GetOrderLayersByZPos();
|
||||
|
||||
const FlatteningController* flatcon = display->GetFlatCon();
|
||||
if (flatcon != nullptr) {
|
||||
if (flatcon->ShouldFlatten()) {
|
||||
display->total_stats().frames_flattened++;
|
||||
return GetFlattenedComposition(layers);
|
||||
}
|
||||
if (flatcon != nullptr && flatcon->ShouldFlatten()) {
|
||||
display->total_stats().frames_flattened++;
|
||||
return GetFlattenedComposition(layers, FlattenReason::kStaticScene);
|
||||
}
|
||||
|
||||
bool use_cursor_plane = false;
|
||||
|
|
@ -69,7 +68,7 @@ auto Backend::ValidateDisplay(HwcDisplay* display) -> ValidatedComposition {
|
|||
|
||||
size_t client_start = 0;
|
||||
size_t client_size = 0;
|
||||
ValidatedComposition validated_composition;
|
||||
ValidatedComposition validated_composition{};
|
||||
|
||||
// Populates and tests |validated_composition|, returning whether it
|
||||
// succeeded.
|
||||
|
|
@ -115,7 +114,11 @@ auto Backend::ValidateDisplay(HwcDisplay* display) -> ValidatedComposition {
|
|||
++display->total_stats().failed_kms_cursor_validate;
|
||||
}
|
||||
use_cursor_plane = false;
|
||||
validated_composition = GetFlattenedComposition(layers);
|
||||
validated_composition = GetFlattenedComposition(layers,
|
||||
FlattenReason::
|
||||
kValidateFailed);
|
||||
} else if (display->CtmByGpu()) {
|
||||
validated_composition.flatten_reason = FlattenReason::kCtmWithOffset;
|
||||
}
|
||||
|
||||
display->total_stats().gpu_pixops += CalcPixOps(validated_composition);
|
||||
|
|
@ -127,10 +130,11 @@ auto Backend::ValidateDisplay(HwcDisplay* display) -> ValidatedComposition {
|
|||
}
|
||||
|
||||
Backend::ValidatedComposition Backend::GetFlattenedComposition(
|
||||
const std::vector<const HwcLayer*>& layers) {
|
||||
const std::vector<const HwcLayer*>& layers, FlattenReason flatten_reason) {
|
||||
return ValidatedComposition{
|
||||
.composition_types = GetCompositionTypes(layers, 0, layers.size(), false),
|
||||
.composition_plan = nullptr};
|
||||
.composition_plan = nullptr,
|
||||
.flatten_reason = flatten_reason};
|
||||
}
|
||||
|
||||
std::tuple<size_t, size_t> Backend::GetClientLayers(
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
#include "compositor/LayerData.h"
|
||||
|
|
@ -32,6 +34,15 @@ class Backend {
|
|||
// Mapping of the CompositionType that the Backend assigned to each
|
||||
// HwcLayer.
|
||||
using CompositionTypeMap = std::map<const HwcLayer*, CompositionType>;
|
||||
// Enum of possible reasons that the backend may choose to flatten the
|
||||
// composition.
|
||||
enum class FlattenReason {
|
||||
kUnspecified = 0,
|
||||
kNone,
|
||||
kStaticScene,
|
||||
kValidateFailed,
|
||||
kCtmWithOffset,
|
||||
};
|
||||
struct ValidatedComposition {
|
||||
// The resulting composition type for each layer.
|
||||
CompositionTypeMap composition_types{};
|
||||
|
|
@ -40,6 +51,8 @@ class Backend {
|
|||
// for use by this display. As such, the caller must ensure that the
|
||||
// DrmKmsPlan is not destructed before the composition is committed.
|
||||
std::shared_ptr<DrmKmsPlan> composition_plan = nullptr;
|
||||
// Reason the composition was flattened, or |kNone| if it wasn't.
|
||||
FlattenReason flatten_reason = FlattenReason::kNone;
|
||||
};
|
||||
|
||||
virtual ~Backend() = default;
|
||||
|
|
@ -51,7 +64,7 @@ class Backend {
|
|||
|
||||
protected:
|
||||
static ValidatedComposition GetFlattenedComposition(
|
||||
const std::vector<const HwcLayer*>& layers);
|
||||
const std::vector<const HwcLayer*>& layers, FlattenReason flatten_reason);
|
||||
static bool HardwareSupportsLayerType(CompositionType comp_type);
|
||||
static uint32_t CalcPixOps(const ValidatedComposition& validated_composition);
|
||||
static uint32_t CalcPixOps(const std::vector<const HwcLayer*>& layers,
|
||||
|
|
|
|||
|
|
@ -23,7 +23,8 @@ namespace android::drm_hwcomposer {
|
|||
|
||||
auto BackendClient::ValidateDisplay(HwcDisplay* display)
|
||||
-> ValidatedComposition {
|
||||
return GetFlattenedComposition(display->GetOrderLayersByZPos());
|
||||
return GetFlattenedComposition(display->GetOrderLayersByZPos(),
|
||||
FlattenReason::kNone);
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue