Hello community, here is the log from the commit of package grim for openSUSE:Factory checked in at 2019-06-04 12:14:30 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/grim (Old) and /work/SRC/openSUSE:Factory/.grim.new.5148 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "grim" Tue Jun 4 12:14:30 2019 rev:2 rq:707382 version:1.2.0 Changes: -------- --- /work/SRC/openSUSE:Factory/grim/grim.changes 2019-02-24 17:12:31.560481273 +0100 +++ /work/SRC/openSUSE:Factory/.grim.new.5148/grim.changes 2019-06-04 12:14:34.175777970 +0200 @@ -1,0 +2,7 @@ +Tue Jun 4 06:10:47 UTC 2019 - mvet...@suse.com + +- Update to 1.2.0: + * Add support for the PPM format. This is useful for speeding up + grim when piping its output into another process. + +------------------------------------------------------------------- Old: ---- v1.1.tar.gz New: ---- v1.2.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ grim.spec ++++++ --- /var/tmp/diff_new_pack.WGAzIi/_old 2019-06-04 12:14:35.883777410 +0200 +++ /var/tmp/diff_new_pack.WGAzIi/_new 2019-06-04 12:14:35.907777403 +0200 @@ -12,12 +12,12 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# Please submit bugfixes or comments via http://bugs.opensuse.org/ # Name: grim -Version: 1.1 +Version: 1.2.0 Release: 0 Summary: Wayland compositor image grabber License: MIT ++++++ v1.1.tar.gz -> v1.2.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/grim-1.1/README.md new/grim-1.2.0/README.md --- old/grim-1.1/README.md 2019-01-29 15:09:25.000000000 +0100 +++ new/grim-1.2.0/README.md 2019-06-03 20:50:17.000000000 +0200 @@ -46,11 +46,11 @@ grim -o $(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .name') screenshot.png ``` -## Installation +## Package manager installation * Arch Linux: `pacman -S grim` -## Building +## Building from source Install dependencies: @@ -64,9 +64,10 @@ ```sh meson build ninja -C build -build/grim ``` +To run directly, use `build/grim`, or if you would like to do a system installation (in `/usr/local` by default), run `ninja -C build install`. + ## Contributing Either [send GitHub pull requests][github] or [send patches on the mailing list][ml]. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/grim-1.1/cairo_ppm.c new/grim-1.2.0/cairo_ppm.c --- old/grim-1.1/cairo_ppm.c 1970-01-01 01:00:00.000000000 +0100 +++ new/grim-1.2.0/cairo_ppm.c 2019-06-03 20:50:17.000000000 +0200 @@ -0,0 +1,96 @@ +#include <assert.h> +#include <fcntl.h> +#include <limits.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/stat.h> +#include <sys/types.h> +#include <unistd.h> +#include <cairo.h> + +#include "cairo_ppm.h" + +cairo_status_t cairo_surface_write_to_ppm_mem(cairo_surface_t *sfc, + unsigned char **data, unsigned long *len) { + // 256 bytes ought to be enough for everyone + char header[256]; + + int width = cairo_image_surface_get_width(sfc); + int height = cairo_image_surface_get_height(sfc); + + int header_len = snprintf(header, sizeof(header), "P6\n%d %d\n255\n", width, height); + assert(header_len <= (int)sizeof(header)); + + *len = header_len + width * height * 3; + unsigned char *buffer = malloc(*len); + *data = buffer; + + // We _do_not_ include the null byte + memcpy(buffer, header, header_len); + buffer += header_len; + + cairo_format_t cformat = cairo_image_surface_get_format(sfc); + assert(cformat == CAIRO_FORMAT_RGB24 || cformat == CAIRO_FORMAT_ARGB32); + + // Both formats are native-endian 32-bit ints + uint32_t *pixels = (uint32_t *)cairo_image_surface_get_data(sfc); + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) { + uint32_t p = *pixels++; + // RGB order + *buffer++ = (p >> 16) & 0xff; + *buffer++ = (p >> 8) & 0xff; + *buffer++ = (p >> 0) & 0xff; + } + } + + return CAIRO_STATUS_SUCCESS; +} + + +static cairo_status_t cj_write(void *closure, const unsigned char *data, + unsigned int length) { + if (write((long) closure, data, length) < length) { + return CAIRO_STATUS_WRITE_ERROR; + } else { + return CAIRO_STATUS_SUCCESS; + } +} + +cairo_status_t cairo_surface_write_to_ppm_stream(cairo_surface_t *sfc, + cairo_write_func_t write_func, void *closure) { + cairo_status_t e; + unsigned char *data = NULL; + unsigned long len = 0; + + e = cairo_surface_write_to_ppm_mem(sfc, &data, &len); + if (e == CAIRO_STATUS_SUCCESS) { + assert(sizeof(unsigned long) <= sizeof(size_t) + || !(len >> (sizeof(size_t) * CHAR_BIT))); + e = write_func(closure, data, len); + free(data); + } + + return e; +} + +cairo_status_t cairo_surface_write_to_ppm(cairo_surface_t *sfc, + const char *filename) { + cairo_status_t e; + int outfile; + + outfile = open(filename, + O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + + if (outfile == -1) { + return CAIRO_STATUS_DEVICE_ERROR; + } + + e = cairo_surface_write_to_ppm_stream(sfc, cj_write, + (void*) (long) outfile); + + close(outfile); + return e; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/grim-1.1/include/cairo_ppm.h new/grim-1.2.0/include/cairo_ppm.h --- old/grim-1.1/include/cairo_ppm.h 1970-01-01 01:00:00.000000000 +0100 +++ new/grim-1.2.0/include/cairo_ppm.h 2019-06-03 20:50:17.000000000 +0200 @@ -0,0 +1,10 @@ +#ifndef _CAIRO_PPM_H +#define _CAIRO_PPM_H + +#include <cairo.h> + +cairo_status_t cairo_surface_write_to_ppm_mem(cairo_surface_t *sfc, unsigned char **data, unsigned long *len); +cairo_status_t cairo_surface_write_to_ppm_stream(cairo_surface_t *sfc, cairo_write_func_t write_func, void *closure); +cairo_status_t cairo_surface_write_to_ppm(cairo_surface_t *sfc, const char *filename); + +#endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/grim-1.1/include/grim.h new/grim-1.2.0/include/grim.h --- old/grim-1.1/include/grim.h 2019-01-29 15:09:25.000000000 +0100 +++ new/grim-1.2.0/include/grim.h 2019-06-03 20:50:17.000000000 +0200 @@ -9,6 +9,7 @@ enum grim_filetype { GRIM_FILETYPE_PNG, + GRIM_FILETYPE_PPM, GRIM_FILETYPE_JPEG, }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/grim-1.1/main.c new/grim-1.2.0/main.c --- old/grim-1.1/main.c 2019-01-29 15:09:25.000000000 +0100 +++ new/grim-1.2.0/main.c 2019-06-03 20:50:17.000000000 +0200 @@ -12,6 +12,7 @@ #include "grim.h" #include "output-layout.h" #include "render.h" +#include "cairo_ppm.h" #ifdef HAVE_JPEG #include "cairo_jpg.h" #endif @@ -198,7 +199,7 @@ " -s <factor> Set the output image scale factor. Defaults to the\n" " greatest output scale factor.\n" " -g <geometry> Set the region to capture.\n" - " -t png|jpeg Set the output filetype. Defaults to png.\n" + " -t png|ppm|jpeg Set the output filetype. Defaults to png.\n" " -q <quality> Set the JPEG filetype quality 0-100. Defaults to 80.\n" " -o <output> Set the output name to capture.\n" " -c Include cursors in the screenshot.\n"; @@ -251,6 +252,8 @@ case 't': if (strcmp(optarg, "png") == 0) { output_filetype = GRIM_FILETYPE_PNG; + } else if (strcmp(optarg, "ppm") == 0) { + output_filetype = GRIM_FILETYPE_PPM; } else if (strcmp(optarg, "jpeg") == 0) { #ifdef HAVE_JPEG output_filetype = GRIM_FILETYPE_JPEG; @@ -411,6 +414,9 @@ cairo_status_t status; if (strcmp(output_filename, "-") == 0) { switch (output_filetype) { + case GRIM_FILETYPE_PPM: + status = cairo_surface_write_to_ppm_stream(surface, write_func, stdout); + break; case GRIM_FILETYPE_PNG: status = cairo_surface_write_to_png_stream(surface, write_func, stdout); break; @@ -425,6 +431,9 @@ } } else { switch (output_filetype) { + case GRIM_FILETYPE_PPM: + status = cairo_surface_write_to_ppm(surface, output_filename); + break; case GRIM_FILETYPE_PNG: status = cairo_surface_write_to_png(surface, output_filename); break; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/grim-1.1/meson.build new/grim-1.2.0/meson.build --- old/grim-1.1/meson.build 2019-01-29 15:09:25.000000000 +0100 +++ new/grim-1.2.0/meson.build 2019-06-03 20:50:17.000000000 +0200 @@ -1,9 +1,9 @@ project( 'grim', 'c', - version: '1.0.0', + version: '1.2.0', license: 'MIT', - meson_version: '>=0.43.0', + meson_version: '>=0.48.0', default_options: [ 'c_std=c11', 'warning_level=2', @@ -18,14 +18,13 @@ cc = meson.get_compiler('c') cairo = dependency('cairo') -jpeg = dependency('libjpeg', required: get_option('jpeg') == 'enabled') +jpeg = dependency('libjpeg', required: get_option('jpeg')) math = cc.find_library('m') realtime = cc.find_library('rt') wayland_client = dependency('wayland-client') wayland_protos = dependency('wayland-protocols', version: '>=1.14') -have_jpeg = get_option('jpeg') != 'disabled' and jpeg.found() -if have_jpeg +if jpeg.found() add_project_arguments('-DHAVE_JPEG', language: 'c') endif @@ -37,6 +36,7 @@ 'main.c', 'output-layout.c', 'render.c', + 'cairo_ppm.c', ] grim_deps = [ @@ -47,7 +47,7 @@ wayland_client, ] -if have_jpeg +if jpeg.found() grim_files += ['cairo_jpg.c'] grim_deps += [jpeg] endif @@ -60,7 +60,7 @@ install: true, ) -scdoc = find_program('scdoc', required: false) +scdoc = find_program('scdoc', required: get_option('man-pages')) if scdoc.found() sh = find_program('sh') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/grim-1.1/meson_options.txt new/grim-1.2.0/meson_options.txt --- old/grim-1.1/meson_options.txt 2019-01-29 15:09:25.000000000 +0100 +++ new/grim-1.2.0/meson_options.txt 2019-06-03 20:50:17.000000000 +0200 @@ -1,7 +1,2 @@ -option( - 'jpeg', - type: 'combo', - choices: ['auto', 'enabled', 'disabled'], - value: 'auto', - description: 'Enable JPEG support', -) +option('jpeg', type: 'feature', value: 'auto', description: 'Enable JPEG support') +option('man-pages', type: 'feature', value: 'auto', description: 'Generate and install man pages')