Skip to content

Commit

Permalink
fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ardera committed Sep 15, 2024
1 parent 606656c commit 2302b67
Show file tree
Hide file tree
Showing 24 changed files with 476 additions and 216 deletions.
17 changes: 7 additions & 10 deletions src/compositor_ng.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,9 @@ static int compositor_push_fl_layers(struct compositor *compositor, size_t n_fl_
/// TODO: Implement
layer->surface = compositor_get_view_by_id_locked(compositor, fl_layer->platform_view->identifier);
if (layer->surface == NULL) {
layer->surface =
CAST_SURFACE(dummy_render_surface_new(compositor->tracer, VEC2I(fl_layer->size.width, fl_layer->size.height)));
layer->surface = CAST_SURFACE(
dummy_render_surface_new(compositor->tracer, VEC2I((int) fl_layer->size.width, (int) fl_layer->size.height))
);
}
#else
// in release mode, we just assume the id is valid.
Expand Down Expand Up @@ -384,10 +385,6 @@ static int compositor_push_fl_layers(struct compositor *compositor, size_t n_fl_

fl_layer_composition_unref(composition);

return 0;

//fail_free_composition:
//fl_layer_composition_unref(composition);
return ok;
}

Expand Down Expand Up @@ -556,14 +553,14 @@ void compositor_set_cursor(

struct view_geometry viewgeo = window_get_view_geometry(compositor->main_window);

if (compositor->cursor_pos.x < 0.0f) {
compositor->cursor_pos.x = 0.0f;
if (compositor->cursor_pos.x < 0.0) {
compositor->cursor_pos.x = 0.0;
} else if (compositor->cursor_pos.x > viewgeo.view_size.x) {
compositor->cursor_pos.x = viewgeo.view_size.x;
}

if (compositor->cursor_pos.y < 0.0f) {
compositor->cursor_pos.y = 0.0f;
if (compositor->cursor_pos.y < 0.0) {
compositor->cursor_pos.y = 0.0;
} else if (compositor->cursor_pos.y > viewgeo.view_size.y) {
compositor->cursor_pos.y = viewgeo.view_size.y;
}
Expand Down
16 changes: 8 additions & 8 deletions src/cursor.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
#include "util/collection.h"
#include "util/geometry.h"

#define PIXEL_RATIO_LDPI 1.25
#define PIXEL_RATIO_MDPI 1.6666
#define PIXEL_RATIO_HDPI 2.5
#define PIXEL_RATIO_XHDPI 3.3333
#define PIXEL_RATIO_XXHDPI 5
#define PIXEL_RATIO_XXXHDPI 6.6666
#define PIXEL_RATIO_LDPI 1.25f
#define PIXEL_RATIO_MDPI 1.6666f
#define PIXEL_RATIO_HDPI 2.5f
#define PIXEL_RATIO_XHDPI 3.3333f
#define PIXEL_RATIO_XXHDPI 5.0f
#define PIXEL_RATIO_XXXHDPI 6.6666f

struct pointer_icon {
enum pointer_kind kind;
Expand Down Expand Up @@ -1450,7 +1450,7 @@ static void run_length_decode(void *image_buf, const void *rle_data, size_t size
}
}

const struct pointer_icon *pointer_icon_for_details(enum pointer_kind kind, double pixel_ratio) {
const struct pointer_icon *pointer_icon_for_details(enum pointer_kind kind, float pixel_ratio) {
const struct pointer_icon *best;

best = NULL;
Expand All @@ -1461,7 +1461,7 @@ const struct pointer_icon *pointer_icon_for_details(enum pointer_kind kind, doub
if (best == NULL) {
best = icon;
continue;
} else if (fabs(pixel_ratio - icon->pixel_ratio) < fabs(pixel_ratio - best->pixel_ratio)) {
} else if (fabsf(pixel_ratio - icon->pixel_ratio) < fabsf(pixel_ratio - best->pixel_ratio)) {
best = icon;
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/cursor.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ enum pointer_kind {

struct pointer_icon;

const struct pointer_icon *pointer_icon_for_details(enum pointer_kind kind, double pixel_ratio);
const struct pointer_icon *pointer_icon_for_details(enum pointer_kind kind, float pixel_ratio);

enum pointer_kind pointer_icon_get_kind(const struct pointer_icon *icon);

Expand Down
8 changes: 4 additions & 4 deletions src/dmabuf_surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,10 @@ static int dmabuf_surface_present_kms(struct surface *_s, const struct fl_layer_
.src_w = DOUBLE_TO_FP1616_ROUNDED(s->next_buf->buf.width),
.src_h = DOUBLE_TO_FP1616_ROUNDED(s->next_buf->buf.height),

.dst_x = props->aa_rect.offset.x,
.dst_y = props->aa_rect.offset.y,
.dst_w = props->aa_rect.size.x,
.dst_h = props->aa_rect.size.y,
.dst_x = (int) round(props->aa_rect.offset.x),
.dst_y = (int) round(props->aa_rect.offset.y),
.dst_w = (int) round(props->aa_rect.size.x),
.dst_h = (int) round(props->aa_rect.size.y),

.has_rotation = false,
.rotation = PLANE_TRANSFORM_ROTATE_0,
Expand Down
44 changes: 26 additions & 18 deletions src/egl_gbm_render_surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,8 @@ static void on_release_layer(void *userdata) {
static int egl_gbm_render_surface_present_kms(struct surface *s, const struct fl_layer_props *props, struct kms_req_builder *builder) {
struct egl_gbm_render_surface *egl_surface;
struct gbm_bo_meta *meta;
struct drmdev *drmdev;
struct gbm_bo *bo;
enum pixfmt pixel_format;
uint32_t fb_id, opaque_fb_id;
int ok;

egl_surface = CAST_THIS(s);
Expand All @@ -410,16 +408,18 @@ static int egl_gbm_render_surface_present_kms(struct surface *s, const struct fl
goto fail_unlock;
}

drmdev = kms_req_builder_get_drmdev(builder);
ASSERT_NOT_NULL(drmdev);
meta->drmdev = kms_req_builder_get_drmdev(builder);
ASSERT_NOT_NULL(meta->drmdev);

drmdev_ref(meta->drmdev);

struct drm_crtc *crtc = kms_req_builder_get_crtc(builder);
ASSERT_NOT_NULL(crtc);

if (drm_crtc_any_plane_supports_format(drmdev, crtc, egl_surface->pixel_format)) {
if (drm_crtc_any_plane_supports_format(meta->drmdev, crtc, egl_surface->pixel_format)) {
TRACER_BEGIN(egl_surface->surface.tracer, "drmdev_add_fb (non-opaque)");
fb_id = drmdev_add_fb_from_gbm_bo(
drmdev,
uint32_t fb_id = drmdev_add_fb_from_gbm_bo(
meta->drmdev,
bo,
/* cast_opaque */ false
);
Expand All @@ -428,7 +428,7 @@ static int egl_gbm_render_surface_present_kms(struct surface *s, const struct fl
if (fb_id == 0) {
ok = EIO;
LOG_ERROR("Couldn't add GBM buffer as DRM framebuffer.\n");
goto fail_free_meta;
goto fail_unref_drmdev;
}

meta->has_nonopaque_fb_id = true;
Expand All @@ -441,16 +441,16 @@ static int egl_gbm_render_surface_present_kms(struct surface *s, const struct fl
// if this EGL surface is non-opaque and has an opaque equivalent
if (!get_pixfmt_info(egl_surface->pixel_format)->is_opaque &&
pixfmt_opaque(egl_surface->pixel_format) != egl_surface->pixel_format &&
drm_crtc_any_plane_supports_format(drmdev, crtc, pixfmt_opaque(egl_surface->pixel_format))) {
opaque_fb_id = drmdev_add_fb_from_gbm_bo(
drmdev,
drm_crtc_any_plane_supports_format(meta->drmdev, crtc, pixfmt_opaque(egl_surface->pixel_format))) {
uint32_t opaque_fb_id = drmdev_add_fb_from_gbm_bo(
meta->drmdev,
bo,
/* cast_opaque */ true
);
if (opaque_fb_id == 0) {
ok = EIO;
LOG_ERROR("Couldn't add GBM buffer as opaque DRM framebuffer.\n");
goto fail_remove_fb;
goto fail_rm_nonopaque_fb;
}

meta->has_opaque_fb_id = true;
Expand All @@ -463,11 +463,9 @@ static int egl_gbm_render_surface_present_kms(struct surface *s, const struct fl
if (!meta->has_nonopaque_fb_id && !meta->has_opaque_fb_id) {
ok = EIO;
LOG_ERROR("Couldn't add GBM buffer as DRM framebuffer.\n");
goto fail_free_meta;
goto fail_remove_opaque_fb;
}

meta->drmdev = drmdev_ref(drmdev);
meta->nonopaque_fb_id = fb_id;
gbm_bo_set_user_data(bo, meta, on_destroy_gbm_bo_meta);
} else {
// We can only add this GBM BO to a single KMS device as an fb right now.
Expand All @@ -493,6 +491,8 @@ static int egl_gbm_render_surface_present_kms(struct surface *s, const struct fl
);
*/

uint32_t fb_id;

// So we just cast our fb to an XRGB8888 framebuffer and scanout that instead.
if (meta->has_nonopaque_fb_id && !meta->has_opaque_fb_id) {
fb_id = meta->nonopaque_fb_id;
Expand Down Expand Up @@ -555,10 +555,18 @@ static int egl_gbm_render_surface_present_kms(struct surface *s, const struct fl
locked_fb_unref(egl_surface->locked_front_fb);
goto fail_unlock;

fail_remove_fb:
drmdev_rm_fb(drmdev, fb_id);
fail_remove_opaque_fb:
if (meta->has_opaque_fb_id) {
drmdev_rm_fb(meta->drmdev, meta->opaque_fb_id);
}

fail_free_meta:
fail_rm_nonopaque_fb:
if (meta->has_nonopaque_fb_id) {
drmdev_rm_fb(meta->drmdev, meta->nonopaque_fb_id);
}

fail_unref_drmdev:
drmdev_unref(meta->drmdev);
free(meta);

fail_unlock:
Expand Down
9 changes: 5 additions & 4 deletions src/filesystem_layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,14 @@ static struct flutter_paths *resolve(
// We still haven't found it. Fail because we need it to run flutter.
if (path_exists(icudtl_path) == false) {
LOG_DEBUG("icudtl file not found at %s.\n", icudtl_path);
free(icudtl_path);

LOG_ERROR("icudtl file not found!\n");
goto fail_free_asset_bundle_path;
goto fail_free_icudtl_path;
}

// Find the kernel_blob.bin file. Only necessary for JIT (debug) mode.
ok = asprintf(&kernel_blob_path, "%s/%s", app_bundle_path_real, kernel_blob_subpath);
if (ok == -1) {
goto fail_free_asset_bundle_path;
goto fail_free_icudtl_path;
}

if (FLUTTER_RUNTIME_MODE_IS_JIT(runtime_mode) && !path_exists(kernel_blob_path)) {
Expand Down Expand Up @@ -222,6 +220,9 @@ static struct flutter_paths *resolve(
fail_free_kernel_blob_path:
free(kernel_blob_path);

fail_free_icudtl_path:
free(icudtl_path);

fail_free_asset_bundle_path:
free(asset_bundle_path);

Expand Down
Loading

0 comments on commit 2302b67

Please sign in to comment.