Ticket #2802 (closed feature: fixed)

Opened 3 years ago

Last modified 2 years ago

New SVG2 renderer for modern browsers

Reported by: ahocevar Owned by:
Priority: minor Milestone: 2.11 Release
Component: Renderer Version: 2.9
Keywords: Cc:
State: Commit

Description

The attached patch proposes an SVG2 renderer. This comes without workarounds that we needed for older browsers, and it uses native coordinates. It also uses the map's maxExtent as drawing board, so there is no need to redraw features after a pan. Because the SVG coordinate system never changes, there is no need to redraw features when the zoom changes.

The patch is a snapshot of the development in my  renderer-ng sandbox, as a start for further vector rendering improvements targeted towards OL 3.0.

Patch comes with tests, a new performance test, and more examples that support the ?renderer=<Renderer> url option.

Setting milestone to 2.10, because with this patch, the new renderer will not be used unless a Vector layer is configured to do so. So there is no danger of introducing a regression, and it would give us the chance to get feedback from users. If anyone disagrees, please set the milestone back to 2.11.

Thanks for any review.

Attachments

openlayers-2802.patch Download (60.7 KB) - added by ahocevar 3 years ago.
SVG2.js Download (31.6 KB) - added by reluc 3 years ago.
An other SVG2 implementation
openlayers-2802.2.patch Download (55.8 KB) - added by ahocevar 3 years ago.
Now use the same supports method as in Renderer.SVG (as discussed with crschmidt), and made dasharrays resolution aware (as pointed out by reluc)
openlayers-2802.3.patch Download (62.2 KB) - added by ahocevar 3 years ago.
layer.redraw() needs to set drawn to false to make sure that all features get redrawn
vector.patch Download (61.3 KB) - added by crschmidt 2 years ago.
openlayers-2802.4.patch Download (63.8 KB) - added by ahocevar 2 years ago.
with updates from Renderer.SVG

Change History

Changed 3 years ago by ahocevar

Changed 3 years ago by reluc

An other SVG2 implementation

Changed 3 years ago by reluc

Proposing an other SVG2 implementation.

Like ahocevar this SVG rendering uses native coordinates. Each geometry has been drawn once, but for Browser optimization the renderer update viewbox and features style.

Changed 3 years ago by reluc

The real difference between the twice implementation is the definition of the width and height of the SVG root element.

In ahocevar implementation the width and height is based on the extent and the resolution, in my case the width and height are the same as the map. I didn't change the method setStyle.

Changed 3 years ago by ahocevar

Now use the same supports method as in Renderer.SVG (as discussed with crschmidt), and made dasharrays resolution aware (as pointed out by reluc)

Changed 3 years ago by ahocevar

layer.redraw() needs to set drawn to false to make sure that all features get redrawn

Changed 2 years ago by crschmidt

Changed 2 years ago by crschmidt

  • state changed from Review to Commit

Updated patch to apply to trunk.

Having reviewed these changes, I feel that it is low risk to include this in trunk without turning it on by default. Once it's in, we can discuss perhaps setting the live examples on OL.org to use this renderer in the default chain, and see if we get some complaints from people. There is a very obvious and significant speedup on zooming with many features, and I think that for the browsers which support SVG on the mobile side, this might be a potential significant improvement.

Changed 2 years ago by ahocevar

Thanks for the review crschmidt. I need to pull in some bugfixes from the traditional SVG renderer before this can be committed. Will commit once this is done.

Changed 2 years ago by ahocevar

with updates from Renderer.SVG

Changed 2 years ago by ahocevar

  • status changed from new to closed
  • resolution set to fixed

(In [11616]) New SVG2 renderer for increased performance and smaller library size. Not enabled by default. To use, include 'SVG2' in the renderers array of your OpenLayers.Layer.Vector instance. r=crschmidt (closes #2802)

Note: See TracTickets for help on using tickets.