@@ -99,15 +99,17 @@ var FlatTintPipeline = new Class({
9999 return this ;
100100 } ,
101101
102- batchFillRect : function ( srcX , srcY , srcScaleX , srcScaleY , srcRotation , x , y , width , height , fillColor , fillAlpha , a1 , b1 , c1 , d1 , e1 , f1 , currentMatrix )
102+ batchFillRect : function ( srcX , srcY , srcScaleX , srcScaleY , srcRotation , x , y , width , height , fillColor , fillAlpha , a1 , b1 , c1 , d1 , e1 , f1 , currentMatrix , roundPixels )
103103 {
104104 this . renderer . setPipeline ( this ) ;
105105
106106 if ( this . vertexCount + 6 > this . vertexCapacity )
107107 {
108108 this . flush ( ) ;
109109 }
110-
110+
111+ var renderer = this . renderer ;
112+ var resolution = renderer . gameConfig . resolution ;
111113 var vertexViewF32 = this . vertexViewF32 ;
112114 var vertexViewU32 = this . vertexViewU32 ;
113115 var vertexOffset = this . vertexCount * this . vertexComponentCount ;
@@ -135,6 +137,18 @@ var FlatTintPipeline = new Class({
135137 var ty3 = xw * b + y * d + f ;
136138 var tint = Utils . getTintAppendFloatAlphaAndSwap ( fillColor , fillAlpha ) ;
137139
140+ if ( roundPixels )
141+ {
142+ tx0 = ( ( tx0 * resolution ) | 0 ) / resolution ;
143+ ty0 = ( ( ty0 * resolution ) | 0 ) / resolution ;
144+ tx1 = ( ( tx1 * resolution ) | 0 ) / resolution ;
145+ ty1 = ( ( ty1 * resolution ) | 0 ) / resolution ;
146+ tx2 = ( ( tx2 * resolution ) | 0 ) / resolution ;
147+ ty2 = ( ( ty2 * resolution ) | 0 ) / resolution ;
148+ tx3 = ( ( tx3 * resolution ) | 0 ) / resolution ;
149+ ty3 = ( ( ty3 * resolution ) | 0 ) / resolution ;
150+ }
151+
138152 vertexViewF32 [ vertexOffset + 0 ] = tx0 ;
139153 vertexViewF32 [ vertexOffset + 1 ] = ty0 ;
140154 vertexViewU32 [ vertexOffset + 2 ] = tint ;
@@ -157,7 +171,7 @@ var FlatTintPipeline = new Class({
157171 this . vertexCount += 6 ;
158172 } ,
159173
160- batchFillTriangle : function ( srcX , srcY , srcScaleX , srcScaleY , srcRotation , x0 , y0 , x1 , y1 , x2 , y2 , fillColor , fillAlpha , a1 , b1 , c1 , d1 , e1 , f1 , currentMatrix )
174+ batchFillTriangle : function ( srcX , srcY , srcScaleX , srcScaleY , srcRotation , x0 , y0 , x1 , y1 , x2 , y2 , fillColor , fillAlpha , a1 , b1 , c1 , d1 , e1 , f1 , currentMatrix , roundPixels )
161175 {
162176 this . renderer . setPipeline ( this ) ;
163177
@@ -166,6 +180,8 @@ var FlatTintPipeline = new Class({
166180 this . flush ( ) ;
167181 }
168182
183+ var renderer = this . renderer ;
184+ var resolution = renderer . gameConfig . resolution ;
169185 var vertexViewF32 = this . vertexViewF32 ;
170186 var vertexViewU32 = this . vertexViewU32 ;
171187 var vertexOffset = this . vertexCount * this . vertexComponentCount ;
@@ -189,6 +205,16 @@ var FlatTintPipeline = new Class({
189205 var ty2 = x2 * b + y2 * d + f ;
190206 var tint = Utils . getTintAppendFloatAlphaAndSwap ( fillColor , fillAlpha ) ;
191207
208+ if ( roundPixels )
209+ {
210+ tx0 = ( ( tx0 * resolution ) | 0 ) / resolution ;
211+ ty0 = ( ( ty0 * resolution ) | 0 ) / resolution ;
212+ tx1 = ( ( tx1 * resolution ) | 0 ) / resolution ;
213+ ty1 = ( ( ty1 * resolution ) | 0 ) / resolution ;
214+ tx2 = ( ( tx2 * resolution ) | 0 ) / resolution ;
215+ ty2 = ( ( ty2 * resolution ) | 0 ) / resolution ;
216+ }
217+
192218 vertexViewF32 [ vertexOffset + 0 ] = tx0 ;
193219 vertexViewF32 [ vertexOffset + 1 ] = ty0 ;
194220 vertexViewU32 [ vertexOffset + 2 ] = tint ;
@@ -202,7 +228,7 @@ var FlatTintPipeline = new Class({
202228 this . vertexCount += 3 ;
203229 } ,
204230
205- batchStrokeTriangle : function ( srcX , srcY , srcScaleX , srcScaleY , srcRotation , x0 , y0 , x1 , y1 , x2 , y2 , lineWidth , lineColor , lineAlpha , a , b , c , d , e , f , currentMatrix )
231+ batchStrokeTriangle : function ( srcX , srcY , srcScaleX , srcScaleY , srcRotation , x0 , y0 , x1 , y1 , x2 , y2 , lineWidth , lineColor , lineAlpha , a , b , c , d , e , f , currentMatrix , roundPixels )
206232 {
207233
208234 var tempTriangle = this . tempTriangle ;
@@ -233,14 +259,17 @@ var FlatTintPipeline = new Class({
233259 tempTriangle , lineWidth , lineColor , lineAlpha ,
234260 a , b , c , d , e , f ,
235261 false ,
236- currentMatrix
262+ currentMatrix ,
263+ roundPixels
237264 ) ;
238265 } ,
239266
240- batchFillPath : function ( srcX , srcY , srcScaleX , srcScaleY , srcRotation , path , fillColor , fillAlpha , a1 , b1 , c1 , d1 , e1 , f1 , currentMatrix )
267+ batchFillPath : function ( srcX , srcY , srcScaleX , srcScaleY , srcRotation , path , fillColor , fillAlpha , a1 , b1 , c1 , d1 , e1 , f1 , currentMatrix , roundPixels )
241268 {
242269 this . renderer . setPipeline ( this ) ;
243270
271+ var renderer = this . renderer ;
272+ var resolution = renderer . gameConfig . resolution ;
244273 var length = path . length ;
245274 var polygonCache = this . polygonCache ;
246275 var polygonIndexArray ;
@@ -301,6 +330,16 @@ var FlatTintPipeline = new Class({
301330 tx2 = x2 * a + y2 * c + e ;
302331 ty2 = x2 * b + y2 * d + f ;
303332
333+ if ( roundPixels )
334+ {
335+ tx0 = ( ( tx0 * resolution ) | 0 ) / resolution ;
336+ ty0 = ( ( ty0 * resolution ) | 0 ) / resolution ;
337+ tx1 = ( ( tx1 * resolution ) | 0 ) / resolution ;
338+ ty1 = ( ( ty1 * resolution ) | 0 ) / resolution ;
339+ tx2 = ( ( tx2 * resolution ) | 0 ) / resolution ;
340+ ty2 = ( ( ty2 * resolution ) | 0 ) / resolution ;
341+ }
342+
304343 vertexViewF32 [ vertexOffset + 0 ] = tx0 ;
305344 vertexViewF32 [ vertexOffset + 1 ] = ty0 ;
306345 vertexViewU32 [ vertexOffset + 2 ] = tint ;
@@ -317,7 +356,7 @@ var FlatTintPipeline = new Class({
317356 polygonCache . length = 0 ;
318357 } ,
319358
320- batchStrokePath : function ( srcX , srcY , srcScaleX , srcScaleY , srcRotation , path , lineWidth , lineColor , lineAlpha , a , b , c , d , e , f , isLastPath , currentMatrix )
359+ batchStrokePath : function ( srcX , srcY , srcScaleX , srcScaleY , srcRotation , path , lineWidth , lineColor , lineAlpha , a , b , c , d , e , f , isLastPath , currentMatrix , roundPixels )
321360 {
322361 this . renderer . setPipeline ( this ) ;
323362
@@ -343,7 +382,8 @@ var FlatTintPipeline = new Class({
343382 point0 . width / 2 , point1 . width / 2 ,
344383 point0 . rgb , point1 . rgb , lineAlpha ,
345384 a , b , c , d , e , f ,
346- currentMatrix
385+ currentMatrix ,
386+ roundPixels
347387 ) ;
348388
349389 polylines . push ( line ) ;
@@ -387,15 +427,17 @@ var FlatTintPipeline = new Class({
387427
388428 } ,
389429
390- batchLine : function ( srcX , srcY , srcScaleX , srcScaleY , srcRotation , ax , ay , bx , by , aLineWidth , bLineWidth , aLineColor , bLineColor , lineAlpha , a1 , b1 , c1 , d1 , e1 , f1 , currentMatrix )
430+ batchLine : function ( srcX , srcY , srcScaleX , srcScaleY , srcRotation , ax , ay , bx , by , aLineWidth , bLineWidth , aLineColor , bLineColor , lineAlpha , a1 , b1 , c1 , d1 , e1 , f1 , currentMatrix , roundPixels )
391431 {
392432 this . renderer . setPipeline ( this ) ;
393433
394434 if ( this . vertexCount + 6 > this . vertexCapacity )
395435 {
396436 this . flush ( ) ;
397437 }
398-
438+
439+ var renderer = this . renderer ;
440+ var resolution = renderer . gameConfig . resolution ;
399441 var a0 = currentMatrix [ 0 ] ;
400442 var b0 = currentMatrix [ 1 ] ;
401443 var c0 = currentMatrix [ 2 ] ;
@@ -438,6 +480,18 @@ var FlatTintPipeline = new Class({
438480 var bTint = getTint ( bLineColor , lineAlpha ) ;
439481 var vertexOffset = this . vertexCount * this . vertexComponentCount ;
440482
483+ if ( roundPixels )
484+ {
485+ x0 = ( ( x0 * resolution ) | 0 ) / resolution ;
486+ y0 = ( ( y0 * resolution ) | 0 ) / resolution ;
487+ x1 = ( ( x1 * resolution ) | 0 ) / resolution ;
488+ y1 = ( ( y1 * resolution ) | 0 ) / resolution ;
489+ x2 = ( ( x2 * resolution ) | 0 ) / resolution ;
490+ y2 = ( ( y2 * resolution ) | 0 ) / resolution ;
491+ x3 = ( ( x3 * resolution ) | 0 ) / resolution ;
492+ y3 = ( ( y3 * resolution ) | 0 ) / resolution ;
493+ }
494+
441495 vertexViewF32 [ vertexOffset + 0 ] = x0 ;
442496 vertexViewF32 [ vertexOffset + 1 ] = y0 ;
443497 vertexViewU32 [ vertexOffset + 2 ] = bTint ;
@@ -522,6 +576,7 @@ var FlatTintPipeline = new Class({
522576 var mvd = src * cmb + srd * cmd ;
523577 var mve = sre * cma + srf * cmc + cme ;
524578 var mvf = sre * cmb + srf * cmd + cmf ;
579+ var roundPixels = camera . roundPixels ;
525580
526581 pathArray . length = 0 ;
527582
@@ -610,7 +665,8 @@ var FlatTintPipeline = new Class({
610665 fillAlpha ,
611666 /* Transform */
612667 mva , mvb , mvc , mvd , mve , mvf ,
613- currentMatrix
668+ currentMatrix ,
669+ roundPixels
614670 ) ;
615671 }
616672 break ;
@@ -632,7 +688,8 @@ var FlatTintPipeline = new Class({
632688 /* Transform */
633689 mva , mvb , mvc , mvd , mve , mvf ,
634690 path === this . _lastPath ,
635- currentMatrix
691+ currentMatrix ,
692+ roundPixels
636693 ) ;
637694 }
638695 break ;
@@ -650,7 +707,8 @@ var FlatTintPipeline = new Class({
650707 fillAlpha ,
651708 /* Transform */
652709 mva , mvb , mvc , mvd , mve , mvf ,
653- currentMatrix
710+ currentMatrix ,
711+ roundPixels
654712 ) ;
655713
656714 cmdIndex += 4 ;
@@ -671,7 +729,8 @@ var FlatTintPipeline = new Class({
671729 fillAlpha ,
672730 /* Transform */
673731 mva , mvb , mvc , mvd , mve , mvf ,
674- currentMatrix
732+ currentMatrix ,
733+ roundPixels
675734 ) ;
676735
677736 cmdIndex += 6 ;
@@ -693,7 +752,8 @@ var FlatTintPipeline = new Class({
693752 lineAlpha ,
694753 /* Transform */
695754 mva , mvb , mvc , mvd , mve , mvf ,
696- currentMatrix
755+ currentMatrix ,
756+ roundPixels
697757 ) ;
698758
699759 cmdIndex += 6 ;
0 commit comments