42 * and then passes them on to a CompositePipe object for painting. |
42 * and then passes them on to a CompositePipe object for painting. |
43 */ |
43 */ |
44 public final class AAShapePipe |
44 public final class AAShapePipe |
45 implements ShapeDrawPipe, ParallelogramPipe |
45 implements ShapeDrawPipe, ParallelogramPipe |
46 { |
46 { |
47 static final RenderingEngine renderengine = RenderingEngine.getInstance(); |
47 static final RenderingEngine RDR_ENGINE = RenderingEngine.getInstance(); |
48 |
48 |
49 // Per-thread TileState (~1K very small so do not use any Weak Reference) |
49 // Per-thread TileState (~1K very small so do not use any Weak Reference) |
50 private static final ReentrantContextProvider<TileState> tileStateProvider = |
50 private static final ReentrantContextProvider<TileState> TILE_STATE_PROVIDER = |
51 new ReentrantContextProviderTL<TileState>( |
51 new ReentrantContextProviderTL<TileState>( |
52 ReentrantContextProvider.REF_HARD) |
52 ReentrantContextProvider.REF_HARD) |
53 { |
53 { |
54 @Override |
54 @Override |
55 protected TileState newContext() { |
55 protected TileState newContext() { |
88 double ux2, double uy2, |
88 double ux2, double uy2, |
89 double x, double y, |
89 double x, double y, |
90 double dx1, double dy1, |
90 double dx1, double dy1, |
91 double dx2, double dy2) |
91 double dx2, double dy2) |
92 { |
92 { |
93 final TileState ts = tileStateProvider.acquire(); |
93 final TileState ts = TILE_STATE_PROVIDER.acquire(); |
94 try { |
94 try { |
95 final int[] abox = ts.abox; |
95 final int[] abox = ts.abox; |
96 |
96 |
97 final AATileGenerator aatg = |
97 final AATileGenerator aatg = |
98 renderengine.getAATileGenerator(x, y, dx1, dy1, dx2, dy2, 0, 0, |
98 RDR_ENGINE.getAATileGenerator(x, y, dx1, dy1, dx2, dy2, 0, 0, |
99 sg.getCompClip(), abox); |
99 sg.getCompClip(), abox); |
100 if (aatg != null) { |
100 if (aatg != null) { |
101 renderTiles(sg, ts.computeBBox(ux1, uy1, ux2, uy2), |
101 renderTiles(sg, ts.computeBBox(ux1, uy1, ux2, uy2), |
102 aatg, abox, ts); |
102 aatg, abox, ts); |
103 } |
103 } |
104 } finally { |
104 } finally { |
105 tileStateProvider.release(ts); |
105 TILE_STATE_PROVIDER.release(ts); |
106 } |
106 } |
107 } |
107 } |
108 |
108 |
109 @Override |
109 @Override |
110 public void drawParallelogram(SunGraphics2D sg, |
110 public void drawParallelogram(SunGraphics2D sg, |
113 double x, double y, |
113 double x, double y, |
114 double dx1, double dy1, |
114 double dx1, double dy1, |
115 double dx2, double dy2, |
115 double dx2, double dy2, |
116 double lw1, double lw2) |
116 double lw1, double lw2) |
117 { |
117 { |
118 final TileState ts = tileStateProvider.acquire(); |
118 final TileState ts = TILE_STATE_PROVIDER.acquire(); |
119 try { |
119 try { |
120 final int[] abox = ts.abox; |
120 final int[] abox = ts.abox; |
121 |
121 |
122 final AATileGenerator aatg = |
122 final AATileGenerator aatg = |
123 renderengine.getAATileGenerator(x, y, dx1, dy1, dx2, dy2, lw1, |
123 RDR_ENGINE.getAATileGenerator(x, y, dx1, dy1, dx2, dy2, lw1, |
124 lw2, sg.getCompClip(), abox); |
124 lw2, sg.getCompClip(), abox); |
125 if (aatg != null) { |
125 if (aatg != null) { |
126 // Note that bbox is of the original shape, not the wide path. |
126 // Note that bbox is of the original shape, not the wide path. |
127 // This is appropriate for handing to Paint methods... |
127 // This is appropriate for handing to Paint methods... |
128 renderTiles(sg, ts.computeBBox(ux1, uy1, ux2, uy2), |
128 renderTiles(sg, ts.computeBBox(ux1, uy1, ux2, uy2), |
129 aatg, abox, ts); |
129 aatg, abox, ts); |
130 } |
130 } |
131 } finally { |
131 } finally { |
132 tileStateProvider.release(ts); |
132 TILE_STATE_PROVIDER.release(ts); |
133 } |
133 } |
134 } |
134 } |
135 |
135 |
136 public void renderPath(SunGraphics2D sg, Shape s, BasicStroke bs) { |
136 public void renderPath(SunGraphics2D sg, Shape s, BasicStroke bs) { |
137 final boolean adjust = (bs != null && |
137 final boolean adjust = (bs != null && |
138 sg.strokeHint != SunHints.INTVAL_STROKE_PURE); |
138 sg.strokeHint != SunHints.INTVAL_STROKE_PURE); |
139 final boolean thin = (sg.strokeState <= SunGraphics2D.STROKE_THINDASHED); |
139 final boolean thin = (sg.strokeState <= SunGraphics2D.STROKE_THINDASHED); |
140 |
140 |
141 final TileState ts = tileStateProvider.acquire(); |
141 final TileState ts = TILE_STATE_PROVIDER.acquire(); |
142 try { |
142 try { |
143 final int[] abox = ts.abox; |
143 final int[] abox = ts.abox; |
144 |
144 |
145 final AATileGenerator aatg = |
145 final AATileGenerator aatg = |
146 renderengine.getAATileGenerator(s, sg.transform, sg.getCompClip(), |
146 RDR_ENGINE.getAATileGenerator(s, sg.transform, sg.getCompClip(), |
147 bs, thin, adjust, abox); |
147 bs, thin, adjust, abox); |
148 if (aatg != null) { |
148 if (aatg != null) { |
149 renderTiles(sg, s, aatg, abox, ts); |
149 renderTiles(sg, s, aatg, abox, ts); |
150 } |
150 } |
151 } finally { |
151 } finally { |
152 tileStateProvider.release(ts); |
152 TILE_STATE_PROVIDER.release(ts); |
153 } |
153 } |
154 } |
154 } |
155 |
155 |
156 public void renderTiles(SunGraphics2D sg, Shape s, |
156 public void renderTiles(SunGraphics2D sg, Shape s, |
157 final AATileGenerator aatg, |
157 final AATileGenerator aatg, |