• Nigel Tao's avatar
    draw.Draw fast paths for a nil mask (and RGBA dst). · 48cdb63b
    Nigel Tao authored
    Averaged times (in microseconds) for drawing an 800x600 rectangle
    are listed below. The summary is: around a 100x improvement.
    
    draw.Draw call times were typically linear in the number of pixels
    touched (i.e. drawing an 800x600 rectangle took 100x as much time as
    drawing an 80x60 rectangle).
    
    Before this change, there was only the general-but-slow code path.
    When drawing any src with a 50%-opaque mask: 237300 us
    When drawing any src with a nil mask: 50100 us
    
    After this change, the 50%-opaque mask case is unchanged.
    For an *image.RGBA dst and nil mask and...
    ...a uniform color (i.e. an image.ColorImage) src: 282 us
    ...another *image.RGBA src: 615 us.
    
    For the curious, an intermediate implementation detected the special
    cases but used simple nested for loops instead of the built-in copy
    function. The respective times (compared to 282 and 615 for the
    final implementation, or 50100 for the original) were 3110 and 3573.
    
    Times were measured with 8g/8l on my laptop. I haven't tried gccgo
    or other architectures.
    
    R=r, rsc
    CC=golang-dev
    https://golang.org/cl/201048
    48cdb63b
Name
Last commit
Last update
..
archive/tar Loading commit data...
asn1 Loading commit data...
big Loading commit data...
bignum Loading commit data...
bufio Loading commit data...
bytes Loading commit data...
compress Loading commit data...
container Loading commit data...
crypto Loading commit data...
debug Loading commit data...
ebnf Loading commit data...
encoding Loading commit data...
exec Loading commit data...
exp Loading commit data...
expvar Loading commit data...
flag Loading commit data...
fmt Loading commit data...
go Loading commit data...
gob Loading commit data...
hash Loading commit data...
http Loading commit data...
image Loading commit data...
io Loading commit data...
json Loading commit data...
log Loading commit data...
math Loading commit data...
net Loading commit data...
netchan Loading commit data...
once Loading commit data...
os Loading commit data...
patch Loading commit data...
path Loading commit data...
rand Loading commit data...
reflect Loading commit data...
regexp Loading commit data...
rpc Loading commit data...
runtime Loading commit data...
scanner Loading commit data...
sort Loading commit data...
strconv Loading commit data...
strings Loading commit data...
sync Loading commit data...
syscall Loading commit data...
syslog Loading commit data...
tabwriter Loading commit data...
template Loading commit data...
testing Loading commit data...
time Loading commit data...
unicode Loading commit data...
unsafe Loading commit data...
utf8 Loading commit data...
websocket Loading commit data...
xgb Loading commit data...
xml Loading commit data...
Makefile Loading commit data...
deps.bash Loading commit data...