Revert "hwc: rewrite supports_gscaler() to use libgscaler"
This reverts commit f3416d3fd62de43b5f15076957d94282e13b30ba.
diff --git a/libhwc/hwc.cpp b/libhwc/hwc.cpp
index 1d30a2e..dc748c8 100644
--- a/libhwc/hwc.cpp
+++ b/libhwc/hwc.cpp
@@ -304,32 +304,38 @@
{
private_handle_t *handle = private_handle_t::dynamicCast(layer.handle);
- exynos_gsc_img src_cfg, dst_cfg;
- src_cfg.x = layer.sourceCrop.left;
- src_cfg.y = layer.sourceCrop.top;
- src_cfg.w = WIDTH(layer.sourceCrop);
- src_cfg.h = HEIGHT(layer.sourceCrop);
- src_cfg.fw = handle->stride;
- src_cfg.fh = handle->vstride;
- src_cfg.format = format;
- dst_cfg.x = 0;
- dst_cfg.y = 0;
- dst_cfg.w = WIDTH(layer.displayFrame);
- dst_cfg.h = HEIGHT(layer.displayFrame);
- dst_cfg.format = HAL_PIXEL_FORMAT_BGRA_8888;
- dst_cfg.rot = layer.transform;
+ int max_w = is_rotated(layer) ? 2048 : 4800;
+ int max_h = is_rotated(layer) ? 2048 : 3344;
- if (!exynos5_format_is_supported_by_gscaler(format))
- return false;
+ bool rot90or270 = !!(layer.transform & HAL_TRANSFORM_ROT_90);
+ // n.b.: HAL_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_90 |
+ // HAL_TRANSFORM_ROT_180
- if (!exynos_gsc_cfg_valid(&src_cfg, &dst_cfg, local_path, false))
- return false;
+ int src_w = WIDTH(layer.sourceCrop), src_h = HEIGHT(layer.sourceCrop);
+ int dest_w, dest_h;
+ if (rot90or270) {
+ dest_w = HEIGHT(layer.displayFrame);
+ dest_h = WIDTH(layer.displayFrame);
+ } else {
+ dest_w = WIDTH(layer.displayFrame);
+ dest_h = HEIGHT(layer.displayFrame);
+ }
+ int max_downscale = local_path ? 4 : 16;
+ const int max_upscale = 8;
- if (exynos5_format_is_rgb(format) &&
- !exynos_gsc_cfg_aligned(&src_cfg, &dst_cfg))
- return false;
-
- return true;
+ return exynos5_format_is_supported_by_gscaler(format) &&
+ handle->stride <= max_w &&
+ handle->stride % GSC_W_ALIGNMENT == 0 &&
+ src_w <= dest_w * max_downscale &&
+ dest_w <= src_w * max_upscale &&
+ handle->vstride <= max_h &&
+ handle->vstride % GSC_H_ALIGNMENT == 0 &&
+ src_h <= dest_h * max_downscale &&
+ dest_h <= src_h * max_upscale &&
+ // per 46.2
+ (!rot90or270 || layer.sourceCrop.top % 2 == 0) &&
+ (!rot90or270 || layer.sourceCrop.left % 2 == 0);
+ // per 46.3.1.6
}
static bool exynos5_requires_gscaler(hwc_layer_1_t &layer, int format)