コード例 #1
0
ファイル: simple-shm.c プロジェクト: DaRamirezSoto/weston
static void
redraw(void *data, struct wl_callback *callback, uint32_t time)
{
	struct window *window = data;
	struct buffer *buffer;

	buffer = window_next_buffer(window);
	if (!buffer) {
		fprintf(stderr,
			!callback ? "Failed to create the first buffer.\n" :
			"Both buffers busy at redraw(). Server bug?\n");
		abort();
	}

	paint_pixels(buffer->shm_data, 20, window->width, window->height, time);

	wl_surface_attach(window->surface, buffer->buffer, 0, 0);
	wl_surface_damage(window->surface,
			  20, 20, window->width - 40, window->height - 40);

	if (callback)
		wl_callback_destroy(callback);

	window->callback = wl_surface_frame(window->surface);
	wl_callback_add_listener(window->callback, &frame_listener, window);
	wl_surface_commit(window->surface);
	buffer->busy = 1;
}
コード例 #2
0
ファイル: test1.c プロジェクト: arthurfait/pilot_wtk
int canvas_draw(void *draw_data, struct pilot_blit *blit)
{
	struct mycanvas_data *data = draw_data;
	uint32_t w, h;
	int change = data->change;
	LOG_DEBUG("");
	data->change += 16;
	paint_pixels(blit->data, 20, blit->rect.w, blit->rect.h, data->change);
	return (change != data->change);
}
コード例 #3
0
ファイル: test1.cpp プロジェクト: darkenk/wayland-test
int main(int argc, char **argv) {

    display = wl_display_connect(NULL);
    if (display == NULL) {
        fprintf(stderr, "Can't connect to display\n");
        exit(1);
    }
    printf("connected to display\n");

    struct wl_registry *registry = wl_display_get_registry(display);
    wl_registry_add_listener(registry, &registry_listener, NULL);

    wl_display_dispatch(display);
    wl_display_roundtrip(display);

    if (compositor == NULL) {
        fprintf(stderr, "Can't find compositor\n");
        exit(1);
    } else {
        fprintf(stderr, "Found compositor\n");
    }

    surface = wl_compositor_create_surface(compositor);
    if (surface == NULL) {
        fprintf(stderr, "Can't create surface\n");
        exit(1);
    } else {
        fprintf(stderr, "Created surface\n");
    }

    shell_surface = wl_shell_get_shell_surface(shell, surface);
    if (shell_surface == NULL) {
        fprintf(stderr, "Can't create shell surface\n");
        exit(1);
    } else {
        fprintf(stderr, "Created shell surface\n");
    }
    wl_shell_surface_set_toplevel(shell_surface);

    wl_shell_surface_add_listener(shell_surface,
                                  &shell_surface_listener, NULL);


    create_window();
    paint_pixels();

    while (wl_display_dispatch(display) != -1) {
        ;
    }

    wl_display_disconnect(display);
    printf("disconnected from display\n");

    exit(0);
}
コード例 #4
0
ファイル: test1-2.c プロジェクト: arthurfait/pilot_wtk
int canvas_draw(void *draw_data, struct pilot_blit *blit)
{
	struct mycanvas_data *data = draw_data;
	uint32_t w, h;
	LOG_DEBUG("");
	data->change += data->incr;
	paint_pixels(blit->data, 20, blit->rect.w, blit->rect.h, data->change);
	// we return 0 to not force the redraw at the next frame return
	// thread_run does the redraw instead
	return 0;
}
コード例 #5
0
	void XdevLWindowWayland::onPaint() {
		wl_callback_destroy(m_frameCallback);
		XdevLWindowPosition position = getPosition();
		XdevLWindowSize size = getSize();
		wl_surface_damage(m_surface, position.x, position.y, size.width, size.height);

		paint_pixels();

		m_frameCallback = wl_surface_frame(m_surface);
		wl_surface_attach(m_surface, m_buffer, 0, 0);


		wl_callback_add_listener(m_frameCallback, &frame_listener, this);

		wl_surface_commit(m_surface);
	}
コード例 #6
0
ファイル: simple-shm.c プロジェクト: Blei/weston
static void
redraw(void *data, struct wl_callback *callback, uint32_t time)
{
	struct window *window = data;

	paint_pixels(window->shm_data, window->width, window->height, time);
	wl_surface_attach(window->surface, window->buffer, 0, 0);
	wl_surface_damage(window->surface,
			  0, 0, window->width, window->height);

	if (callback)
		wl_callback_destroy(callback);

	window->callback = wl_surface_frame(window->surface);
	wl_callback_add_listener(window->callback, &frame_listener, window);
}
コード例 #7
0
ファイル: mandelbrot.cpp プロジェクト: tfc/mandelbrot_maps
void paint_part(const unsigned total_width, const unsigned total_height,
		const unsigned total_chunks_x, const unsigned total_chunks_y,
		const unsigned chunk_x, const unsigned chunk_y,
		const unsigned iterations,
		const std::string filename_prefix,
		const bool mirror_optimization)
{
	const unsigned img_width = total_width / total_chunks_x;
	const unsigned img_height = total_height / total_chunks_y;

	const unsigned start_x = img_width * chunk_x;
	const unsigned start_y = img_height * chunk_y;

	const unsigned chunk_y_mirror = total_chunks_y - 1 - chunk_y;

	JpegMap img(img_width, img_height);
	JpegMap img_mirror;
	if (mirror_optimization) 
		img_mirror.reinit(img_width, img_height);

	int maxval = paint_pixels(total_width, total_height,
			img_width, img_height,
			start_x, start_y,
			0, img_width,
			0, img_height,
			iterations,
			img, img_mirror);

	// If valcnt is zero, then every pixel is black.
	// Don't waste disk space for that.
	if (maxval < 5) return;

	img.blur();
	img_mirror.blur();

	{
	std::stringstream file;
	file << filename_prefix << "mb_" << chunk_x << "_" << chunk_y << ".jpg";
	img.write_jpeg_file(file.str().c_str(), 95);
	}

	if (mirror_optimization) {
		std::stringstream file;
		file << filename_prefix << "mb_" << chunk_x << "_" << chunk_y_mirror << ".jpg";
		img_mirror.write_jpeg_file(file.str().c_str(), 95);
	}
}
コード例 #8
0
ファイル: mandelbrot.cpp プロジェクト: tfc/mandelbrot_maps
static inline double paint_pixels(const unsigned total_width, const unsigned total_height,
		const unsigned img_width, const unsigned img_height,
		const unsigned start_x, const unsigned start_y,
		const unsigned lx, const unsigned rx,
		const unsigned uy, const unsigned ly,
		const unsigned iterations,
		JpegMap &img, JpegMap &img_mirror)
{
	if (std::min(rx-lx, ly-uy) < 10) {
		double maxval = 0;
		for (int y=uy; y < ly; ++y) {
			for (int x=lx; x < rx; ++x) {
				const double val = paint_pixel(total_width, total_height,
				img_width, img_height,
				start_x, x,
				start_y, y,
				iterations, img, img_mirror);

				maxval = std::max(val, maxval);
			}
		}
		return maxval;
	}
	if (rx <= lx || ly <= uy) return 0;

	double maxdiff = 0;
	cmplx z;
	const cmplx pos = complex_coord(total_width, total_height, start_x, start_y);
	const int firstval = mandelbrot_iterations(pos, iterations, z);

	for (int y = uy+1; y < ly - 1; ++y) {
		// Left column
		const int val = paint_pixel(total_width, total_height,
				img_width, img_height,
				start_x, lx,
				start_y, y,
				iterations, img, img_mirror);
		// Right column
		const int val2 = paint_pixel(total_width, total_height,
				img_width, img_height,
				start_x, rx-1,
				start_y, y,
				iterations, img, img_mirror);
		maxdiff = std::max(maxdiff, std::fabs(val - firstval));
		maxdiff = std::max(maxdiff, std::fabs(val2 - firstval));
	}

	for (int x = lx; x < rx; ++x) {
		// Upper row
		const int val = paint_pixel(total_width, total_height,
				img_width, img_height,
				start_x, x,
				start_y, uy,
				iterations, img, img_mirror);
		// Lower row
		const int val2 = paint_pixel(total_width, total_height,
				img_width, img_height,
				start_x, x,
				start_y, ly-1,
				iterations, img, img_mirror);
		maxdiff = std::max(maxdiff, std::fabs(val - firstval));
		maxdiff = std::max(maxdiff, std::fabs(val2 - firstval));
	}

	if (maxdiff == 0) {
		const RgbColor col = rgb_mandelbrot(firstval, iterations, z);
		for (int y=uy; y < ly; ++y) {
			for (int x=lx; x < rx; ++x) {
				img.setPixel(x, y, col);
				img_mirror.setPixel(x, img_height - 1 - y, col);
			}
		}

		return firstval;
	}

	const unsigned mx = (rx + lx) / 2;
	const unsigned my = (ly + uy) / 2;

	int maxval = 0;
	int ret;

	// Upper left
	ret = paint_pixels(total_width, total_height,
			img_width, img_height,
			start_x, start_y,
			lx+1, mx, uy+1, my,
			iterations,
			img, img_mirror);
	maxval = std::max(ret, maxval);
	// Upper right
	ret = paint_pixels(total_width, total_height,
			img_width, img_height,
			start_x, start_y,
			mx, rx-1, uy+1, my,
			iterations,
			img, img_mirror);
	maxval = std::max(ret, maxval);
	// Lower left
	ret = paint_pixels(total_width, total_height,
			img_width, img_height,
			start_x, start_y,
			lx, mx, my, ly-1,
			iterations,
			img, img_mirror);
	maxval = std::max(ret, maxval);
	// Lower right
	ret = paint_pixels(total_width, total_height,
			img_width, img_height,
			start_x, start_y,
			mx, rx-1, my, ly-1,
			iterations,
			img, img_mirror);
	maxval = std::max(ret, maxval);

	return maxval;
}