Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ol.style.Image classes should defer rendering to the layer renderer #5775

Closed
ahocevar opened this issue Aug 25, 2016 · 8 comments
Closed

ol.style.Image classes should defer rendering to the layer renderer #5775

ahocevar opened this issue Aug 25, 2016 · 8 comments
Labels

Comments

@ahocevar
Copy link
Member

Currently ol.style.Image subclasses render an image to an AtlasManager. Instead, layer renderers should decide what to do with the information stored in an Image style. For example in the case of ol.style.Circle, the Canvas renderer could more efficiently just render a circle with the provided radius, fill and stroke, instead of the style having to add an image to the AtlasManager for every radius-fill-stroke combination.

@ahocevar
Copy link
Member Author

Also see #5748.

@tschaub
Copy link
Member

tschaub commented Sep 11, 2016

Agreed. It would be nice if the AtlasManager became a WebGL specific thing.

@ahocevar
Copy link
Member Author

ahocevar commented Feb 15, 2017

@wglas85, if you want to work on this, here is a brief outline of what I have in mind:

1. Create a new ol.style.Shape class

A ol.style.Shape would be configured with a ol.Size and a ol.geom.Geometry (can also be a ol.geom.GeometryCollection. The geometry defines the shape in pixel space, bounded by a rectangle with extent [0, 0, size[0], size[1]].

2. Make ol.style.RegularShape inherit from ol.style.Shape

All rendering code can be removed, and the shape will be described as ol.geom.Geometry instead.

A related refactoring would be to merge ol.style.Icon and ol.style.Image into a single class.

3. Update point renderers

This change mostly involves ol.renderer.vector.renderPointGeometry_, ol.render.canvas.Immediate.prototype.drawPoint and ol.render.canvas.Immediate.prototype.drawPoint (and WebGL counterparts, if any). Now that ol.style.Style#getImage() can return an ol.stlye.Icon or an ol.style.Shape, we do not always get an already rendered image any more. These functions are now responsible for creating and caching images (and making an AtlasManger handle them for WebGL only) from the geometry and size defined in an ol.style.Shape. And they can use ol.render.toContext for that.

With these changes in place, ol.style.* classes do not perform any computations any more, and are just containers for properties. And AtlasManager will no longer be an implicit dependency of ol.style.RegularShape, reducing the size of builds that do not need a WebGL renderer.

@wglas85
Copy link

wglas85 commented Feb 19, 2017

@ahocevar could you please tell me how to temporarily activate the immediate canvas renderer, so I can start by implementing this bare-bone render without having to tackle all the replay complexities?

@ahocevar
Copy link
Member Author

You won't need to touch any code inside functions of the replay or immediate APIs. This change would be mostly about removing all rendering code from ol.style.RegularShape, and replacing it with ol.render.toContext calls in the functions I listed above (which are both higher level than the immediate and replay APIs.

wglas85 added a commit to wglas85/openlayers that referenced this issue Feb 25, 2017
@wglas85
Copy link

wglas85 commented Feb 25, 2017

@ahocevar I have performed first steps on this issue, there need some topics to be discussed, I'm going to arrange a meetup...

wglas85 added a commit to wglas85/openlayers that referenced this issue Feb 26, 2017
@wglas85
Copy link

wglas85 commented Feb 26, 2017

@ahocevar I made some more progress, we still have to decide on some topics, most notable the software layer at which we render the shapes to pixels, when needed and which scaling to apply...

wglas85 added a commit to wglas85/openlayers that referenced this issue Feb 28, 2017
wglas85 added a commit to wglas85/openlayers that referenced this issue Feb 28, 2017
@stale
Copy link

stale bot commented May 22, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label May 22, 2019
@stale stale bot closed this as completed May 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants