11
11
#include < cmath>
12
12
#include < algorithm>
13
13
#include < functional>
14
+ #include < vector>
14
15
15
16
#include " agg_alpha_mask_u8.h"
16
17
#include " agg_conv_curve.h"
@@ -102,8 +103,6 @@ class BufferRegion
102
103
int stride;
103
104
};
104
105
105
- #define MARKER_CACHE_SIZE 512
106
-
107
106
// the renderer
108
107
class RendererAgg
109
108
{
@@ -539,22 +538,14 @@ inline void RendererAgg::draw_markers(GCAgg &gc,
539
538
rendererBase.reset_clipping (true );
540
539
agg::rect_i marker_size (0x7FFFFFFF , 0x7FFFFFFF , -0x7FFFFFFF , -0x7FFFFFFF );
541
540
542
- agg::int8u staticFillCache[MARKER_CACHE_SIZE];
543
- agg::int8u staticStrokeCache[MARKER_CACHE_SIZE];
544
- agg::int8u *fillCache = staticFillCache;
545
- agg::int8u *strokeCache = staticStrokeCache;
546
-
547
541
try
548
542
{
549
- unsigned fillSize = 0 ;
543
+ std::vector<agg::int8u> fillBuffer ;
550
544
if (face.first ) {
551
545
theRasterizer.add_path (marker_path_curve);
552
546
agg::render_scanlines (theRasterizer, slineP8, scanlines);
553
- fillSize = scanlines.byte_size ();
554
- if (fillSize >= MARKER_CACHE_SIZE) {
555
- fillCache = new agg::int8u[fillSize];
556
- }
557
- scanlines.serialize (fillCache);
547
+ fillBuffer.resize (scanlines.byte_size ());
548
+ scanlines.serialize (fillBuffer.data ());
558
549
marker_size = agg::rect_i (scanlines.min_x (),
559
550
scanlines.min_y (),
560
551
scanlines.max_x (),
@@ -569,11 +560,8 @@ inline void RendererAgg::draw_markers(GCAgg &gc,
569
560
theRasterizer.reset ();
570
561
theRasterizer.add_path (stroke);
571
562
agg::render_scanlines (theRasterizer, slineP8, scanlines);
572
- unsigned strokeSize = scanlines.byte_size ();
573
- if (strokeSize >= MARKER_CACHE_SIZE) {
574
- strokeCache = new agg::int8u[strokeSize];
575
- }
576
- scanlines.serialize (strokeCache);
563
+ std::vector<agg::int8u> strokeBuffer (scanlines.byte_size ());
564
+ scanlines.serialize (strokeBuffer.data ());
577
565
marker_size = agg::rect_i (std::min (marker_size.x1 , scanlines.min_x ()),
578
566
std::min (marker_size.y1 , scanlines.min_y ()),
579
567
std::max (marker_size.x2 , scanlines.max_x ()),
@@ -619,11 +607,11 @@ inline void RendererAgg::draw_markers(GCAgg &gc,
619
607
620
608
if (face.first ) {
621
609
ren.color (face.second );
622
- sa.init (fillCache, fillSize , x, y);
610
+ sa.init (fillBuffer. data (), fillBuffer. size () , x, y);
623
611
agg::render_scanlines (sa, sl, ren);
624
612
}
625
613
ren.color (gc.color );
626
- sa.init (strokeCache, strokeSize , x, y);
614
+ sa.init (strokeBuffer. data (), strokeBuffer. size () , x, y);
627
615
agg::render_scanlines (sa, sl, ren);
628
616
}
629
617
} else {
@@ -647,32 +635,23 @@ inline void RendererAgg::draw_markers(GCAgg &gc,
647
635
648
636
if (face.first ) {
649
637
rendererAA.color (face.second );
650
- sa.init (fillCache, fillSize , x, y);
638
+ sa.init (fillBuffer. data (), fillBuffer. size () , x, y);
651
639
agg::render_scanlines (sa, sl, rendererAA);
652
640
}
653
641
654
642
rendererAA.color (gc.color );
655
- sa.init (strokeCache, strokeSize , x, y);
643
+ sa.init (strokeBuffer. data (), strokeBuffer. size () , x, y);
656
644
agg::render_scanlines (sa, sl, rendererAA);
657
645
}
658
646
}
659
647
}
660
648
catch (...)
661
649
{
662
- if (fillCache != staticFillCache)
663
- delete[] fillCache;
664
- if (strokeCache != staticStrokeCache)
665
- delete[] strokeCache;
666
650
theRasterizer.reset_clipping ();
667
651
rendererBase.reset_clipping (true );
668
652
throw ;
669
653
}
670
654
671
- if (fillCache != staticFillCache)
672
- delete[] fillCache;
673
- if (strokeCache != staticStrokeCache)
674
- delete[] strokeCache;
675
-
676
655
theRasterizer.reset_clipping ();
677
656
rendererBase.reset_clipping (true );
678
657
}
0 commit comments