Blame c++/contourgl/clrender.h

572d9c
/*
572d9c
    ......... 2015 Ivan Mahonin
572d9c
572d9c
    This program is free software: you can redistribute it and/or modify
572d9c
    it under the terms of the GNU General Public License as published by
572d9c
    the Free Software Foundation, either version 3 of the License, or
572d9c
    (at your option) any later version.
572d9c
572d9c
    This program is distributed in the hope that it will be useful,
572d9c
    but WITHOUT ANY WARRANTY; without even the implied warranty of
572d9c
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
572d9c
    GNU General Public License for more details.
572d9c
572d9c
    You should have received a copy of the GNU General Public License
572d9c
    along with this program.  If not, see <http: licenses="" www.gnu.org="">.</http:>
572d9c
*/
572d9c
572d9c
#ifndef _RASTERIZER_H_
572d9c
#define _RASTERIZER_H_
572d9c
572d9c
#include <vector></vector>
572d9c
572d9c
#include "clcontext.h"
572d9c
#include "geometry.h"
572d9c
#include "contour.h"
572d9c
#include "swrender.h"
572d9c
572d9c
572d9c
class ClRender {
f83e6b
private:
572d9c
	ClContext &cl;
f83e6b
	cl_program contour_program;
013f0c
	cl_kernel contour_draw_kernel;
2517eb
	size_t contour_draw_workgroup_size;
f83e6b
f83e6b
	Surface *surface;
013f0c
	cl_mem paths_buffer;
f83e6b
	cl_mem mark_buffer;
67876c
	cl_mem surface_image;
028154
	cl_event prev_event;
572d9c
f83e6b
public:
572d9c
	ClRender(ClContext &cl);
572d9c
	~ClRender();
572d9c
f83e6b
	void send_surface(Surface *surface);
f83e6b
	Surface* receive_surface();
013f0c
	void send_paths(const void *paths, int size);
2517eb
	void remove_paths();
013f0c
	void draw();
c7fa36
	void wait();
572d9c
};
572d9c
572d9c
b09c5d
class ClRender2 {
b09c5d
public:
b09c5d
	struct Path {
b09c5d
		Color color;
b09c5d
		int invert;
b09c5d
		int evenodd;
b09c5d
		int align0;
b09c5d
		int align1;
b09c5d
	};
b09c5d
b09c5d
	struct Point {
b09c5d
		vec2f coord;
b09c5d
		int path_index;
b09c5d
		int align0;
b09c5d
	};
b09c5d
b09c5d
private:
b09c5d
	ClContext &cl;
b09c5d
	cl_program contour_program;
b09c5d
	cl_kernel contour_reset_kernel;
b09c5d
	cl_kernel contour_paths_kernel;
b09c5d
	cl_kernel contour_draw_kernel;
b09c5d
b09c5d
	Surface *surface;
b09c5d
	int points_count;
b09c5d
	cl_mem paths_buffer;
b09c5d
	cl_mem points_buffer;
b09c5d
	cl_mem samples_buffer;
b09c5d
	cl_mem surface_image;
b09c5d
	cl_event prev_event;
b09c5d
b09c5d
public:
b09c5d
	ClRender2(ClContext &cl);
b09c5d
	~ClRender2();
b09c5d
b09c5d
	void send_surface(Surface *surface);
b09c5d
	Surface* receive_surface();
b09c5d
	void remove_surface();
b09c5d
b09c5d
	void send_paths(const Path *paths, int paths_count, const Point *points, int points_count);
b09c5d
	void remove_paths();
b09c5d
b09c5d
	void draw();
b09c5d
	void wait();
b09c5d
};
b09c5d
b09c5d
572d9c
#endif