neuwld

patched neuwld library (tracked)
git clone https://git.daat.foo/neuwld.git
Log | Files | Refs | README | LICENSE

context.c (2526B)


      1 /* wld: context.c
      2  *
      3  * Copyright (c) 2013, 2014 Michael Forney
      4  *
      5  * Permission is hereby granted, free of charge, to any person obtaining a copy
      6  * of this software and associated documentation files (the "Software"), to deal
      7  * in the Software without restriction, including without limitation the rights
      8  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
      9  * copies of the Software, and to permit persons to whom the Software is
     10  * furnished to do so, subject to the following conditions:
     11  *
     12  * The above copyright notice and this permission notice shall be included in
     13  * all copies or substantial portions of the Software.
     14  *
     15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     18  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     20  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
     21  * SOFTWARE.
     22  */
     23 
     24 #include "wld-private.h"
     25 
     26 void
     27 context_initialize(struct wld_context *context, const struct wld_context_impl *impl)
     28 {
     29 	*((const struct wld_context_impl **)&context->impl) = impl;
     30 }
     31 
     32 EXPORT
     33 struct wld_renderer *
     34 wld_create_renderer(struct wld_context *context)
     35 {
     36 	return context->impl->create_renderer(context);
     37 }
     38 
     39 EXPORT
     40 struct wld_buffer *
     41 wld_create_buffer(struct wld_context *context,
     42                   uint32_t width, uint32_t height,
     43                   uint32_t format, uint32_t flags)
     44 {
     45 	return &context->impl->create_buffer(context, width, height,
     46 	                                     format, flags)
     47 	            ->base;
     48 }
     49 
     50 EXPORT
     51 struct wld_buffer *
     52 wld_import_buffer(struct wld_context *context,
     53                   uint32_t type, union wld_object object,
     54                   uint32_t width, uint32_t height,
     55                   uint32_t format, uint32_t pitch)
     56 {
     57 	return &context->impl->import_buffer(context, type, object,
     58 	                                     width, height, format, pitch)
     59 	            ->base;
     60 }
     61 
     62 EXPORT
     63 struct wld_surface *
     64 wld_create_surface(struct wld_context *context,
     65                    uint32_t width, uint32_t height,
     66                    uint32_t format, uint32_t flags)
     67 {
     68 	return context->impl->create_surface(context, width, height, format, flags);
     69 }
     70 
     71 EXPORT
     72 void
     73 wld_destroy_context(struct wld_context *context)
     74 {
     75 	context->impl->destroy(context);
     76 }