summaryrefslogtreecommitdiff
path: root/image/webp.c
diff options
context:
space:
mode:
Diffstat (limited to 'image/webp.c')
-rw-r--r--image/webp.c93
1 files changed, 22 insertions, 71 deletions
diff --git a/image/webp.c b/image/webp.c
index cabd40a3f..90c7121ac 100644
--- a/image/webp.c
+++ b/image/webp.c
@@ -41,73 +41,8 @@ typedef struct webp_content
struct content base;
} webp_content;
-static nserror webp_create(const content_handler *handler,
- lwc_string *imime_type, const http_parameter *params,
- llcache_handle *llcache, const char *fallback_charset,
- bool quirks, struct content **c);
-static bool webp_convert(struct content *c);
-static void webp_destroy(struct content *c);
-static bool webp_redraw(struct content *c, struct content_redraw_data *data,
- const struct rect *clip, const struct redraw_context *ctx);
-static nserror webp_clone(const struct content *old, struct content **newc);
-static content_type webp_content_type(lwc_string *mime_type);
-
-static const content_handler webp_content_handler = {
- .create = webp_create,
- .data_complete = webp_convert,
- .destroy = webp_destroy,
- .redraw = webp_redraw,
- .clone = webp_clone,
- .type = webp_content_type,
- .no_share = false,
-};
-static const char *webp_types[] = {
- "image/webp"
-};
-
-static lwc_string *webp_mime_types[NOF_ELEMENTS(webp_types)];
-
-nserror webp_init(void)
-{
- uint32_t i;
- lwc_error lerror;
- nserror error;
-
- for (i = 0; i < NOF_ELEMENTS(webp_mime_types); i++) {
- lerror = lwc_intern_string(webp_types[i],
- strlen(webp_types[i]),
- &webp_mime_types[i]);
- if (lerror != lwc_error_ok) {
- error = NSERROR_NOMEM;
- goto error;
- }
-
- error = content_factory_register_handler(webp_mime_types[i],
- &webp_content_handler);
- if (error != NSERROR_OK)
- goto error;
- }
-
- return NSERROR_OK;
-
-error:
- webp_fini();
-
- return error;
-}
-
-void webp_fini(void)
-{
- uint32_t i;
-
- for (i = 0; i < NOF_ELEMENTS(webp_mime_types); i++) {
- if (webp_mime_types[i] != NULL)
- lwc_string_unref(webp_mime_types[i]);
- }
-}
-
-nserror webp_create(const content_handler *handler,
+static nserror webp_create(const content_handler *handler,
lwc_string *imime_type, const http_parameter *params,
llcache_handle *llcache, const char *fallback_charset,
bool quirks, struct content **c)
@@ -137,7 +72,7 @@ nserror webp_create(const content_handler *handler,
* No conversion is necessary. We merely read the WebP dimensions.
*/
-bool webp_convert(struct content *c)
+static bool webp_convert(struct content *c)
{
union content_msg_data msg_data;
const uint8_t *data;
@@ -200,7 +135,7 @@ bool webp_convert(struct content *c)
* Destroy a CONTENT_WEBP and free all resources it owns.
*/
-void webp_destroy(struct content *c)
+static void webp_destroy(struct content *c)
{
if (c->bitmap != NULL)
bitmap_destroy(c->bitmap);
@@ -211,7 +146,7 @@ void webp_destroy(struct content *c)
* Redraw a CONTENT_WEBP.
*/
-bool webp_redraw(struct content *c, struct content_redraw_data *data,
+static bool webp_redraw(struct content *c, struct content_redraw_data *data,
const struct rect *clip, const struct redraw_context *ctx)
{
bitmap_flags_t flags = BITMAPF_NONE;
@@ -226,7 +161,7 @@ bool webp_redraw(struct content *c, struct content_redraw_data *data,
}
-nserror webp_clone(const struct content *old, struct content **newc)
+static nserror webp_clone(const struct content *old, struct content **newc)
{
webp_content *webp;
nserror error;
@@ -255,9 +190,25 @@ nserror webp_clone(const struct content *old, struct content **newc)
return NSERROR_OK;
}
-content_type webp_content_type(lwc_string *mime_type)
+static content_type webp_content_type(lwc_string *mime_type)
{
return CONTENT_IMAGE;
}
+static const content_handler webp_content_handler = {
+ .create = webp_create,
+ .data_complete = webp_convert,
+ .destroy = webp_destroy,
+ .redraw = webp_redraw,
+ .clone = webp_clone,
+ .type = webp_content_type,
+ .no_share = false,
+};
+
+static const char *webp_types[] = {
+ "image/webp"
+};
+
+CONTENT_FACTORY_REGISTER_TYPES(webp, webp_types, webp_content_handler);
+
#endif