summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuhiko Tanibata <NOBUHIKO_TANIBATA@denso.co.jp>2014-06-25 17:55:08 +0900
committerNobuhiko Tanibata <NOBUHIKO_TANIBATA@denso.co.jp>2014-08-21 10:08:13 +0900
commit92c98fae9c5af701af698339d98aa274f283c844 (patch)
tree6e41cc19589bb85dd2a258094632fe31c5d57814
parent9c326bd395b813babc7a4f569bb25f4d2a6411cb (diff)
downloadwayland-ivi-extension-92c98fae9c5af701af698339d98aa274f283c844.tar.gz
weston-ivi-shell: Move screenshot function from IVI-Shell to ivi-controller.
This is because ivi-shell shall not have dependency on other components as much as possible. Now it depends on CAIRO. Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@denso.co.jp>
-rwxr-xr-xweston-ivi-shell/src/ivi-controller.c64
-rw-r--r--weston-ivi-shell/src/ivi-layout-export.h43
2 files changed, 71 insertions, 36 deletions
diff --git a/weston-ivi-shell/src/ivi-controller.c b/weston-ivi-shell/src/ivi-controller.c
index 40c01f7..3b039f7 100755
--- a/weston-ivi-shell/src/ivi-controller.c
+++ b/weston-ivi-shell/src/ivi-controller.c
@@ -777,9 +777,9 @@ controller_surface_screenshot(struct wl_client *client,
struct wl_resource *resource,
const char *filename)
{
- struct ivisurface *ivisurf = wl_resource_get_user_data(resource);
(void)client;
- ivi_layout_takeSurfaceScreenshot(filename, ivisurf->layout_surface);
+ (void)resource;
+ (void)filename;
}
static void
@@ -1066,7 +1066,65 @@ controller_screen_screenshot(struct wl_client *client,
{
struct iviscreen *iviscrn = wl_resource_get_user_data(resource);
(void)client;
- ivi_layout_takeScreenshot(iviscrn->layout_screen, filename);
+
+ struct weston_output *output = NULL;
+ cairo_surface_t *cairo_surf = NULL;
+ int32_t i = 0;
+ int32_t width = 0;
+ int32_t height = 0;
+ int32_t stride = 0;
+ uint8_t *readpixs = NULL;
+ uint8_t *writepixs = NULL;
+ uint8_t *d = NULL;
+ uint8_t *s = NULL;
+
+ output = ivi_layout_screenGetOutput(iviscrn->layout_screen);
+ --output->disable_planes;
+
+ width = output->current_mode->width;
+ height = output->current_mode->height;
+ stride = width * (PIXMAN_FORMAT_BPP(output->compositor->read_format) / 8);
+
+ readpixs = malloc(stride * height);
+ if (readpixs == NULL) {
+ weston_log("fails to allocate memory\n");
+ return;
+ }
+
+ writepixs = malloc(stride * height);
+ if (writepixs == NULL) {
+ weston_log("fails to allocate memory\n");
+ return;
+ }
+
+ output->compositor->renderer->read_pixels(
+ output,
+ output->compositor->read_format,
+ readpixs,
+ 0,
+ 0,
+ width,
+ height);
+
+ s = readpixs;
+ d = writepixs + stride * (height - 1);
+
+ for (i = 0; i < height; ++i) {
+ memcpy(d, s, stride);
+ d -= stride;
+ s += stride;
+ }
+
+ cairo_surf = cairo_image_surface_create_for_data(
+ writepixs,
+ CAIRO_FORMAT_ARGB32,
+ width,
+ height,
+ stride);
+ cairo_surface_write_to_png(cairo_surf, filename);
+ cairo_surface_destroy(cairo_surf);
+ free(writepixs);
+ free(readpixs);
}
static void
diff --git a/weston-ivi-shell/src/ivi-layout-export.h b/weston-ivi-shell/src/ivi-layout-export.h
index 9784cf3..25deeb8 100644
--- a/weston-ivi-shell/src/ivi-layout-export.h
+++ b/weston-ivi-shell/src/ivi-layout-export.h
@@ -833,39 +833,6 @@ ivi_layout_screenSetRenderOrder(struct ivi_layout_screen *iviscrn,
const uint32_t number);
/**
- * \brief Take a screenshot from the current displayed layer scene.
- * The screenshot is saved as bmp file with the corresponding filename.
- *
- * \return 0 if the method call was successful
- * \return -1 if the method call was failed
- */
-int32_t
-ivi_layout_takeScreenshot(struct ivi_layout_screen *iviscrn,
- const char *filename);
-
-/**
- * \brief Take a screenshot of a certain layer
- * The screenshot is saved as bmp file with the corresponding filename.
- *
- * \return 0 if the method call was successful
- * \return -1 if the method call was failed
- */
-int32_t
-ivi_layout_takeLayerScreenshot(const char *filename,
- struct ivi_layout_layer *ivilayer);
-
-/**
- * \brief Take a screenshot of a certain surface
- * The screenshot is saved as bmp file with the corresponding filename.
- *
- * \return 0 if the method call was successful
- * \return -1 if the method call was failed
- */
-int32_t
-ivi_layout_takeSurfaceScreenshot(const char *filename,
- struct ivi_layout_surface *ivisurf);
-
-/**
* \brief Enable or disable a rendering optimization
*
* \return 0 if the method call was successful
@@ -945,6 +912,16 @@ ivi_layout_surfaceSetSourceRectangle(struct ivi_layout_surface *ivisurf,
uint32_t width, uint32_t height);
/**
+ * \brief get weston_output from ivi_layout_screen.
+ *
+ * \return (struct weston_screen *)
+ * if the method call was successful
+ * \return NULL if the method call was failed
+ */
+struct weston_output *
+ivi_layout_screenGetOutput(struct ivi_layout_screen *);
+
+/**
* \brief Commit all changes and execute all enqueued commands since last commit.
*
* \return 0 if the method call was successful