diff options
author | Nobuhiko Tanibata <ntanibata@jp.adit-jv.com> | 2015-04-14 17:35:07 +0900 |
---|---|---|
committer | Nobuhiko Tanibata <ntanibata@jp.adit-jv.com> | 2015-04-27 15:12:55 +0900 |
commit | 7f7180d570994acb5db8b63e32dc212374e6e36c (patch) | |
tree | f487c76962eef9b003d3f7bc9674d59af77bb06d /weston-ivi-shell | |
parent | 802f557491ccc44a72f946502513b2ed39e1b518 (diff) | |
download | wayland-ivi-extension-7f7180d570994acb5db8b63e32dc212374e6e36c.tar.gz |
ivi-controller: remove unnecessary functions related to surface screenshot.
Weston now provides surface-screenshot related function. ivi-controller
doesn't have to implement capture function by itself.
Signed-off-by: Nobuhiko Tanibata <ntanibata@jp.adit-jv.com>
Diffstat (limited to 'weston-ivi-shell')
-rw-r--r-- | weston-ivi-shell/src/ivi-controller-impl.c | 233 |
1 files changed, 0 insertions, 233 deletions
diff --git a/weston-ivi-shell/src/ivi-controller-impl.c b/weston-ivi-shell/src/ivi-controller-impl.c index 7ea808d..68b97b1 100644 --- a/weston-ivi-shell/src/ivi-controller-impl.c +++ b/weston-ivi-shell/src/ivi-controller-impl.c @@ -744,239 +744,6 @@ controller_surface_set_orientation(struct wl_client *client, ivi_extension_surface_set_orientation(ivisurf->shell, ivisurf->layout_surface, (uint32_t)orientation); } -static int -shm_surface_screenshot(struct weston_surface *surface, - int32_t width, - int32_t height, - int32_t stride, - const char *filename) -{ - struct weston_buffer *weston_buffer = NULL; - struct wl_shm_buffer *shm_buffer = NULL; - cairo_surface_t *cairo_surf = NULL; - uint8_t *source_buffer = NULL; - uint8_t *dest_buffer = NULL; - - weston_buffer = surface->buffer_ref.buffer; - if (weston_buffer == NULL) { - fprintf(stderr, "Failed to get weston buffer.\n"); - return -1; - } - - shm_buffer = wl_shm_buffer_get(weston_buffer->resource); - if (shm_buffer == NULL) { - return -1; - } - - source_buffer = wl_shm_buffer_get_data(shm_buffer); - if (source_buffer == NULL) { - fprintf(stderr, "Failed to get data from shm buffer.\n"); - return -1; - } - - dest_buffer = malloc(stride * height); - if (dest_buffer == NULL) { - fprintf(stderr, "Failed to allocate memory.\n"); - return -1; - } - - memcpy(dest_buffer, source_buffer, stride * height); - - cairo_surf = cairo_image_surface_create_for_data( - dest_buffer, - CAIRO_FORMAT_RGB24, - width, - height, - stride); - - cairo_surface_write_to_png(cairo_surf, filename); - cairo_surface_destroy(cairo_surf); - free(dest_buffer); - - return 0; -} - -static void -bind_framebuffer(GLuint *fbo_id, GLuint *tex_id, GLsizei width, GLsizei height) -{ - glGenTextures(1, tex_id); - glGenFramebuffers(1, fbo_id); - glBindTexture(GL_TEXTURE_2D, *tex_id); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); - glBindFramebuffer(GL_FRAMEBUFFER, *fbo_id); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, *tex_id, 0); - glClearColor(0, 0, 0, 0); - glClear(GL_COLOR_BUFFER_BIT); -} - -static void -unbind_framebuffer(GLuint fbo_id, GLuint tex_id) -{ - glBindTexture(GL_TEXTURE_2D, 0); - glBindFramebuffer(GL_FRAMEBUFFER, 0); - glDeleteTextures(1, &tex_id); - glDeleteFramebuffers(1, &fbo_id); -} - -static void -dump_surface(struct weston_output *output, - struct weston_compositor *compositor, - const char *filename, - struct weston_view *view, - int32_t x, - int32_t y, - int32_t width, - int32_t height) -{ - struct weston_renderer *renderer = compositor->renderer; - pixman_region32_t region; - struct wl_list backup_transformation_list; - struct weston_transform *link = NULL; - struct weston_transform *next = NULL; - uint8_t *readpixs = NULL; - int32_t stride = width * (PIXMAN_FORMAT_BPP(compositor->read_format) / 8); - GLuint fbo_id, tex_id; - - readpixs = malloc(stride * height); - if (readpixs == NULL) { - fprintf(stderr, "Failed to allocate memory.\n"); - return; - } - - pixman_region32_init_rect(®ion, x, y, width, height); - bind_framebuffer(&fbo_id, &tex_id, output->current_mode->width, output->current_mode->height); - - wl_list_init(&backup_transformation_list); - wl_list_for_each_safe(link, next, &view->geometry.transformation_list, link) { - wl_list_remove(&link->link); - wl_list_insert(&backup_transformation_list, &link->link); - } - - wl_list_init(&view->geometry.transformation_list); - weston_view_geometry_dirty(view); - weston_view_update_transform(view); - - renderer->repaint_output(output, ®ion); - glFinish(); - - y = output->current_mode->height - (y + height); - int result = renderer->read_pixels(output, - compositor->read_format, - readpixs, - x, - y, - width, - height); - - wl_list_for_each_safe(link, next, &backup_transformation_list, link) { - wl_list_remove(&link->link); - wl_list_insert(&view->geometry.transformation_list, &link->link); - } - - weston_view_geometry_dirty(view); - weston_view_update_transform(view); - - unbind_framebuffer(fbo_id, tex_id); - - save_as_bitmap(filename, readpixs, stride * height, width, height, PIXMAN_FORMAT_BPP(compositor->read_format)); - free(readpixs); -} - -static struct weston_view * -clear_viewlist_but_specified_surface(struct weston_compositor *compositor, - struct weston_surface *surface) -{ - struct weston_view *view = NULL; - wl_list_init(&compositor->view_list); - - wl_list_for_each(view, &surface->views, surface_link) { - if (view == NULL) { - continue; - } - - wl_list_insert(compositor->view_list.prev, &view->link); - break; - } - - return view; -} - -static void -get_gl_surface_rectangle(const struct ivi_layout_surface_properties *prop, - int32_t *x, - int32_t *y, - int32_t *width, - int32_t *height) -{ - if (prop == NULL) { - return; - } - - *x = prop->source_x; - *y = prop->source_y; - *width = prop->source_width; - *height = prop->source_height; -} - -static int -gl_surface_screenshot(struct ivisurface *ivisurf, - struct weston_surface *surface, - const char *filename) -{ - struct weston_compositor *compositor = surface->compositor; - struct ivishell *shell = ivisurf->shell; - struct weston_view *view = NULL; - struct weston_output *output = NULL; - struct iviscreen *link_scrn = NULL; - const struct ivi_layout_surface_properties *prop; - int32_t x = 0; - int32_t y = 0; - int32_t width = 0; - int32_t height = 0; - - wl_list_for_each(link_scrn, &shell->list_screen, link) { - if (link_scrn != NULL) { - break; - } - } - - if (link_scrn == NULL) { - fprintf(stderr, "Failed to get iviscreen\n"); - return -1; - } - - prop = ivi_extension_get_properties_of_surface(shell, ivisurf->layout_surface); - if (prop == NULL) { - fprintf(stderr, "Failed to get surface properties.\n"); - return -1; - } - - view = clear_viewlist_but_specified_surface(compositor, surface); - if (view != NULL) { - int32_t plane_is_null = 0; - if (view->plane == NULL) { - plane_is_null = 1; - view->plane = &compositor->primary_plane; - } - - get_gl_surface_rectangle(prop, &x, &y, &width, &height); - dump_surface(link_scrn->output, - compositor, - filename, - view, - x, - y, - width, - height); - - if (plane_is_null) { - view->plane = NULL; - } - } - - return 0; -} - static void controller_surface_screenshot(struct wl_client *client, struct wl_resource *resource, |