Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(343)

Side by Side Diff: src/pkg/image/draw/draw_test.go

Issue 5619052: code review 5619052: std: add struct field tags to untagged literals. (Closed)
Patch Set: diff -r 957880bae91d https://go.googlecode.com/hg/ Created 13 years, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pkg/image/draw/bench_test.go ('k') | src/pkg/image/gif/reader.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 The Go Authors. All rights reserved. 1 // Copyright 2010 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package draw 5 package draw
6 6
7 import ( 7 import (
8 "image" 8 "image"
9 "image/color" 9 "image/color"
10 "testing" 10 "testing"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 sb := src.Bounds() 161 sb := src.Bounds()
162 mb := image.Rect(-1e9, -1e9, 1e9, 1e9) 162 mb := image.Rect(-1e9, -1e9, 1e9, 1e9)
163 if mask != nil { 163 if mask != nil {
164 mb = mask.Bounds() 164 mb = mask.Bounds()
165 } 165 }
166 golden := image.NewRGBA(image.Rect(0, 0, b.Max.X, b.Max.Y)) 166 golden := image.NewRGBA(image.Rect(0, 0, b.Max.X, b.Max.Y))
167 for y := r.Min.Y; y < r.Max.Y; y++ { 167 for y := r.Min.Y; y < r.Max.Y; y++ {
168 sy := y + sp.Y - r.Min.Y 168 sy := y + sp.Y - r.Min.Y
169 my := y + mp.Y - r.Min.Y 169 my := y + mp.Y - r.Min.Y
170 for x := r.Min.X; x < r.Max.X; x++ { 170 for x := r.Min.X; x < r.Max.X; x++ {
171 » » » if !(image.Point{x, y}.In(b)) { 171 » » » if !(image.Pt(x, y).In(b)) {
172 continue 172 continue
173 } 173 }
174 sx := x + sp.X - r.Min.X 174 sx := x + sp.X - r.Min.X
175 » » » if !(image.Point{sx, sy}.In(sb)) { 175 » » » if !(image.Pt(sx, sy).In(sb)) {
176 continue 176 continue
177 } 177 }
178 mx := x + mp.X - r.Min.X 178 mx := x + mp.X - r.Min.X
179 » » » if !(image.Point{mx, my}.In(mb)) { 179 » » » if !(image.Pt(mx, my).In(mb)) {
180 continue 180 continue
181 } 181 }
182 182
183 const M = 1<<16 - 1 183 const M = 1<<16 - 1
184 var dr, dg, db, da uint32 184 var dr, dg, db, da uint32
185 if op == Over { 185 if op == Over {
186 dr, dg, db, da = dst.At(x, y).RGBA() 186 dr, dg, db, da = dst.At(x, y).RGBA()
187 } 187 }
188 sr, sg, sb, sa := src.At(sx, sy).RGBA() 188 sr, sg, sb, sa := src.At(sx, sy).RGBA()
189 ma := uint32(M) 189 ma := uint32(M)
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 image.Rect(0, 15, 40, 16), 305 image.Rect(0, 15, 40, 16),
306 image.Rect(24, 24, 25, 25), 306 image.Rect(24, 24, 25, 25),
307 image.Rect(23, 23, 26, 26), 307 image.Rect(23, 23, 26, 26),
308 image.Rect(22, 22, 27, 27), 308 image.Rect(22, 22, 27, 27),
309 image.Rect(21, 21, 28, 28), 309 image.Rect(21, 21, 28, 28),
310 image.Rect(20, 20, 29, 29), 310 image.Rect(20, 20, 29, 29),
311 } 311 }
312 for _, r := range rr { 312 for _, r := range rr {
313 m := image.NewRGBA(image.Rect(0, 0, 40, 30)).SubImage(r).(*image .RGBA) 313 m := image.NewRGBA(image.Rect(0, 0, 40, 30)).SubImage(r).(*image .RGBA)
314 b := m.Bounds() 314 b := m.Bounds()
315 » » c := color.RGBA{11, 0, 0, 255} 315 » » c := color.RGBA{R: 11, G: 0, B: 0, A: 255}
dsymonds 2012/02/02 07:00:33 color.RGBA is frozen; you don't need to change thi
nigeltao 2012/02/02 07:05:49 True, but it looked weird to use an untagged struc
nigeltao 2012/02/02 22:57:48 The color.RGBA changes have been reverted.
316 » » src := &image.Uniform{c} 316 » » src := &image.Uniform{C: c}
317 check := func(desc string) { 317 check := func(desc string) {
318 for y := b.Min.Y; y < b.Max.Y; y++ { 318 for y := b.Min.Y; y < b.Max.Y; y++ {
319 for x := b.Min.X; x < b.Max.X; x++ { 319 for x := b.Min.X; x < b.Max.X; x++ {
320 if !eq(c, m.At(x, y)) { 320 if !eq(c, m.At(x, y)) {
321 t.Errorf("%s fill: at (%d, %d), sub-image bounds=%v: want %v got %v", desc, x, y, r, c, m.At(x, y)) 321 t.Errorf("%s fill: at (%d, %d), sub-image bounds=%v: want %v got %v", desc, x, y, r, c, m.At(x, y))
322 return 322 return
323 } 323 }
324 } 324 }
325 } 325 }
326 } 326 }
327 // Draw 1 pixel at a time. 327 // Draw 1 pixel at a time.
328 for y := b.Min.Y; y < b.Max.Y; y++ { 328 for y := b.Min.Y; y < b.Max.Y; y++ {
329 for x := b.Min.X; x < b.Max.X; x++ { 329 for x := b.Min.X; x < b.Max.X; x++ {
330 DrawMask(m, image.Rect(x, y, x+1, y+1), src, ima ge.ZP, nil, image.ZP, Src) 330 DrawMask(m, image.Rect(x, y, x+1, y+1), src, ima ge.ZP, nil, image.ZP, Src)
331 } 331 }
332 } 332 }
333 check("pixel") 333 check("pixel")
334 // Draw 1 row at a time. 334 // Draw 1 row at a time.
335 » » c = color.RGBA{0, 22, 0, 255} 335 » » c = color.RGBA{R: 0, G: 22, B: 0, A: 255}
dsymonds 2012/02/02 07:00:33 ditto
336 » » src = &image.Uniform{c} 336 » » src = &image.Uniform{C: c}
337 for y := b.Min.Y; y < b.Max.Y; y++ { 337 for y := b.Min.Y; y < b.Max.Y; y++ {
338 DrawMask(m, image.Rect(b.Min.X, y, b.Max.X, y+1), src, i mage.ZP, nil, image.ZP, Src) 338 DrawMask(m, image.Rect(b.Min.X, y, b.Max.X, y+1), src, i mage.ZP, nil, image.ZP, Src)
339 } 339 }
340 check("row") 340 check("row")
341 // Draw 1 column at a time. 341 // Draw 1 column at a time.
342 » » c = color.RGBA{0, 0, 33, 255} 342 » » c = color.RGBA{R: 0, G: 0, B: 33, A: 255}
dsymonds 2012/02/02 07:00:33 ditto
343 » » src = &image.Uniform{c} 343 » » src = &image.Uniform{C: c}
344 for x := b.Min.X; x < b.Max.X; x++ { 344 for x := b.Min.X; x < b.Max.X; x++ {
345 DrawMask(m, image.Rect(x, b.Min.Y, x+1, b.Max.Y), src, i mage.ZP, nil, image.ZP, Src) 345 DrawMask(m, image.Rect(x, b.Min.Y, x+1, b.Max.Y), src, i mage.ZP, nil, image.ZP, Src)
346 } 346 }
347 check("column") 347 check("column")
348 // Draw the whole image at once. 348 // Draw the whole image at once.
349 » » c = color.RGBA{44, 55, 66, 77} 349 » » c = color.RGBA{R: 44, G: 55, B: 66, A: 77}
dsymonds 2012/02/02 07:00:33 ditto
350 » » src = &image.Uniform{c} 350 » » src = &image.Uniform{C: c}
351 DrawMask(m, b, src, image.ZP, nil, image.ZP, Src) 351 DrawMask(m, b, src, image.ZP, nil, image.ZP, Src)
352 check("whole") 352 check("whole")
353 } 353 }
354 } 354 }
OLDNEW
« no previous file with comments | « src/pkg/image/draw/bench_test.go ('k') | src/pkg/image/gif/reader.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b