本文整理汇总了C++中pixman_image_create_bits函数的典型用法代码示例。如果您正苦于以下问题:C++ pixman_image_create_bits函数的具体用法?C++ pixman_image_create_bits怎么用?C++ pixman_image_create_bits使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pixman_image_create_bits函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bench_composite
void
bench_composite (const char *testname,
int src_fmt,
int src_flags,
int op,
int mask_fmt,
int mask_flags,
int dst_fmt,
double npix)
{
pixman_image_t * src_img;
pixman_image_t * dst_img;
pixman_image_t * mask_img;
pixman_image_t * xsrc_img;
pixman_image_t * xdst_img;
pixman_image_t * xmask_img;
double t1, t2, t3, pix_cnt;
int64_t n, l1test_width, nlines;
double bytes_per_pix = 0;
pixman_bool_t bench_pixbuf = FALSE;
pixman_composite_func_t func = pixman_image_composite_wrapper;
if (!(src_flags & SOLID_FLAG))
{
bytes_per_pix += (src_fmt >> 24) / 8.0;
src_img = pixman_image_create_bits (src_fmt,
WIDTH, HEIGHT,
src,
WIDTH * 4);
xsrc_img = pixman_image_create_bits (src_fmt,
XWIDTH, XHEIGHT,
src,
XWIDTH * 4);
}
示例2: create_image
static pixman_image_t *
create_image (pixman_image_t **clone)
{
pixman_format_code_t format = RANDOM_ELT (formats);
pixman_image_t *image;
int width = prng_rand_n (MAX_WIDTH);
int height = prng_rand_n (MAX_HEIGHT);
int stride = ((width * (PIXMAN_FORMAT_BPP (format) / 8)) + 3) & ~3;
uint32_t *bytes = malloc (stride * height);
prng_randmemset (bytes, stride * height, RANDMEMSET_MORE_00_AND_FF);
image = pixman_image_create_bits (
format, width, height, bytes, stride);
pixman_image_set_destroy_function (image, free_bits, NULL);
assert (image);
if (clone)
{
uint32_t *bytes_dup = malloc (stride * height);
memcpy (bytes_dup, bytes, stride * height);
*clone = pixman_image_create_bits (
format, width, height, bytes_dup, stride);
pixman_image_set_destroy_function (*clone, free_bits, NULL);
}
return image;
}
示例3: main
int
main (int argc, char **argv)
{
uint32_t dst[SIZE];
pixman_image_t *src_img;
pixman_image_t *dst_img;
int i, j, x, y;
int ret = 0;
for (i = 0; i < n_test_cases; ++i)
{
for (j = 0; j < 2; ++j)
{
src_img = pixman_image_create_bits (testcases[i].format,
testcases[i].width,
testcases[i].height,
testcases[i].src,
testcases[i].stride);
pixman_image_set_indexed(src_img, testcases[i].indexed);
dst_img = pixman_image_create_bits (PIXMAN_a8r8g8b8,
testcases[i].width,
testcases[i].height,
dst,
testcases[i].width*4);
if (j)
{
pixman_image_set_accessors (src_img, reader, writer);
pixman_image_set_accessors (dst_img, reader, writer);
}
pixman_image_composite (PIXMAN_OP_SRC, src_img, NULL, dst_img,
0, 0, 0, 0, 0, 0, testcases[i].width, testcases[i].height);
pixman_image_unref (src_img);
pixman_image_unref (dst_img);
for (y = 0; y < testcases[i].height; ++y)
{
for (x = 0; x < testcases[i].width; ++x)
{
int offset = y * testcases[i].width + x;
if (dst[offset] != testcases[i].dst[offset])
{
printf ("test %i%c: pixel mismatch at (x=%d,y=%d): %08x expected, %08x obtained\n",
i + 1, 'a' + j,
x, y,
testcases[i].dst[offset], dst[offset]);
ret = 1;
}
}
}
}
}
return ret;
}
示例4: main
int
main ()
{
int o, s, m, d;
enable_fp_exceptions();
for (o = 0; o < ARRAY_LENGTH (pdf_ops); ++o)
{
pixman_op_t op = pdf_ops[o];
for (s = 0; s < ARRAY_LENGTH (pixels); ++s)
{
pixman_image_t *src;
src = pixman_image_create_bits (
PIXMAN_a8r8g8b8, 1, 1, (uint32_t *)&(pixels[s]), 4);
for (m = -1; m < ARRAY_LENGTH (pixels); ++m)
{
pixman_image_t *msk = NULL;
if (m >= 0)
{
msk = pixman_image_create_bits (
PIXMAN_a8r8g8b8, 1, 1, (uint32_t *)&(pixels[m]), 4);
}
for (d = 0; d < ARRAY_LENGTH (pixels); ++d)
{
pixman_image_t *dst;
uint32_t dp = pixels[d];
dst = pixman_image_create_bits (
PIXMAN_a8r8g8b8, 1, 1, &dp, 4);
pixman_image_composite (op, src, msk, dst,
0, 0, 0, 0, 0, 0, 1, 1);
pixman_image_unref (dst);
}
if (msk)
pixman_image_unref (msk);
}
pixman_image_unref (src);
}
}
return 0;
}
示例5: Transform
static void
Transform(DataSourceSurface* aDest,
DataSourceSurface* aSource,
const gfx3DMatrix& aTransform,
const Point& aDestOffset)
{
IntSize destSize = aDest->GetSize();
pixman_image_t* dest = pixman_image_create_bits(PIXMAN_a8r8g8b8,
destSize.width,
destSize.height,
(uint32_t*)aDest->GetData(),
aDest->Stride());
IntSize srcSize = aSource->GetSize();
pixman_image_t* src = pixman_image_create_bits(PIXMAN_a8r8g8b8,
srcSize.width,
srcSize.height,
(uint32_t*)aSource->GetData(),
aSource->Stride());
MOZ_ASSERT(src !=0 && dest != 0, "Failed to create pixman images?");
pixman_transform pixTransform = Matrix3DToPixman(aTransform);
pixman_transform pixTransformInverted;
// If the transform is singular then nothing would be drawn anyway, return here
if (!pixman_transform_invert(&pixTransformInverted, &pixTransform)) {
pixman_image_unref(dest);
pixman_image_unref(src);
return;
}
pixman_image_set_transform(src, &pixTransformInverted);
pixman_image_composite32(PIXMAN_OP_SRC,
src,
nullptr,
dest,
aDestOffset.x,
aDestOffset.y,
0,
0,
0,
0,
destSize.width,
destSize.height);
pixman_image_unref(dest);
pixman_image_unref(src);
}
示例6: pixman_image_create_bits
pixman_image_t *qemu_pixman_linebuf_create(pixman_format_code_t format,
int width)
{
pixman_image_t *image = pixman_image_create_bits(format, width, 1, NULL, 0);
assert(image != NULL);
return image;
}
示例7: pixman_image_create_bits
static XImage *create_temp_image(int screen, int width, int height,
pixman_image_t **pixman_image_out,
XShmSegmentInfo **shminfo_out)
{
XImage *image;
XShmSegmentInfo *shminfo;
RedDrawable::Format format;
pixman_image_t *pixman_image;
XVisualInfo *vinfo;
image = NULL;
shminfo = NULL;
vinfo = XPlatform::get_vinfo()[screen];
format = XPlatform::get_screen_format(screen);
image = XPlatform::create_x_image(format, width, height, vinfo->depth,
vinfo->visual, &shminfo);
pixman_image = pixman_image_create_bits(RedDrawable::format_to_pixman(format),
width, height,
(uint32_t *)image->data, image->bytes_per_line);
if (pixman_image == NULL) {
THROW("surf create failed");
}
*pixman_image_out = pixman_image;
*shminfo_out = shminfo;
return image;
}
示例8: pixman_renderer_surface_copy_content
static int
pixman_renderer_surface_copy_content(struct weston_surface *surface,
void *target, size_t size,
int src_x, int src_y,
int width, int height)
{
const pixman_format_code_t format = PIXMAN_a8b8g8r8;
const size_t bytespp = 4; /* PIXMAN_a8b8g8r8 */
struct pixman_surface_state *ps = get_surface_state(surface);
pixman_image_t *out_buf;
if (!ps->image)
return -1;
out_buf = pixman_image_create_bits(format, width, height,
target, width * bytespp);
pixman_image_set_transform(ps->image, NULL);
pixman_image_composite32(PIXMAN_OP_SRC,
ps->image, /* src */
NULL, /* mask */
out_buf, /* dest */
src_x, src_y, /* src_x, src_y */
0, 0, /* mask_x, mask_y */
0, 0, /* dest_x, dest_y */
width, height);
pixman_image_unref(out_buf);
return 0;
}
示例9: headless_compositor_create_output
static int
headless_compositor_create_output(struct headless_compositor *c,
struct headless_parameters *param)
{
struct headless_output *output;
struct wl_event_loop *loop;
output = zalloc(sizeof *output);
if (output == NULL)
return -1;
output->mode.flags =
WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED;
output->mode.width = param->width;
output->mode.height = param->height;
output->mode.refresh = 60000;
wl_list_init(&output->base.mode_list);
wl_list_insert(&output->base.mode_list, &output->mode.link);
output->base.current_mode = &output->mode;
weston_output_init(&output->base, &c->base, 0, 0, param->width,
param->height, param->transform, 1);
output->base.make = "weston";
output->base.model = "headless";
loop = wl_display_get_event_loop(c->base.wl_display);
output->finish_frame_timer =
wl_event_loop_add_timer(loop, finish_frame_handler, output);
output->base.start_repaint_loop = headless_output_start_repaint_loop;
output->base.repaint = headless_output_repaint;
output->base.destroy = headless_output_destroy;
output->base.assign_planes = NULL;
output->base.set_backlight = NULL;
output->base.set_dpms = NULL;
output->base.switch_mode = NULL;
if (c->use_pixman) {
output->image_buf = malloc(param->width * param->height * 4);
if (!output->image_buf)
return -1;
output->image = pixman_image_create_bits(PIXMAN_x8r8g8b8,
param->width,
param->height,
output->image_buf,
param->width * 4);
if (pixman_renderer_output_create(&output->base) < 0)
return -1;
pixman_renderer_output_set_buffer(&output->base,
output->image);
}
wl_list_insert(c->base.output_list.prev, &output->base.link);
return 0;
}
示例10: xrdp_server_shared_framebuffer
int xrdp_server_shared_framebuffer(xrdpModule* mod, XRDP_MSG_SHARED_FRAMEBUFFER* msg)
{
mod->framebuffer.fbWidth = msg->width;
mod->framebuffer.fbHeight = msg->height;
mod->framebuffer.fbScanline = msg->scanline;
mod->framebuffer.fbSegmentId = msg->segmentId;
mod->framebuffer.fbBitsPerPixel = msg->bitsPerPixel;
mod->framebuffer.fbBytesPerPixel = msg->bytesPerPixel;
printf("received shared framebuffer message: mod->framebuffer.fbAttached: %d msg->attach: %d\n",
mod->framebuffer.fbAttached, msg->attach);
if (!mod->framebuffer.fbAttached && msg->attach)
{
mod->framebuffer.fbSharedMemory = (BYTE*) shmat(mod->framebuffer.fbSegmentId, 0, 0);
mod->framebuffer.fbAttached = TRUE;
printf("attached segment %d to %p\n",
mod->framebuffer.fbSegmentId, mod->framebuffer.fbSharedMemory);
mod->framebuffer.image = (void*) pixman_image_create_bits(PIXMAN_x8r8g8b8,
mod->framebuffer.fbWidth, mod->framebuffer.fbHeight,
(uint32_t*) mod->framebuffer.fbSharedMemory, mod->framebuffer.fbScanline);
}
if (mod->framebuffer.fbAttached && !msg->attach)
{
shmdt(mod->framebuffer.fbSharedMemory);
mod->framebuffer.fbAttached = FALSE;
mod->framebuffer.fbSharedMemory = 0;
}
return 0;
}
示例11: pixman_image_create_bits
static inline pixman_image_t *__surface_create_stride(pixman_format_code_t format, int width, int height,
int stride)
{
uint8_t *data;
uint8_t *stride_data;
pixman_image_t *surface;
PixmanData *pixman_data;
data = (uint8_t *)spice_malloc_n(abs(stride), height);
if (stride < 0) {
stride_data = data + (-stride) * (height - 1);
} else {
stride_data = data;
}
surface = pixman_image_create_bits(format, width, height, (uint32_t *)stride_data, stride);
if (surface == NULL) {
free(data);
spice_error("create surface failed, out of memory");
}
pixman_data = pixman_image_add_data(surface);
pixman_data->data = data;
pixman_data->format = format;
return surface;
}
示例12: _cairo_image_surface_create_with_pixman_format
cairo_surface_t *
_cairo_image_surface_create_with_pixman_format (unsigned char *data,
pixman_format_code_t pixman_format,
int width,
int height,
int stride)
{
cairo_surface_t *surface;
pixman_image_t *pixman_image;
if (! _cairo_image_surface_is_size_valid (width, height))
{
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE));
}
pixman_image = pixman_image_create_bits (pixman_format, width, height,
(uint32_t *) data, stride);
if (unlikely (pixman_image == NULL))
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
surface = _cairo_image_surface_create_for_pixman_image (pixman_image,
pixman_format);
if (unlikely (surface->status)) {
pixman_image_unref (pixman_image);
return surface;
}
/* we can not make any assumptions about the initial state of user data */
surface->is_clear = data == NULL;
return surface;
}
示例13: pixman_renderer_output_create
WL_EXPORT int
pixman_renderer_output_create(struct weston_output *output)
{
struct pixman_output_state *po = calloc(1, sizeof *po);
int w, h;
if (!po)
return -1;
/* set shadow image transformation */
w = output->current_mode->width;
h = output->current_mode->height;
po->shadow_buffer = malloc(w * h * 4);
if (!po->shadow_buffer) {
free(po);
return -1;
}
po->shadow_image =
pixman_image_create_bits(PIXMAN_x8r8g8b8, w, h,
po->shadow_buffer, w * 4);
if (!po->shadow_image) {
free(po->shadow_buffer);
free(po);
return -1;
}
output->renderer_state = po;
return 0;
}
示例14: create_bits_picture
static pixman_image_t *
create_bits_picture(PicturePtr pict, Bool has_clip, int *xoff, int *yoff)
{
PixmapPtr pixmap;
FbBits *bits;
FbStride stride;
int bpp;
pixman_image_t *image;
fbGetDrawablePixmap(pict->pDrawable, pixmap, *xoff, *yoff);
fbGetPixmapBitsData(pixmap, bits, stride, bpp);
image = pixman_image_create_bits((pixman_format_code_t) pict->format,
pixmap->drawable.width,
pixmap->drawable.height, (uint32_t *) bits,
stride * sizeof(FbStride));
if (!image)
return NULL;
#ifdef FB_ACCESS_WRAPPER
#if FB_SHIFT==5
pixman_image_set_accessors(image,
(pixman_read_memory_func_t) wfbReadMemory,
(pixman_write_memory_func_t) wfbWriteMemory);
#else
#error The pixman library only works when FbBits is 32 bits wide
#endif
#endif
/* pCompositeClip is undefined for source pictures, so
* only set the clip region for pictures with drawables
*/
if (has_clip) {
if (pict->clientClipType != CT_NONE)
pixman_image_set_has_client_clip(image, TRUE);
if (*xoff || *yoff)
pixman_region_translate(pict->pCompositeClip, *xoff, *yoff);
pixman_image_set_clip_region(image, pict->pCompositeClip);
if (*xoff || *yoff)
pixman_region_translate(pict->pCompositeClip, -*xoff, -*yoff);
}
/* Indexed table */
if (pict->pFormat->index.devPrivate)
pixman_image_set_indexed(image, pict->pFormat->index.devPrivate);
/* Add in drawable origin to position within the image */
*xoff += pict->pDrawable->x;
*yoff += pict->pDrawable->y;
return image;
}
示例15: process_image_data
static void process_image_data(struct fp_img_dev *dev, char **output, int *output_height)
{
//pixman stuff taken from libfprint/pixman.c, adapted for my purposes.
pixman_image_t *orig, *resized;
pixman_transform_t transform;
struct vfs0050_dev *vfs_dev = dev->priv;
struct vfs0050_line *line, *calibration_line;
char *buf = malloc(vfs_dev->scanbuf_idx);
int lines = vfs_dev->scanbuf_idx / VFS0050_FRAME_SIZE;
int i, x, sum, last_sum, diff;
int new_height;
//just grab one around middle, there should be 100
calibration_line = (struct vfs0050_line *) ((char *) vfs_dev->calbuf + (50 * VFS0050_FRAME_SIZE));
new_height = 0;
for (i = 0; i < lines; i++) {
line = (struct vfs0050_line *) ((char *) vfs_dev->scanbuf + (i * VFS0050_FRAME_SIZE));
if (!is_noise(line))
memcpy(buf + (new_height++ * VFS0050_IMG_WIDTH), line->row, VFS0050_IMG_WIDTH);
else
fp_dbg("removed noise at line: %d\n", i);
}
orig = pixman_image_create_bits(PIXMAN_a8, VFS0050_IMG_WIDTH, new_height, (uint32_t *) buf, VFS0050_IMG_WIDTH);
new_height *= VFS0050_SCALE_FACTOR; //scale for resized image
resized = pixman_image_create_bits(PIXMAN_a8, VFS0050_IMG_WIDTH, new_height, NULL, VFS0050_IMG_WIDTH);
pixman_transform_init_identity(&transform);
pixman_transform_scale(NULL, &transform, pixman_int_to_fixed(1), pixman_double_to_fixed(0.2));
pixman_image_set_transform(orig, &transform);
pixman_image_set_filter(orig, PIXMAN_FILTER_BEST, NULL, 0);
pixman_image_composite32(PIXMAN_OP_SRC,
orig,
NULL,
resized,
0, 0,
0, 0,
0, 0,
VFS0050_IMG_WIDTH, new_height
);
memcpy(buf, pixman_image_get_data(resized), VFS0050_IMG_WIDTH * new_height);
pixman_image_unref(orig);
pixman_image_unref(resized);
*output_height = new_height;
*output = buf;
}