blob: 36d59be68a790fa454a811e0c12fc0a9796ae9f7 [file] [log] [blame]
Ander Conselvan de Oliveira11f8d402012-10-29 18:19:24 +02001/*
2 * Copyright © 2012 Intel Corporation
3 *
4 * Permission to use, copy, modify, distribute, and sell this software and
5 * its documentation for any purpose is hereby granted without fee, provided
6 * that the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of the copyright holders not be used in
9 * advertising or publicity pertaining to distribution of the software
10 * without specific, written prior permission. The copyright holders make
11 * no representations about the suitability of this software for any
12 * purpose. It is provided "as is" without express or implied warranty.
13 *
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
15 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
17 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
18 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
19 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
20 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 */
22
Daniel Stonec228e232013-05-22 18:03:19 +030023#include "config.h"
Ander Conselvan de Oliveira11f8d402012-10-29 18:19:24 +020024
25#include <stdlib.h>
26
27#include "compositor.h"
28
John Kåre Alsakera95b2d62012-11-13 19:10:21 +010029static int
30noop_renderer_read_pixels(struct weston_output *output,
31 pixman_format_code_t format, void *pixels,
32 uint32_t x, uint32_t y,
33 uint32_t width, uint32_t height)
34{
35 return 0;
36}
37
Ander Conselvan de Oliveira11f8d402012-10-29 18:19:24 +020038static void
39noop_renderer_repaint_output(struct weston_output *output,
40 pixman_region32_t *output_damage)
41{
42}
43
44static void
45noop_renderer_flush_damage(struct weston_surface *surface)
46{
47}
48
49static void
Jason Ekstrand6bd62942013-06-20 20:38:23 -050050noop_renderer_attach(struct weston_surface *es, struct weston_buffer *buffer)
Ander Conselvan de Oliveira11f8d402012-10-29 18:19:24 +020051{
Emilio Pozuelo Monfort2c87d942014-02-07 09:34:44 +010052 struct wl_shm_buffer *shm_buffer;
53
54 if (!buffer)
55 return;
56
57 shm_buffer = wl_shm_buffer_get(buffer->resource);
58
59 if (!shm_buffer) {
60 weston_log("No-op renderer supports only SHM buffers\n");
61 return;
62 }
63
64 buffer->shm_buffer = shm_buffer;
65 buffer->width = wl_shm_buffer_get_width(shm_buffer);
66 buffer->height = wl_shm_buffer_get_height(shm_buffer);
Ander Conselvan de Oliveira11f8d402012-10-29 18:19:24 +020067}
68
John Kåre Alsaker878f4492012-11-13 19:10:23 +010069static void
70noop_renderer_surface_set_color(struct weston_surface *surface,
71 float red, float green, float blue, float alpha)
72{
73}
74
Ander Conselvan de Oliveira11f8d402012-10-29 18:19:24 +020075static void
Ander Conselvan de Oliveira11f8d402012-10-29 18:19:24 +020076noop_renderer_destroy(struct weston_compositor *ec)
77{
78 free(ec->renderer);
79 ec->renderer = NULL;
80}
81
82WL_EXPORT int
83noop_renderer_init(struct weston_compositor *ec)
84{
85 struct weston_renderer *renderer;
Ander Conselvan de Oliveira11f8d402012-10-29 18:19:24 +020086
87 renderer = malloc(sizeof *renderer);
88 if (renderer == NULL)
89 return -1;
90
John Kåre Alsakera95b2d62012-11-13 19:10:21 +010091 renderer->read_pixels = noop_renderer_read_pixels;
Ander Conselvan de Oliveira11f8d402012-10-29 18:19:24 +020092 renderer->repaint_output = noop_renderer_repaint_output;
93 renderer->flush_damage = noop_renderer_flush_damage;
94 renderer->attach = noop_renderer_attach;
John Kåre Alsaker878f4492012-11-13 19:10:23 +010095 renderer->surface_set_color = noop_renderer_surface_set_color;
Vasily Khoruzhick52cfd612013-01-08 19:09:01 +030096 renderer->destroy = noop_renderer_destroy;
Ander Conselvan de Oliveira11f8d402012-10-29 18:19:24 +020097 ec->renderer = renderer;
98
99 return 0;
100}