Changeset 18501 in josm for trunk/src/org/openstreetmap/josm/data/osm/visitor
- Timestamp:
- 2022-06-27T18:22:12+02:00 (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/AbstractMapRenderer.java
r18332 r18501 214 214 * @param p2 Second point of the way segment. 215 215 * @return <code>true</code> if segment may be visible. 216 * @see #isSegmentVisible(MapViewPoint, MapViewPoint, MapViewRectangle) for a more efficient version (cache the view) 216 217 * @since 10827 217 218 */ 218 219 protected boolean isSegmentVisible(MapViewPoint p1, MapViewPoint p2) { 219 MapViewRectangle view = mapState.getViewArea(); 220 return isSegmentVisible(p1, p2, mapState.getViewArea()); 221 } 222 223 /** 224 * Checks if segment is visible in display. 225 * 226 * @param p1 First point of the way segment. 227 * @param p2 Second point of the way segment. 228 * @param view The current view to check 229 * @return <code>true</code> if segment may be visible. 230 * @since 18501 231 */ 232 protected boolean isSegmentVisible(MapViewPoint p1, MapViewPoint p2, MapViewRectangle view) { 220 233 // not outside in the same direction 221 234 return (p1.getOutsideRectangleFlags(view) & p2.getOutsideRectangleFlags(view)) == 0; … … 233 246 Iterator<? extends INode> it = w.getNodes().iterator(); 234 247 MapViewPoint lastP = null; 248 // By moving this out of the for loop (in isSegmentVisible) 249 // MapViewState#getViewArea goes from ~56.5% of memory allocations to ~4.2% 250 // CPU samples also goes down from ~5.1% to ~2.9% 251 MapViewRectangle viewArea = mapState.getViewArea(); 235 252 while (it.hasNext()) { 236 253 INode n = it.next(); 237 254 if (n.isLatLonKnown()) { 238 255 MapViewPoint p = mapState.getPointFor(n); 239 if (lastP != null && isSegmentVisible(lastP, p ) && isLargeSegment(lastP, p, virtualNodeSpace)) {256 if (lastP != null && isSegmentVisible(lastP, p, viewArea) && isLargeSegment(lastP, p, virtualNodeSpace)) { 240 257 double x = (p.getInViewX()+lastP.getInViewX())/2; 241 258 double y = (p.getInViewY()+lastP.getInViewY())/2;
Note:
See TracChangeset
for help on using the changeset viewer.