Commit Graph

58 Commits

Author SHA1 Message Date
Nigel Tao
b57ddf1b68 draw: RGBA src fast path for scaling.
benchmark                     old ns/op      new ns/op      delta
BenchmarkScaleSrcRGBA         15124800       2091946        -86.17%

Change-Id: Id8d3088793ebf1d75b929fcf6945987817e87463
Reviewed-on: https://go-review.googlesource.com/6234
Reviewed-by: Rob Pike <r@golang.org>
2015-02-28 01:27:59 +00:00
Nigel Tao
2a40e8dacf draw: RGBA dst fast path for scaling.
benchmark                     old ns/op      new ns/op      delta
BenchmarkScaleLargeDownNN     6124873        3348203        -45.33%
BenchmarkScaleLargeDownAB     15608417       12626534       -19.10%
BenchmarkScaleLargeDownBL     1503354937     1482605150     -1.38%
BenchmarkScaleLargeDownCR     2987623786     2937846270     -1.67%
BenchmarkScaleDownNN          1793478        935896         -47.82%
BenchmarkScaleDownAB          4277596        3405613        -20.38%
BenchmarkScaleDownBL          29932226       29268085       -2.22%
BenchmarkScaleDownCR          57563042       57322266       -0.42%
BenchmarkScaleUpNN            89694138       46216098       -48.47%
BenchmarkScaleUpAB            212318283      169267373      -20.28%
BenchmarkScaleUpBL            120899444      80215032       -33.65%
BenchmarkScaleUpCR            181116518      140140247      -22.62%
BenchmarkScaleSrcNRGBA        13229017       10620746       -19.72%
BenchmarkScaleSrcRGBA         12993292       10155919       -21.84%
BenchmarkScaleSrcUniform      3964808        1146947        -71.07%
BenchmarkScaleSrcYCbCr        15871184       12779895       -19.48%

Change-Id: I7d92bd9f4c20692c5a52ea31019fe3852e657535
Reviewed-on: https://go-review.googlesource.com/6230
Reviewed-by: Rob Pike <r@golang.org>
2015-02-27 06:36:42 +00:00
Nigel Tao
db892dd957 draw: clip scaling to the dst bounds.
This is necessary for the upcoming RGBA dst fast path. The RGBA.Set slow
path will clip automatically. Accessing RGBA.Pix directly will not.

Benchmarks look like noise to me:
benchmark                     old ns/op      new ns/op      delta
BenchmarkScaleLargeDownNN     6212108        6131166        -1.30%
BenchmarkScaleLargeDownAB     15586042       15656681       +0.45%
BenchmarkScaleLargeDownBL     1518783517     1508124217     -0.70%
BenchmarkScaleLargeDownCR     2998969089     2978114154     -0.70%
BenchmarkScaleDownNN          1821187        1809314        -0.65%
BenchmarkScaleDownAB          4286983        4248974        -0.89%
BenchmarkScaleDownBL          29396818       30181926       +2.67%
BenchmarkScaleDownCR          56441945       57952417       +2.68%
BenchmarkScaleUpNN            90325384       89734496       -0.65%
BenchmarkScaleUpAB            211613922      211625435      +0.01%
BenchmarkScaleUpBL            119730880      120817135      +0.91%
BenchmarkScaleUpCR            178592665      182305702      +2.08%
BenchmarkScaleSrcNRGBA        13271034       13210760       -0.45%
BenchmarkScaleSrcRGBA         13082234       12997551       -0.65%
BenchmarkScaleSrcUniform      4003966        3934184        -1.74%
BenchmarkScaleSrcYCbCr        15939182       15900123       -0.25%

Change-Id: Ibf2843bb3c4eb695b58030e7314053c669533016
Reviewed-on: https://go-review.googlesource.com/6073
Reviewed-by: Rob Pike <r@golang.org>
2015-02-26 22:56:31 +00:00
Nigel Tao
284bc4b702 draw: test that the fast path implementations match the generic ones.
Change-Id: I34418bd8e5dec7b03e9c29efdab10f6116b4463f
Reviewed-on: https://go-review.googlesource.com/5730
Reviewed-by: Rob Pike <r@golang.org>
2015-02-26 00:12:42 +00:00
Nigel Tao
748adb17a1 draw: generate impl.go type switches.
This just the type switches to concrete-type-specific methods.
Generating RGBA- or YCbCr-specific code instead of calling the
general-purpose At and Set methods will be follow-up changes.

benchmark                     old ns/op      new ns/op      delta
BenchmarkScaleLargeDownNN     5771212        5766160        -0.09%
BenchmarkScaleLargeDownAB     14057354       14023083       -0.24%
BenchmarkScaleLargeDownBL     1349968635     1347746478     -0.16%
BenchmarkScaleLargeDownCR     2687753329     2678909022     -0.33%
BenchmarkScaleDownNN          1802408        1808723        +0.35%
BenchmarkScaleDownAB          4352978        4284878        -1.56%
BenchmarkScaleDownBL          29760913       29522171       -0.80%
BenchmarkScaleDownCR          57666917       56334005       -2.31%
BenchmarkScaleUpNN            88886450       89235790       +0.39%
BenchmarkScaleUpAB            214687758      213797857      -0.41%
BenchmarkScaleUpBL            119588096      119846371      +0.22%
BenchmarkScaleUpCR            179784111      180662030      +0.49%
BenchmarkScaleSrcUniform      4128528        3855385        -6.62%
BenchmarkScaleSrcNRGBA        13275457       13375039       +0.75%
BenchmarkScaleSrcRGBA         13333672       12812895       -3.91%
BenchmarkScaleSrcYCbCr        14321945       14139071       -1.28%

Change-Id: I28025c3b49186a12d20ee0182a4c8ff9b036d0ae
Reviewed-on: https://go-review.googlesource.com/5712
Reviewed-by: Rob Pike <r@golang.org>
2015-02-24 06:30:29 +00:00
Nigel Tao
999c3975a8 draw: autogenerate impl.go.
Adding fast paths for concrete dst and src image types will be follow-up
changes.

Change-Id: Ib23e3cc46d9c7a52ebd5eddfbad09177b0b421af
Reviewed-on: https://go-review.googlesource.com/5417
Reviewed-by: Rob Pike <r@golang.org>
2015-02-24 00:55:15 +00:00
Nigel Tao
2a1231edb8 draw: factor out the Scale implementations.
This is just a copy/paste/rename in anticipation of automatically
generating fast-path code for specific dst-image types and src-image
types, a la the standard library's image/draw package.

Change-Id: If6385b347cb5e1d134b0ce841ef38ed4450a6fef
Reviewed-on: https://go-review.googlesource.com/5252
Reviewed-by: David Symonds <dsymonds@golang.org>
2015-02-20 07:27:42 +00:00
Nigel Tao
96b77d5c7a draw: new package, a superset of the standard library's image/draw
package, including the ability to scale an image.

Design discussion:
https://groups.google.com/forum/#!topic/golang-dev/B7-OrWdheic

Previous code review (when Go used hg instead of git):
https://codereview.appspot.com/101670045

New benchmarks:
BenchmarkScaleLargeDownNN	     300	   5935174 ns/op
BenchmarkScaleLargeDownAB	     100	  14482372 ns/op
BenchmarkScaleLargeDownBL	       1	1383805986 ns/op
BenchmarkScaleLargeDownCR	       1	2724631789 ns/op
BenchmarkScaleDownNN     	    1000	   1850500 ns/op
BenchmarkScaleDownAB     	     300	   4413499 ns/op
BenchmarkScaleDownBL     	      50	  30498748 ns/op
BenchmarkScaleDownCR     	      20	  58349653 ns/op
BenchmarkScaleUpNN       	      20	  92306475 ns/op
BenchmarkScaleUpAB       	       5	 220103753 ns/op
BenchmarkScaleUpBL       	      10	 122635195 ns/op
BenchmarkScaleUpCR       	      10	 183275927 ns/op

Change-Id: I69d397e68897bae024c7b330a9375fa3e7688591
Reviewed-on: https://go-review.googlesource.com/4210
Reviewed-by: Rob Pike <r@golang.org>
2015-02-17 23:20:02 +00:00