« Return to Thread: Is it possible to perform this type of rendering?

Re: Is it possible to perform this type of rendering?

by Lorne Laliberte :: Rate this Message:

Reply to Author | View in Thread

I should clarify: in practical terms, the anti-aliasing coverage
information is preserved if you output onto a 32-bit surface with a
transparent background, i.e. a buffer that has been cleared with a
transparent color(0,0,0,0).

Lorne Laliberte
Senior Software Developer, Indigo Rose Software



2009/4/27 Lorne Laliberte <lorne@...>:

> You could also just render into a 32-bit buffer (RGBA, BGRA, or
> whatever suits your needs) and then blend that buffer onto your final
> output surface.
>
> That's what I'm doing in our app for a transparent GUI layer above the
> actual scene. It lets us draw whatever we want in the GUI layer
> (selection boxes, controls, etc.) without requiring any redraw within
> the scene.
>
> I'm using a custom dirty rectangle system to minimize the redraw areas
> in general, though.
>
> Lorne Laliberte
> Senior Software Developer, Indigo Rose Software
>
>
>
> On Mon, Apr 27, 2009 at 1:17 PM, Petr Kobalíček
> <kobalicek.petr@...> wrote:
>> Hi Vinnie,
>>
>> I don't know if I will help you, but I think that you should study
>> agg::rasterizer_scanline_aa<> class.
>>
>> For example I'm doing somethink like this in my library:
>>
>> // Types
>> typedef agg::rasterizer_scanline_aa<>         Rasterizer;
>> typedef agg::scanline_p8                      ScanlineP8;
>> typedef agg::scanline_u8                      ScanlineU8;
>>
>> 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());
>>
>>  int exty1 = d->_clipBox.y1();
>>  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();
>>
>>      // TODO: is this necessary?
>>      int y = sl.y();
>>      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;
>>      }
>>    }
>>  }
>> }
>>
>> You can see that by calling sweep_scanlines() you will gen spans with
>> coverage informations and you can do what you want with these spans.
>> I'm using this way to connect antigrain with BlitJit and the speed is
>> very promising.
>>
>> Cheers
>> - Petr
>>
>> 2009/4/27 Vinnie <thevinn@...>:
>>>
>>> Dear Group:
>>>
>>> I'm drawing a ton of cool-looking controls, sliders, and knobs with agg. Unfortunately all the gradient fills and anti-aliasing comes at the price of some speed. I want to cache certain un-changing elements into an offscreen bitmap. However, these elements have transparency information associated with them....so...
>>>
>>> I would first like to get an idea if what I need to do is possible with agg before I go delving in.
>>>
>>> Specifically, I want to create a new renderer (I think thats the component I need to modify) that instead of blending color values into the destination map using the coverage information, writes the color as a solid into the destination map, and stores the coverage information in a separate channel.
>>>
>>> In other words, produce the equivalent of a Photoshop Layer (red, green, and blue color planes plus one alpha channel for transparency) based on drawing output.
>>>
>>> For example if I draw an anti-aliased circle, I would want as my output to be a pure black circle in the RGB channels, with the coverage information going into the fourth channel (value=255 on the interior, and intermediate values 1-254 along the edge holding the coverage information).
>>>
>>> Would I do this by providing my own version of renderer_scanline_aa_solid? Is that the right class?
>>>
>>> Or does agg perhaps already have the ability to do this by some magic combination of nesting templates?
>>>
>>> Thanks!
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Crystal Reports - New Free Runtime and 30 Day Trial
>>> Check out the new simplified licensign option that enables unlimited
>>> royalty-free distribution of the report engine for externally facing
>>> server and web deployment.
>>> http://p.sf.net/sfu/businessobjects
>>> _______________________________________________
>>> Vector-agg-general mailing list
>>> Vector-agg-general@...
>>> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>>>
>>
>> ------------------------------------------------------------------------------
>> Crystal Reports - New Free Runtime and 30 Day Trial
>> Check out the new simplified licensign option that enables unlimited
>> royalty-free distribution of the report engine for externally facing
>> server and web deployment.
>> http://p.sf.net/sfu/businessobjects
>> _______________________________________________
>> Vector-agg-general mailing list
>> Vector-agg-general@...
>> https://lists.sourceforge.net/lists/listinfo/vector-agg-general
>>
>

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensign option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general

 « Return to Thread: Is it possible to perform this type of rendering?