Currently, every plot element is responsible for its own clipping. Many series use the DrawClippedXxx(...) extensions from the RenderingExtensions and that way sometimes set and reset clipping multiple times per render (example).
Also, when you render many Series sharing the same axes, it wouldn't really be necessary to set and reset clipping every time.
Since #1645, we have some potential to reduce the amount of calls to IRenderContext.PushClip(...) and IRenderContext.PopClip() by moving the responsibility for the clipping out of the Series and Annotations.
Specifically I propose to:
Why would this be desirable?
- Depending on the platform there could be a more or less significant performance penalty involved with every clipping
- The file size of vector-based exports (especially SVG) can get bloated by many redundant clipping calls
- Rendering code in
Series and Annotations could be simplified in some places, as it wouldn't have to worry about clipping any more
Potential Problems
- Removal of the
DrawClippedXxx(...) extensions will involve some breaking changes for custom implementations. Sure, we could also just keep these, but I'd like to make people aware that they shouldn't be concerned with clipping anymore when implementing custom Series / Annotations.
CandleStickAndVolumeSeries - this is a bit of a weird one, because really it's two series in one and therefore needs to set different clipping areas during rendering. I would suggest to do a (hacky) fix for now and mark this as obsolete... I think people should be better off using individual CandleStickSeries and VolumeSeries anyway.
- (more might emerge once I refine the proof-of-concept implementation I currently have)
I will put together a PR soon so we can talk more specifically about the proposed changes.
Currently, every plot element is responsible for its own clipping. Many series use the
DrawClippedXxx(...)extensions from theRenderingExtensionsand that way sometimes set and reset clipping multiple times per render (example).Also, when you render many
Seriessharing the same axes, it wouldn't really be necessary to set and reset clipping every time.Since #1645, we have some potential to reduce the amount of calls to
IRenderContext.PushClip(...)andIRenderContext.PopClip()by moving the responsibility for the clipping out of theSeriesandAnnotations.Specifically I propose to:
DrawClippedXxx(...)extensionsSeriesandAnnotations completely oblivious to clippingPlotModel.RenderAxes(...)andPlotModel.RenderAnnotations(...)respectively, avoiding setting and resetting where possibleWhy would this be desirable?
SeriesandAnnotationscould be simplified in some places, as it wouldn't have to worry about clipping any morePotential Problems
DrawClippedXxx(...)extensions will involve some breaking changes for custom implementations. Sure, we could also just keep these, but I'd like to make people aware that they shouldn't be concerned with clipping anymore when implementing customSeries/Annotations.CandleStickAndVolumeSeries- this is a bit of a weird one, because really it's two series in one and therefore needs to set different clipping areas during rendering. I would suggest to do a (hacky) fix for now and mark this as obsolete... I think people should be better off using individualCandleStickSeriesandVolumeSeriesanyway.I will put together a PR soon so we can talk more specifically about the proposed changes.