Skip to content

Commit 86743e7

Browse files
committed
image: add RGBA64Image interface
The new RGBA64At method is equivalent to the existing At method (and the new SetRGBA64 method is equivalent to the existing Set method in the image/draw package), but they can avoid allocations from converting concrete color types to the color.Color interface type. Also update api/go1.17.txt and doc/go1.17.html Fixes #44808 Change-Id: I8671f3144512b1200fa373840ed6729a5d61bc35 Reviewed-on: https://go-review.googlesource.com/c/go/+/311129 Trust: Nigel Tao <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Rob Pike <[email protected]>
1 parent 9401172 commit 86743e7

File tree

6 files changed

+338
-1
lines changed

6 files changed

+338
-1
lines changed

api/go1.17.txt

+33-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,38 @@ pkg encoding/csv, method (*Reader) FieldPos(int) (int, int)
2828
pkg go/build, type Context struct, ToolTags []string
2929
pkg go/parser, const SkipObjectResolution = 64
3030
pkg go/parser, const SkipObjectResolution Mode
31+
pkg image, method (*Alpha) RGBA64At(int, int) color.RGBA64
32+
pkg image, method (*Alpha) SetRGBA64(int, int, color.RGBA64)
33+
pkg image, method (*Alpha16) RGBA64At(int, int) color.RGBA64
34+
pkg image, method (*Alpha16) SetRGBA64(int, int, color.RGBA64)
35+
pkg image, method (*CMYK) RGBA64At(int, int) color.RGBA64
36+
pkg image, method (*CMYK) SetRGBA64(int, int, color.RGBA64)
37+
pkg image, method (*Gray) RGBA64At(int, int) color.RGBA64
38+
pkg image, method (*Gray) SetRGBA64(int, int, color.RGBA64)
39+
pkg image, method (*Gray16) RGBA64At(int, int) color.RGBA64
40+
pkg image, method (*Gray16) SetRGBA64(int, int, color.RGBA64)
41+
pkg image, method (*NRGBA) RGBA64At(int, int) color.RGBA64
42+
pkg image, method (*NRGBA) SetRGBA64(int, int, color.RGBA64)
43+
pkg image, method (*NRGBA64) RGBA64At(int, int) color.RGBA64
44+
pkg image, method (*NRGBA64) SetRGBA64(int, int, color.RGBA64)
45+
pkg image, method (*NYCbCrA) RGBA64At(int, int) color.RGBA64
46+
pkg image, method (*Paletted) RGBA64At(int, int) color.RGBA64
47+
pkg image, method (*Paletted) SetRGBA64(int, int, color.RGBA64)
48+
pkg image, method (*RGBA) RGBA64At(int, int) color.RGBA64
49+
pkg image, method (*RGBA) SetRGBA64(int, int, color.RGBA64)
50+
pkg image, method (*YCbCr) RGBA64At(int, int) color.RGBA64
51+
pkg image, type RGBA64Image interface { At, Bounds, ColorModel, RGBA64At }
52+
pkg image, type RGBA64Image interface, At(int, int) color.Color
53+
pkg image, type RGBA64Image interface, Bounds() Rectangle
54+
pkg image, type RGBA64Image interface, ColorModel() color.Model
55+
pkg image, type RGBA64Image interface, RGBA64At(int, int) color.RGBA64
56+
pkg image/draw, type RGBA64Image interface { At, Bounds, ColorModel, RGBA64At, Set, SetRGBA64 }
57+
pkg image/draw, type RGBA64Image interface, At(int, int) color.Color
58+
pkg image/draw, type RGBA64Image interface, Bounds() image.Rectangle
59+
pkg image/draw, type RGBA64Image interface, ColorModel() color.Model
60+
pkg image/draw, type RGBA64Image interface, RGBA64At(int, int) color.RGBA64
61+
pkg image/draw, type RGBA64Image interface, Set(int, int, color.Color)
62+
pkg image/draw, type RGBA64Image interface, SetRGBA64(int, int, color.RGBA64)
3163
pkg io/fs, func FileInfoToDirEntry(FileInfo) DirEntry
3264
pkg math, const MaxFloat64 = 1.79769e+308 // 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368
3365
pkg math, const MaxInt = 9223372036854775807
@@ -153,7 +185,7 @@ pkg time, const Layout = "01/02 03:04:05PM '06 -0700"
153185
pkg time, const Layout ideal-string
154186
pkg time, func UnixMicro(int64) Time
155187
pkg time, func UnixMilli(int64) Time
156-
pkg time, method (Time) IsDST() bool
157188
pkg time, method (Time) GoString() string
189+
pkg time, method (Time) IsDST() bool
158190
pkg time, method (Time) UnixMicro() int64
159191
pkg time, method (Time) UnixMilli() int64

doc/go1.17.html

+13
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,19 @@ <h3 id="minor_library_changes">Minor changes to the library</h3>
693693
</dd>
694694
</dl><!-- go/format -->
695695

696+
<dl id="image"><dt><a href="/pkg/image/">image</a></dt>
697+
<dd>
698+
<p><!-- CL 311129 -->
699+
The concrete image types (<code>RGBA</code>, <code>Gray16</code> and so on)
700+
now implement a new <a href="/pkg/image/#RGBA64Image"><code>RGBA64Image</code></a>
701+
interface. Those concrete types, other than the chroma-subsampling
702+
related <code>YCbCr</code> and <code>NYCbCrA</code>, also now implement
703+
<a href="/pkg/image/draw/#RGBA64Image"><code>draw.RGBA64Image</code></a>, a
704+
new interface in the <code>image/draw</code> package.
705+
</p>
706+
</dd>
707+
</dl><!-- image -->
708+
696709
<dl id="io/fs"><dt><a href="/pkg/io/fs/">io/fs</a></dt>
697710
<dd>
698711
<p><!-- CL 293649 -->

src/image/draw/draw.go

+10
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ type Image interface {
2323
Set(x, y int, c color.Color)
2424
}
2525

26+
// RGBA64Image extends both the Image and image.RGBA64Image interfaces with a
27+
// SetRGBA64 method to change a single pixel. SetRGBA64 is equivalent to
28+
// calling Set, but it can avoid allocations from converting concrete color
29+
// types to the color.Color interface type.
30+
type RGBA64Image interface {
31+
image.RGBA64Image
32+
Set(x, y int, c color.Color)
33+
SetRGBA64(x, y int, c color.RGBA64)
34+
}
35+
2636
// Quantizer produces a palette for an image.
2737
type Quantizer interface {
2838
// Quantize appends up to cap(p) - len(p) colors to p and returns the

0 commit comments

Comments
 (0)