From 0c517a0a0fe881a396e6e45ad4cf0f3cff0ab686 Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Tue, 30 Jul 2024 16:32:38 +0900 Subject: [PATCH] Use e_surface and e_comp_wl_buffer APIs instead of accessing variables Change-Id: I90d20e5c77a0792c7132a1899d305c0ef3621b62 --- src/bin/compmgr/e_comp_object.c | 24 ++++----- src/bin/server/e_comp_wl.c | 94 +++++++++++++++++++++------------ src/bin/server/e_comp_wl_video_buffer.c | 13 +++-- src/bin/server/e_video_shell.c | 1 + 4 files changed, 81 insertions(+), 51 deletions(-) diff --git a/src/bin/compmgr/e_comp_object.c b/src/bin/compmgr/e_comp_object.c index 7c4522c..bcaa731 100644 --- a/src/bin/compmgr/e_comp_object.c +++ b/src/bin/compmgr/e_comp_object.c @@ -15,6 +15,7 @@ #include "e_zone_intern.h" #include "e_theme_intern.h" #include "e_config_intern.h" +#include "e_compositor_intern.h" /* data keys: @@ -488,21 +489,17 @@ _e_comp_object_alpha_set(E_Comp_Object *cw) static void _e_comp_object_map_transform_pos(E_Client *ec, int sx, int sy, int *dx, int *dy) { - E_Comp_Wl_Buffer_Viewport *vp; - E_Comp_Wl_Client_Data *cdata; + E_Surface *surface; int transform; int bw, bh, tx, ty; - cdata = e_client_cdata_get(ec); - - if (!ec || !cdata || e_object_is_del(E_OBJECT(ec))) + if (!ec || e_object_is_del(E_OBJECT(ec)) || !(surface = e_surface_try_from_ec(ec))) { *dx = sx; *dy = sy; return; } - vp = &cdata->scaler.buffer_viewport; transform = e_comp_wl_output_buffer_transform_get(ec); e_pixmap_size_get(ec->pixmap, &bw, &bh); @@ -531,8 +528,8 @@ _e_comp_object_map_transform_pos(E_Client *ec, int sx, int sy, int *dx, int *dy) case WL_OUTPUT_TRANSFORM_FLIPPED_270: tx = bh - sy, ty = bw - sx; break; } - tx *= vp->buffer.scale; - ty *= vp->buffer.scale; + tx *= e_surface_buffer_scale_get(surface); + ty *= e_surface_buffer_scale_get(surface); *dx = tx; *dy = ty; @@ -5330,7 +5327,7 @@ e_comp_object_map_update(Evas_Object *obj) { API_ENTRY; E_Client *ec = cw->ec; - E_Comp_Wl_Client_Data *cdata; + E_Surface *surface; E_Map *map; int x1, y1, x2, y2, x, y, bw, bh, tw, th; char buffer[128]; @@ -5339,18 +5336,19 @@ e_comp_object_map_update(Evas_Object *obj) if (!ec) return; if (e_object_is_del(E_OBJECT(ec))) return; - cdata = e_client_cdata_get(ec); - if (!cdata) return; + + surface = e_surface_try_from_ec(ec); + if (!surface) return; /* if buffer had been flushed, buffer could be NULL. Then map will be applied * when new buffer is attached. */ - if (!cdata->buffer_ref.buffer) return; + if (!e_surface_has_buffer(surface)) return; if ((!cw->redirected) || (e_client_video_hw_composition_check(ec)) || (!e_comp_wl_output_buffer_transform_get(ec) && - cdata->scaler.buffer_viewport.buffer.scale == 1)) + e_surface_buffer_scale_get(surface) == 1)) { if (evas_object_map_enable_get(cw->effect_obj)) { diff --git a/src/bin/server/e_comp_wl.c b/src/bin/server/e_comp_wl.c index 24d0216..2f892f4 100644 --- a/src/bin/server/e_comp_wl.c +++ b/src/bin/server/e_comp_wl.c @@ -48,6 +48,7 @@ #include #include +#include #include #include #include @@ -404,35 +405,39 @@ _e_comp_wl_cb_awake(void *data) E_API enum wl_output_transform e_comp_wl_output_buffer_transform_get(E_Client *ec) { - E_Comp_Wl_Buffer_Viewport *vp; + E_Surface *surface; E_Comp_Wl_Buffer *buffer; - enum wl_output_transform transform, rotation; + enum wl_output_transform buffer_transform, transform, rotation; if (!ec) return WL_OUTPUT_TRANSFORM_NORMAL; if (e_object_is_del(E_OBJECT(ec))) return WL_OUTPUT_TRANSFORM_NORMAL; - if (!ec->comp_data) return WL_OUTPUT_TRANSFORM_NORMAL; - vp = &ec->comp_data->scaler.buffer_viewport; + surface = e_surface_try_from_ec(ec); + if (!surface) + return WL_OUTPUT_TRANSFORM_NORMAL; + + buffer_transform = e_surface_buffer_transform_get(surface); + if (e_comp_wl_subsurface_check(ec)) - return vp->buffer.transform; + return buffer_transform; - buffer = ec->comp_data->buffer_ref.buffer; + buffer = e_surface_buffer_try_get(surface); if (!buffer || (buffer->type != E_COMP_WL_BUFFER_TYPE_NATIVE && buffer->type != E_COMP_WL_BUFFER_TYPE_TBM)) - return vp->buffer.transform; + return buffer_transform; rotation = buffer->transform; if (rotation == 0) - return vp->buffer.transform; + return buffer_transform; /* ignore the flip value when calculating transform because the screen rotation * functionality doesn't consider the flip output transform currently */ - transform = (4 + (vp->buffer.transform & 0x3) - rotation) & 0x3; + transform = (4 + (buffer_transform & 0x3) - rotation) & 0x3; DBG("ec(%p) window rotation(%d) buffer_transform(%d) : transform(%d)", - ec, rotation, vp->buffer.transform, transform); + ec, rotation, buffer_transform, transform); return transform; } @@ -476,9 +481,10 @@ e_comp_wl_output_pending_buffer_transform_get(E_Client *ec) E_API void e_comp_wl_map_size_cal_from_buffer(E_Client *ec) { - E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport; + E_Surface *surface = e_surface_from_ec(ec); E_Comp_Wl_Buffer *buffer; int32_t width, height; + int32_t scale; buffer = e_pixmap_resource_get(ec->pixmap); if (!buffer) @@ -488,18 +494,19 @@ e_comp_wl_map_size_cal_from_buffer(E_Client *ec) return; } + scale = e_surface_buffer_scale_get(surface); switch (e_comp_wl_output_buffer_transform_get(ec)) { case WL_OUTPUT_TRANSFORM_90: case WL_OUTPUT_TRANSFORM_270: case WL_OUTPUT_TRANSFORM_FLIPPED_90: case WL_OUTPUT_TRANSFORM_FLIPPED_270: - width = buffer->h / vp->buffer.scale; - height = buffer->w / vp->buffer.scale; + width = buffer->h / scale; + height = buffer->w / scale; break; default: - width = buffer->w / vp->buffer.scale; - height = buffer->h / vp->buffer.scale; + width = buffer->w / scale; + height = buffer->h / scale; break; } @@ -2902,17 +2909,20 @@ _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state) /* put state damages into surface */ if (view_client) { + E_Surface *surface = e_surface_from_ec(ec); + /* FIXME: workaround for bad wayland egl driver which doesn't send damage request */ if (!eina_list_count(state->damages) && !eina_list_count(state->buffer_damages)) { - if ((cdata->buffer_ref.buffer) && - ((cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_NATIVE) || - (cdata->buffer_ref.buffer->type == E_COMP_WL_BUFFER_TYPE_TBM))) + E_Comp_Wl_Buffer *comp_buffer = e_surface_buffer_try_get(surface); + if ((comp_buffer) && + ((comp_buffer->type == E_COMP_WL_BUFFER_TYPE_NATIVE) || + (comp_buffer->type == E_COMP_WL_BUFFER_TYPE_TBM))) { - e_view_client_damage(view_client, - 0, 0, - cdata->buffer_ref.buffer->w, - cdata->buffer_ref.buffer->h); + int32_t bw, bh; + + e_comp_wl_buffer_size_get(comp_buffer, &bw, &bh); + e_view_client_damage(view_client, 0, 0, bw, bh); } } else @@ -2927,11 +2937,16 @@ _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state) EINA_LIST_FREE(state->buffer_damages, dmg) { if (buffer) - e_comp_wl_rect_convert_inverse(buffer->w, buffer->h, - e_comp_wl_output_buffer_transform_get(ec), - vp->buffer.scale, - dmg->x, dmg->y, dmg->w, dmg->h, - &dmg->x, &dmg->y, &dmg->w, &dmg->h); + { + int32_t bw, bh; + + e_comp_wl_buffer_size_get(buffer, &bw, &bh); + e_comp_wl_rect_convert_inverse(bw, bh, + e_comp_wl_output_buffer_transform_get(ec), + e_surface_buffer_scale_get(surface), + dmg->x, dmg->y, dmg->w, dmg->h, + &dmg->x, &dmg->y, &dmg->w, &dmg->h); + } damages = eina_list_append(damages, dmg); } } @@ -4253,10 +4268,14 @@ e_comp_wl_aux_hint_changed_get(E_Client *ec) E_API E_Comp_Wl_Buffer * e_comp_wl_buffer_ref_buffer_get(E_Client *ec) { + E_Surface *surface; + EINA_SAFETY_ON_NULL_RETURN_VAL(ec, NULL); - EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, NULL); - return ec->comp_data->buffer_ref.buffer; + surface = e_surface_try_from_ec(ec); + EINA_SAFETY_ON_NULL_RETURN_VAL(surface, NULL); + + return e_surface_buffer_try_get(surface); } E_API void @@ -4334,10 +4353,14 @@ e_comp_wl_scaler_buffer_viewport_get(E_Client *ec) E_API int32_t e_comp_wl_scaler_buffer_viewport_buffer_scale_get(E_Client *ec) { + E_Surface *surface; + EINA_SAFETY_ON_NULL_RETURN_VAL(ec, 0); - EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, 0); - return ec->comp_data->scaler.buffer_viewport.buffer.scale; + surface = e_surface_try_from_ec(ec); + EINA_SAFETY_ON_NULL_RETURN_VAL(surface, 0); + + return e_surface_buffer_scale_get(surface); } E_API void @@ -5989,25 +6012,30 @@ e_comp_wl_surface_viewport_get(E_Client *ec, Eina_Rectangle *buffer_viewport, Ei E_Comp_Wl_Buffer *buffer; E_Comp_Wl_Buffer_Viewport *vp; E_Map *m; + E_Surface *surface; enum wl_output_transform buffer_transform; unsigned int rotation; Eina_Bool res = EINA_FALSE; + int32_t bw, bh; EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE); if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE; + surface = e_surface_from_ec(ec); + vp = &ec->comp_data->scaler.buffer_viewport; if (buffer_viewport) { - buffer = ec->comp_data->buffer_ref.buffer; + buffer = e_surface_buffer_try_get(surface); /* Getting a viewport of buffer needs geometry of buffer. */ if (!buffer) return EINA_FALSE; - _buffer_viewport_get(vp, buffer->w, buffer->h, buffer_viewport); + e_comp_wl_buffer_size_get(buffer, &bw, &bh); + _buffer_viewport_get(vp, bw, bh, buffer_viewport); } if ((output_viewport) || (transform)) diff --git a/src/bin/server/e_comp_wl_video_buffer.c b/src/bin/server/e_comp_wl_video_buffer.c index a5d0422..59585f3 100644 --- a/src/bin/server/e_comp_wl_video_buffer.c +++ b/src/bin/server/e_comp_wl_video_buffer.c @@ -1,4 +1,5 @@ #include "e_comp_wl_video_buffer_intern.h" +#include "e_compositor_intern.h" #include "e_util_video_intern.h" #include @@ -927,8 +928,9 @@ EINTERN void e_comp_wl_video_buffer_transform_scale_size_get(E_Client *ec, int *bw, int *bh) { E_Comp_Wl_Buffer *buffer = e_pixmap_resource_get(ec->pixmap); - E_Comp_Wl_Buffer_Viewport *vp = &ec->comp_data->scaler.buffer_viewport; + E_Surface *surface = e_surface_from_ec(ec); int w, h, transform; + int32_t scale; if (bw) *bw = 0; if (bh) *bh = 0; @@ -956,18 +958,19 @@ e_comp_wl_video_buffer_transform_scale_size_get(E_Client *ec, int *bw, int *bh) transform = e_comp_wl_output_buffer_transform_get(ec); + scale = e_surface_buffer_scale_get(surface); switch (transform) { case WL_OUTPUT_TRANSFORM_90: case WL_OUTPUT_TRANSFORM_270: case WL_OUTPUT_TRANSFORM_FLIPPED_90: case WL_OUTPUT_TRANSFORM_FLIPPED_270: - if (bw) *bw = h / vp->buffer.scale; - if (bh) *bh = w / vp->buffer.scale; + if (bw) *bw = h / scale; + if (bh) *bh = w / scale; break; default: - if (bw) *bw = w / vp->buffer.scale; - if (bh) *bh = h / vp->buffer.scale; + if (bw) *bw = w / scale; + if (bh) *bh = h / scale; break; } } diff --git a/src/bin/server/e_video_shell.c b/src/bin/server/e_video_shell.c index 37cf64d..be059ae 100644 --- a/src/bin/server/e_video_shell.c +++ b/src/bin/server/e_video_shell.c @@ -7,6 +7,7 @@ #include "e_compositor_intern.h" #include "e_comp_wl_shell_intern.h" #include "e_comp_object_intern.h" +#include "e_comp_wl_buffer_intern.h" #include "e_desk_intern.h" #include "e_comp_wl_subsurface_intern.h" #include "e_view_intern.h" -- 2.7.4