/**
* Default implementation for rendering using CPU
*/
-void ObjectRenderer::RenderUsingCPU(const Objects & objects, const View & view, const CPURenderTarget & target)
+void ObjectRenderer::RenderUsingCPU(const Objects & objects, const View & view, const CPURenderTarget & target, unsigned first_obj_id, unsigned last_obj_id)
{
Error("Cannot render objects of type %d on CPU", m_type);
//TODO: Render a rect or something instead?
/**
* Rectangle (filled)
*/
-void RectFilledRenderer::RenderUsingCPU(const Objects & objects, const View & view, const CPURenderTarget & target)
+void RectFilledRenderer::RenderUsingCPU(const Objects & objects, const View & view, const CPURenderTarget & target, unsigned first_obj_id, unsigned last_obj_id)
{
for (unsigned i = 0; i < m_indexes.size(); ++i)
{
+ if (m_indexes[i] < first_obj_id) continue;
+ if (m_indexes[i] > last_obj_id) continue;
PixelBounds bounds(CPURenderBounds(objects.bounds[m_indexes[i]], view, target));
for (int64_t x = max(0L, bounds.x); x <= min(bounds.x+bounds.w, target.w-1); ++x)
{
/**
* Rectangle (outine)
*/
-void RectOutlineRenderer::RenderUsingCPU(const Objects & objects, const View & view, const CPURenderTarget & target)
+void RectOutlineRenderer::RenderUsingCPU(const Objects & objects, const View & view, const CPURenderTarget & target, unsigned first_obj_id, unsigned last_obj_id)
{
//Debug("Render %u outlined rectangles on CPU", m_indexes.size());
for (unsigned i = 0; i < m_indexes.size(); ++i)
{
+ if (m_indexes[i] < first_obj_id) continue;
+ if (m_indexes[i] > last_obj_id) continue;
PixelBounds bounds(CPURenderBounds(objects.bounds[m_indexes[i]], view, target));
// Using bresenham's lines now mainly because I want to see if they work
/**
* Circle (filled)
*/
-void CircleFilledRenderer::RenderUsingCPU(const Objects & objects, const View & view, const CPURenderTarget & target)
+void CircleFilledRenderer::RenderUsingCPU(const Objects & objects, const View & view, const CPURenderTarget & target, unsigned first_obj_id, unsigned last_obj_id)
{
for (unsigned i = 0; i < m_indexes.size(); ++i)
{
+ if (m_indexes[i] < first_obj_id) continue;
+ if (m_indexes[i] > last_obj_id) continue;
PixelBounds bounds(CPURenderBounds(objects.bounds[m_indexes[i]], view, target));
int64_t centre_x = bounds.x + bounds.w / 2;
int64_t centre_y = bounds.y + bounds.h / 2;
* Bezier curve
* Not sure how to apply De'Casteljau, will just use a bunch of Bresnham lines for now.
*/
-void BezierRenderer::RenderUsingCPU(const Objects & objects, const View & view, const CPURenderTarget & target)
+void BezierRenderer::RenderUsingCPU(const Objects & objects, const View & view, const CPURenderTarget & target, unsigned first_obj_id, unsigned last_obj_id)
{
//Warn("Rendering Beziers on CPU. Things may explode.");
for (unsigned i = 0; i < m_indexes.size(); ++i)
{
+ if (m_indexes[i] < first_obj_id) continue;
+ if (m_indexes[i] > last_obj_id) continue;
Rect bounds(CPURenderBounds(objects.bounds[m_indexes[i]], view, target));
PixelBounds pix_bounds(bounds);
static void SaveBMP(const CPURenderTarget & target, const char * filename);
- virtual void RenderUsingCPU(const Objects & objects, const View & view, const CPURenderTarget & target) = 0;
+ virtual void RenderUsingCPU(const Objects & objects, const View & view, const CPURenderTarget & target, unsigned first_obj_id, unsigned last_obj_id) = 0;
public:
RectFilledRenderer() : ObjectRenderer(RECT_FILLED, "shaders/rect_vert.glsl", "shaders/rect_frag.glsl","shaders/rect_filled_geom.glsl") {}
virtual ~RectFilledRenderer() {}
- virtual void RenderUsingCPU(const Objects & objects, const View & view, const CPURenderTarget & target);
+ virtual void RenderUsingCPU(const Objects & objects, const View & view, const CPURenderTarget & target, unsigned first_obj_id, unsigned last_obj_id);
};
/** Renderer for outlined rectangles **/
class RectOutlineRenderer : public ObjectRenderer
public:
RectOutlineRenderer() : ObjectRenderer(RECT_OUTLINE, "shaders/rect_vert.glsl", "shaders/rect_frag.glsl", "shaders/rect_outline_geom.glsl") {}
virtual ~RectOutlineRenderer() {}
- virtual void RenderUsingCPU(const Objects & objects, const View & view, const CPURenderTarget & target);
+ virtual void RenderUsingCPU(const Objects & objects, const View & view, const CPURenderTarget & target, unsigned first_obj_id, unsigned last_obj_id);
};
/** Renderer for filled circles **/
class CircleFilledRenderer : public ObjectRenderer
public:
CircleFilledRenderer() : ObjectRenderer(CIRCLE_FILLED, "shaders/rect_vert.glsl", "shaders/circle_frag.glsl", "shaders/circle_filled_geom.glsl") {}
virtual ~CircleFilledRenderer() {}
- virtual void RenderUsingCPU(const Objects & objects, const View & view, const CPURenderTarget & target);
+ virtual void RenderUsingCPU(const Objects & objects, const View & view, const CPURenderTarget & target, unsigned first_obj_id, unsigned last_obj_id);
};
/** Renderer for bezier curves **/
BezierRenderer() : ObjectRenderer(BEZIER, "shaders/rect_vert.glsl", "shaders/rect_frag.glsl", "shaders/bezier_texbuf_geom.glsl") {}
virtual ~BezierRenderer() {}
virtual void RenderUsingGPU(unsigned first_obj_id, unsigned last_obj_id);
- virtual void RenderUsingCPU(const Objects & objects, const View & view, const CPURenderTarget & target);
+ virtual void RenderUsingCPU(const Objects & objects, const View & view, const CPURenderTarget & target, unsigned first_obj_id, unsigned last_obj_id);
void PrepareBezierGPUBuffer(const Objects & objects);
private:
GraphicsBuffer m_bezier_coeffs;
for (unsigned i = 0; i < m_object_renderers.size(); ++i)
{
- m_object_renderers[i]->RenderUsingCPU(m_document.m_objects, *this, {m_cpu_rendering_pixels, width, height});
+ m_object_renderers[i]->RenderUsingCPU(m_document.m_objects, *this, {m_cpu_rendering_pixels, width, height}, first_obj, last_obj);
}
m_screen.RenderPixels(0,0,width, height, m_cpu_rendering_pixels); //TODO: Make this work :(
// Debug for great victory (do something similar for GPU and compare?)