[haiku-commits] Re: haiku: hrev47005 - src/kits/interface src/servers/app src/servers/app/drawing/Painter headers/private/interface src/servers/app/drawing

  • From: Stephan Aßmus <superstippi@xxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 11 Mar 2014 17:45:22 +0100

Hi,

Am 11.03.2014 17:26, schrieb pulkomandy@xxxxxxxxxxxxx:
eb43166: app_server & interface kit: support fill rules.

   * BView gets SetFillRule/FillRule methods. The fill rule is part of the
   view state.
   * The B_NONZERO rule is the default. This is what we implemented before.
   * The B_EVEN_ODD rule is the other common possibility for this, and
   we need to support it to help WebKit to render properly.

                              [ Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> ]

Nicely done, Adrien!

@@ -2827,16 +2835,22 @@ Painter::_RasterizePath(VertexSource& path) const
        if (fMaskedUnpackedScanline != NULL) {
                // TODO: we can't do both alpha-masking and subpixel AA.
                fRasterizer.reset();
+               fRasterizer.filling_rule(
+                       fFillRule == B_EVEN_ODD ? agg::fill_even_odd : 
agg::fill_non_zero);
                fRasterizer.add_path(path);
                agg::render_scanlines(fRasterizer, *fMaskedUnpackedScanline,
                        fRenderer);
        } else if (gSubpixelAntialiasing) {
                fSubpixRasterizer.reset();
+               fSubpixRasterizer.filling_rule(
+                       fFillRule == B_EVEN_ODD ? agg::fill_even_odd : 
agg::fill_non_zero);
                fSubpixRasterizer.add_path(path);
                agg::render_scanlines(fSubpixRasterizer,
                        fSubpixPackedScanline, fSubpixRenderer);
        } else {
                fRasterizer.reset();
+               fRasterizer.filling_rule(
+                       fFillRule == B_EVEN_ODD ? agg::fill_even_odd : 
agg::fill_non_zero);
                fRasterizer.add_path(path);
                agg::render_scanlines(fRasterizer, fPackedScanline, fRenderer);

This above can be improved. Instead of setting it each time a path is drawn, you can set it only in SetFillRule(), on all three rasterizers, and also call SetFillRule() from SetDrawState(). I think this may even be buggy now that I think about it, when you pop a state, the fill rule of the previous state is not restored, since you don't do anything in SetDrawState(). With that change, it should be perfect!

Best regards,
-Stephan



Other related posts: