Hi stefan,
thanks for reply. To give you basic understanding what I'm doing I
will show you snippet of code:
template<int BytesPerPixel, class Rasterizer, class Scanline>
static void FOG_OPTIMIZEDCALL AggRenderScanlines(RasterPainterDevice*
d, Rasterizer& ras, Scanline& sl)
{
if (!ras.rewind_scanlines()) return;
uint8_t* pBase = d->_workRaster;
uint8_t* pRas;
uint8_t* pCur;
sysint_t stride = d->_stride;
sl.reset(ras.min_x(), ras.max_x());
// TODO: Not needed ?
// int extx1 = painter_d->_realRegion.extents().x1();
// int exty1 = d->_clipBox.y1();
// int extx2 = painter_d->_realRegion.extents().x2();
// int exty2 = d->_clipBox.y2();
FillSpan fillSpan = d->_fillFuncs.fillSpan;
FillSpanM fillSpanM_A8 = d->_fillFuncs.fillSpanM_A8;
// solid source
if (1)
{
while (ras.sweep_scanline(sl))
{
unsigned num_spans = sl.num_spans();
typename Scanline::const_iterator span = sl.begin();
sysint_t y = sl.y();
// TODO: Not needed ?
// Vertical clipping to extents.
// if (y < exty1) continue;
// if (y >= exty2) break;
pRas = pBase + y * stride;
for (;;)
{
int x = span->x;
int len = span->len;
pCur = pRas + Raster::mul<int, BytesPerPixel>(x);
if (len > 0)
{
fillSpanM_A8(pCur, &d->_source, span->covers, (unsigned)len);
}
else
{
len = -len;
FOG_ASSERT(len > 0);
uint32_t cover = (uint32_t)*(span->covers);
if (cover == 0xFF)
{
fillSpan(pCur, &d->_source, len);
}
else
{
uint32_t t = Raster::bytemul(d->_source.i, cover);
fillSpan(pCur, &t, len);
}
}
if (--num_spans == 0) break;
++span;
}
}
}
}
This is function that renders content using antigrain rasterizer and
BlitJit jit optimized fillers/blitters. I will probably create own
rasterizer class and I will try some optimizations (I have some
ideas), but currently I'm finding bug in my code that causes sometimes
invalid writes (I'm using valgrind to profile it) so I wondered if
this can happen through clipping.
Btw: the posted function is called from this:
void RasterPainterDevice::_renderPath(const Path& path, bool stroke)
{
AggPath aggPath(path);
ConvCurve curvesPath(aggPath);
_ras.reset();
_ras.filling_rule(static_cast<agg::filling_rule_e>(_fillMode));
_ras.clip_box(
(double)_clipBox.x1(),
(double)_clipBox.y1(),
(double)_clipBox.x2()-0.000001,
(double)_clipBox.y2()-0.000001);
// This can be a bit messy, but it's here to increase performance. We will
// not calculate using transformations if they are not used. Also we add
// stroke and line dash pipeline only if it's needed. This is goal of
// AntiGrain to be able to setup only pipelines what are really need.
if (_transformationsUsed)
{
if (stroke)
{
ConvStroke strokePath(curvesPath);
ConvStrokeTransform strokeTransform(
strokePath, *((agg::trans_affine *)&_transformations));
strokePath.width(_lineWidth);
strokePath.line_join(static_cast<agg::line_join_e>(_lineJoin));
strokePath.line_cap(static_cast<agg::line_cap_e>(_lineCap));
strokePath.miter_limit(_miterLimit);
_ras.add_path(strokeTransform);
}
else
{
ConvCurveTransform curvesTransform(
curvesPath, *((agg::trans_affine *)&_transformations));
_ras.add_path(curvesTransform);
}
}
else
{
if (stroke)
{
ConvStroke strokePath(curvesPath);
strokePath.width(_lineWidth);
strokePath.line_join(static_cast<agg::line_join_e>(_lineJoin));
strokePath.line_cap(static_cast<agg::line_cap_e>(_lineCap));
strokePath.miter_limit(_miterLimit);
_ras.add_path(strokePath);
}
else
{
_ras.add_path(curvesPath);
}
}
AggRenderScanlines<4, Rasterizer, ScanlineP8>(this, _ras, _slP8);
}
I only think that there should be way how to clip to pixel units,
because windowing systems and painters usually contains pixel based
clipping (my painter too) and converting this to double to convert it
back to pixels in rasterizer seems to be a bit hacky :) But antigrain
is nice library to play with, I really think it's powerful, because if
I need I can replace any part to fit my needs:)
- Petr
2009/4/30 Stephan Aßmus <
superstippi@...>:
> Petr Kobalíček schrieb:
>> is there way to set clipping to rasterizer in pixel based coordinates?
>>
>> I'm working with agg::rasterizer_scanline_aa and there is method void
>> clip_box(double x1, double y1, double x2, double y2),
>> if I use for example clip_box(1.0, 1.0, 4.0, 4.0) is there chance that
>> there will be some content in scanlines outside these bounds (I mean
>> something with 0 cover) ?
>
> AFAIK, there should not be any pixels rendered outside these bounds.
>
>> Note: I'm using this rasterizer instead of other classes that's using
>> it to render real content.
>
> What is the actual problem that you observe?
>
> Best regards,
> -Stephan
>
> ------------------------------------------------------------------------------
> Register Now & Save for Velocity, the Web Performance & Operations
> Conference from O'Reilly Media. Velocity features a full day of
> expert-led, hands-on workshops and two days of sessions from industry
> leaders in dedicated Performance & Operations tracks. Use code vel09scf
> and Save an extra 15% before 5/3.
http://p.sf.net/sfu/velocityconf> _______________________________________________
> Vector-agg-general mailing list
>
Vector-agg-general@...
>
https://lists.sourceforge.net/lists/listinfo/vector-agg-general>
------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations
Conference from O'Reilly Media. Velocity features a full day of
expert-led, hands-on workshops and two days of sessions from industry
leaders in dedicated Performance & Operations tracks. Use code vel09scf
and Save an extra 15% before 5/3.
http://p.sf.net/sfu/velocityconf_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general