[waffle] [PATCH 02/13] egl: inline wegl_context_{init, teardown}() in the respective callers
Emil Velikov
emil.l.velikov at gmail.com
Mon May 16 10:54:38 UTC 2016
From: Emil Velikov <emil.velikov at collabora.com>
Seems like an overkill to keep them separate considering the caller and
callee are just a single function call.
Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
src/waffle/egl/wegl_context.c | 75 +++++++++++++++----------------------------
src/waffle/egl/wegl_context.h | 8 -----
2 files changed, 25 insertions(+), 58 deletions(-)
diff --git a/src/waffle/egl/wegl_context.c b/src/waffle/egl/wegl_context.c
index 0e59231..41334eb 100644
--- a/src/waffle/egl/wegl_context.c
+++ b/src/waffle/egl/wegl_context.c
@@ -177,15 +177,22 @@ create_real_context(struct wegl_config *config,
return ctx;
}
-bool
-wegl_context_init(struct wegl_context *ctx,
- struct wcore_config *wc_config,
- struct wcore_context *wc_share_ctx)
+struct wcore_context*
+wegl_context_create(struct wcore_platform *wc_plat,
+ struct wcore_config *wc_config,
+ struct wcore_context *wc_share_ctx)
{
+ struct wegl_context *ctx;
struct wegl_config *config = wegl_config(wc_config);
struct wegl_context *share_ctx = wegl_context(wc_share_ctx);
bool ok;
+ (void) wc_plat;
+
+ ctx = wcore_calloc(sizeof(*ctx));
+ if (!ctx)
+ return NULL;
+
ok = wcore_context_init(&ctx->wcore, &config->wcore);
if (!ok)
goto fail;
@@ -197,64 +204,32 @@ wegl_context_init(struct wegl_context *ctx,
if (ctx->egl == EGL_NO_CONTEXT)
goto fail;
- return true;
+ return &ctx->wcore;
fail:
- wegl_context_teardown(ctx);
- return false;
-}
-
-struct wcore_context*
-wegl_context_create(struct wcore_platform *wc_plat,
- struct wcore_config *wc_config,
- struct wcore_context *wc_share_ctx)
-{
- struct wegl_context *ctx;
-
- (void) wc_plat;
-
- ctx = wcore_calloc(sizeof(*ctx));
- if (!ctx)
- return NULL;
-
- if (!wegl_context_init(ctx, wc_config, wc_share_ctx)) {
- wegl_context_destroy(&ctx->wcore);
- return NULL;
- }
-
- return &ctx->wcore;
+ wegl_context_destroy(&ctx->wcore);
+ return NULL;
}
bool
-wegl_context_teardown(struct wegl_context *ctx)
+wegl_context_destroy(struct wcore_context *wc_ctx)
{
bool result = true;
- if (!ctx)
- return result;
+ if (wc_ctx) {
+ struct wegl_context *ctx = wegl_context(wc_ctx);
- if (ctx->egl != EGL_NO_CONTEXT) {
- struct wegl_display *dpy = wegl_display(ctx->wcore.display);
- struct wegl_platform *plat = wegl_platform(dpy->wcore.platform);
+ if (ctx && ctx->egl != EGL_NO_CONTEXT) {
+ struct wegl_display *dpy = wegl_display(ctx->wcore.display);
+ struct wegl_platform *plat = wegl_platform(dpy->wcore.platform);
- if (!plat->eglDestroyContext(dpy->egl, ctx->egl)) {
- wegl_emit_error(plat, "eglDestroyContext");
- result = false;
+ if (!plat->eglDestroyContext(dpy->egl, ctx->egl)) {
+ wegl_emit_error(plat, "eglDestroyContext");
+ result = false;
+ }
}
- }
-
- result &= wcore_context_teardown(&ctx->wcore);
- return result;
-}
-
-bool
-wegl_context_destroy(struct wcore_context *wc_ctx)
-{
- bool result = true;
- if (wc_ctx) {
- struct wegl_context *ctx = wegl_context(wc_ctx);
- result = wegl_context_teardown(ctx);
+ result &= wcore_context_teardown(&ctx->wcore);
free(ctx);
}
return result;
diff --git a/src/waffle/egl/wegl_context.h b/src/waffle/egl/wegl_context.h
index b7d4d6a..19f9932 100644
--- a/src/waffle/egl/wegl_context.h
+++ b/src/waffle/egl/wegl_context.h
@@ -43,14 +43,6 @@ DEFINE_CONTAINER_CAST_FUNC(wegl_context,
struct wcore_context,
wcore)
-bool
-wegl_context_init(struct wegl_context *ctx,
- struct wcore_config *wc_config,
- struct wcore_context *wc_share_ctx);
-
-bool
-wegl_context_teardown(struct wegl_context *ctx);
-
struct wcore_context*
wegl_context_create(struct wcore_platform *wc_plat,
struct wcore_config *wc_config,
--
2.6.2
More information about the waffle
mailing list