4 * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
7 * Stanislav Vorobiov <s.vorobiov@samsung.com>
8 * Jinhyung Jo <jinhyung.jo@samsung.com>
9 * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this software and associated documentation files (the "Software"), to deal
13 * in the Software without restriction, including without limitation the rights
14 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 * copies of the Software, and to permit persons to whom the Software is
16 * furnished to do so, subject to the following conditions:
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
35 #include "yagl_gles_image.h"
36 #include "yagl_gles_texture.h"
37 #include "yagl_client_context.h"
38 #include "yagl_sharegroup.h"
39 #include "yagl_malloc.h"
40 #include "yagl_host_gles_calls.h"
42 static void yagl_gles_image_update(struct yagl_client_image *image,
48 struct yagl_gles_image *gles_image = (struct yagl_gles_image*)image;
50 yagl_host_glUpdateOffscreenImageYAGL(gles_image->tex_global_name,
55 width * height * bpp);
58 static void yagl_gles_image_destroy(struct yagl_ref *ref)
60 struct yagl_gles_image *image = (struct yagl_gles_image*)ref;
62 if (image->texture_obj) {
63 yagl_gles_texture_release(image->texture_obj);
65 yagl_host_glDeleteObjects(&image->tex_global_name, 1);
68 yagl_client_image_cleanup(&image->base);
73 struct yagl_gles_image *yagl_gles_image_create(yagl_object_name tex_global_name)
75 struct yagl_gles_image *image;
77 image = yagl_malloc0(sizeof(*image));
79 yagl_client_image_init(&image->base, &yagl_gles_image_destroy);
81 image->base.update = &yagl_gles_image_update;
83 image->tex_global_name = tex_global_name;
88 struct yagl_gles_image *yagl_gles_image_wrap_tex(struct yagl_client_context *ctx,
89 yagl_object_name tex_local_name)
91 struct yagl_gles_texture *texture_obj;
92 struct yagl_gles_image *image;
94 texture_obj = (struct yagl_gles_texture *)yagl_sharegroup_acquire_object(ctx->sg,
102 image = yagl_malloc0(sizeof(*image));
104 yagl_client_image_init(&image->base, &yagl_gles_image_destroy);
106 image->base.update = &yagl_gles_image_update;
108 image->tex_global_name = texture_obj->global_name;
109 image->texture_obj = texture_obj;
114 yagl_gles_texture_release(texture_obj);
119 void yagl_gles_image_acquire(struct yagl_gles_image *image)
122 yagl_client_image_acquire(&image->base);
126 void yagl_gles_image_release(struct yagl_gles_image *image)
129 yagl_client_image_release(&image->base);