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

Issue 201048: code review 201048: draw.Draw fast paths for a nil mask (and RGBA dst). (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
15 years, 1 month ago by nigeltao
Modified:
15 years, 1 month ago
Reviewers:
CC:
r, rsc, golang-dev
Visibility:
Public.

Description

draw.Draw fast paths for a nil mask (and RGBA dst). 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.

Patch Set 1 #

Patch Set 2 : code review 201048: draw.Draw fast paths for a nil mask (and RGBA dst). #

Patch Set 3 : code review 201048: draw.Draw fast paths for a nil mask (and RGBA dst). #

Patch Set 4 : code review 201048: draw.Draw fast paths for a nil mask (and RGBA dst). #

Patch Set 5 : code review 201048: draw.Draw fast paths for a nil mask (and RGBA dst). #

Patch Set 6 : code review 201048: draw.Draw fast paths for a nil mask (and RGBA dst). #

Unified diffs Side-by-side diffs Delta from patch set Stats (+50 lines, -0 lines) Patch
M src/pkg/exp/draw/draw.go View 1 2 3 2 chunks +50 lines, -0 lines 0 comments Download

Messages

Total messages: 6
nigeltao
Hello r, rsc (cc: golang-dev@googlegroups.com), I'd like you to review this change.
15 years, 1 month ago (2010-02-04 13:38:22 UTC) #1
rsc
i like it. a few small generalizations. if mask == nil can be if mask ...
15 years, 1 month ago (2010-02-04 19:19:14 UTC) #2
nigeltao_gnome
On 5 February 2010 06:19, Russ Cox <rsc@golang.org> wrote: > if mask == nil can ...
15 years, 1 month ago (2010-02-04 22:26:00 UTC) #3
rsc
Oh, right. No repl here. LGTM
15 years, 1 month ago (2010-02-05 00:17:58 UTC) #4
r
LGTM
15 years, 1 month ago (2010-02-05 00:21:29 UTC) #5
nigeltao
15 years, 1 month ago (2010-02-06 04:57:25 UTC) #6
*** Submitted as http://code.google.com/p/go/source/detail?r=dbfbd65d6549 ***

draw.Draw fast paths for a nil mask (and RGBA dst).

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
http://codereview.appspot.com/201048
Sign in to reply to this message.

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