drm_hwcomposer: Move CalcPixOps into Backend
The CalcPixOps is used only for display validation which is implemented
in the generic backend.
Signed-off-by: Matvii Zorin <matvii.zorin@globallogic.com>
diff --git a/backend/Backend.cpp b/backend/Backend.cpp
index 9e9e2b9..80b22d4 100644
--- a/backend/Backend.cpp
+++ b/backend/Backend.cpp
@@ -49,7 +49,7 @@
for (std::pair<const uint32_t, DrmHwcTwo::HwcLayer *> &l : z_map_tmp)
z_map.emplace(std::make_pair(z_index++, l.second));
- uint32_t total_pixops = display->CalcPixOps(z_map, 0, z_map.size());
+ uint32_t total_pixops = CalcPixOps(z_map, 0, z_map.size());
uint32_t gpu_pixops = 0;
int client_start = -1;
@@ -82,7 +82,7 @@
gpu_pixops = INT_MAX;
for (int i = 0; i < steps; i++) {
- uint32_t po = display->CalcPixOps(z_map, start + i, client_size);
+ uint32_t po = CalcPixOps(z_map, start + i, client_size);
if (po < gpu_pixops) {
gpu_pixops = po;
client_start = start + i;
@@ -139,6 +139,18 @@
display->resource_manager()->ForcedScalingWithGpu());
}
+uint32_t Backend::CalcPixOps(const std::vector<DrmHwcTwo::HwcLayer *> &layers,
+ size_t first_z, size_t size) {
+ uint32_t pixops = 0;
+ for (auto & [ z_order, layer ] : z_map) {
+ if (z_order >= first_z && z_order < first_z + size) {
+ hwc_rect_t df = layer->display_frame();
+ pixops += (df.right - df.left) * (df.bottom - df.top);
+ }
+ }
+ return pixops;
+}
+
// clang-format off
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables, cert-err58-cpp)
REGISTER_BACKEND("generic", Backend);