|
|
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;
|
|
|
c7fa36 |
cl_kernel contour_clear_kernel;
|
|
|
c7fa36 |
cl_kernel contour_path_kernel;
|
|
|
f83e6b |
cl_kernel contour_fill_kernel;
|
|
|
f83e6b |
|
|
|
f83e6b |
Surface *surface;
|
|
|
c7fa36 |
cl_mem path_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();
|
|
|
c7fa36 |
void send_path(const vec2f *path, int count);
|
|
|
c7fa36 |
void path(int start, int count, const Color &color, bool invert, bool evenodd);
|
|
|
c7fa36 |
void wait();
|
|
|
572d9c |
};
|
|
|
572d9c |
|
|
|
572d9c |
|
|
|
572d9c |
class SwRenderAlt {
|
|
|
572d9c |
public:
|
|
|
572d9c |
struct Pixel {
|
|
|
572d9c |
Real area;
|
|
|
572d9c |
Real cover;
|
|
|
572d9c |
Pixel(): area(), cover() { }
|
|
|
572d9c |
void add(Real area, Real cover) { this->area += area; this->cover += cover; }
|
|
|
572d9c |
};
|
|
|
572d9c |
|
|
|
572d9c |
private:
|
|
|
572d9c |
std::vector<pixel> data;</pixel>
|
|
|
572d9c |
|
|
|
572d9c |
public:
|
|
|
572d9c |
const int width;
|
|
|
572d9c |
const int height;
|
|
|
572d9c |
|
|
|
572d9c |
SwRenderAlt(int width, int height): data(width*height), width(width), height(height) { }
|
|
|
572d9c |
|
|
|
572d9c |
Pixel* operator[] (int row) { return &data.front() + row*width; }
|
|
|
572d9c |
const Pixel* operator[] (int row) const { return &data.front() + row*width; }
|
|
|
572d9c |
|
|
|
572d9c |
void line(const Vector &p0, const Vector &p1);
|
|
|
572d9c |
};
|
|
|
572d9c |
|
|
|
572d9c |
#endif
|