Commit Graph

271 Commits

Author SHA1 Message Date
Nigel Tao
7ea36498ac vector: allow dst and mask to have different strides.
Change-Id: If244dba2c681b11122a7a26b352f9411135f123f
Reviewed-on: https://go-review.googlesource.com/29696
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-25 02:48:45 +00:00
Nigel Tao
b077ed42b3 vector: implement arbitrary dst and src image types.
Change-Id: Ib0d0961c69cabc3bb01d7b1d244796f0f713b819
Reviewed-on: https://go-review.googlesource.com/29691
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-24 05:40:50 +00:00
Nigel Tao
50ce1ebf58 vector: add benchmarks.
Change-Id: I4946ccc3a915c7e9365cd5fe860da673a2270fbb
Reviewed-on: https://go-review.googlesource.com/29631
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-23 02:06:24 +00:00
Nigel Tao
cd8486aac9 vector: implement DrawOp == draw.Over.
Some "TODO: the general case" lines remain.

Change-Id: If66e484a00d5ea3fce9db37d4ee493739648daa3
Reviewed-on: https://go-review.googlesource.com/29495
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-23 01:58:13 +00:00
Nigel Tao
bb355ba442 vector: add CubeTo.
Change-Id: Ia64b5b077172303981538de99cc14c5bcc99a3e4
Reviewed-on: https://go-review.googlesource.com/28489
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-08 11:11:11 +00:00
Nigel Tao
714f2e47f7 vector: new package for rasterizing 2-D graphics.
Updates golang/go#16904

Change-Id: I4e11e4e859c007c3444655a227ac935c27f3f784
Reviewed-on: https://go-review.googlesource.com/28347
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-09-04 08:48:55 +00:00
Nigel Tao
112f996332 math/fixed: add Mul methods.
Change-Id: Id6f9f5825527b311b5b1aa4ae0923c9551fa076b
Reviewed-on: https://go-review.googlesource.com/27413
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-08-25 00:04:48 +00:00
Nigel Tao
9f8d0d4587 font/plan9font: look for subfont ".0" suffixes.
Change-Id: Id8aadd846311fd621b47912d7b426d6a2d17a594
Reviewed-on: https://go-review.googlesource.com/25560
Reviewed-by: Rob Pike <r@golang.org>
2016-08-07 01:57:26 +00:00
Nigel Tao
c348254d65 webp: make a placeholder package for Go 1.5 and earlier.
This lets programs that underscore import this package build on Go 1.5.

Change-Id: Icd977b16eb44389f8ee4640c2ab57e4b6791b1f4
Reviewed-on: https://go-review.googlesource.com/24954
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-07-16 05:04:44 +00:00
Brad Fitzpatrick
81315f0c68 webp: mark package as requiring Go 1.6 for NYCbCrA
See https://build.golang.org/log/1e0572f27630c3a896f17722d89b6cc35d9f52d8

Updates golang/go#11811

Change-Id: I0db67f2c8586b1c36608c6131c803eb26fb87751
Reviewed-on: https://go-review.googlesource.com/24945
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-07-15 18:42:21 +00:00
Nigel Tao
a21e5be7b4 riff: fix some short chunk data bugs.
Fixes golang/go#16236

Change-Id: I0e524054d0702a6487ff47d86aed6bf58f4ba3f2
Reviewed-on: https://go-review.googlesource.com/24638
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-07-07 05:37:58 +00:00
Nigel Tao
8550bb5380 font/inconsolata: new package.
Fixes golang/go#16185

Change-Id: Ic7d64428b39be6b39a965fddf8753a2ce36d262c
Reviewed-on: https://go-review.googlesource.com/24482
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-06-30 01:20:08 +00:00
Nigel Tao
c4226c0d9c font/basicfont: add Descent and Left fields.
A face's glyph height (the height of the glyph image) isn't necessarily
the inter-line spacing: f.Ascent + f.Descent isn't always f.Height.

Similarly, a face's glyph image's left side isn't always dot.X.

Change-Id: I86594c52b8d31bf652ac34a695e9270ac635a5bc
Reviewed-on: https://go-review.googlesource.com/24481
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-06-30 00:32:31 +00:00
Nigel Tao
97680175a5 font: add a []byte flavor of string methods.
Change-Id: I2506067ba6ac12c275b65c3a52cb38579d4b9dca
Reviewed-on: https://go-review.googlesource.com/23464
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-05-27 00:37:06 +00:00
Nigel Tao
51ddfee6f3 colornames: export variables such as Darkred.
Change-Id: I1507d510ffa0ee3c899af652e0d1ab9d42a650d3
Reviewed-on: https://go-review.googlesource.com/23463
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-05-27 00:36:51 +00:00
Nigel Tao
f551d3a6b7 font/plan9font: derive the example's ascent from the metrics.
The Face.Metrics method is relatively new.

Also pick up the unicode.7x13.font fix from the upstream plan9port:
https://plan9port-review.googlesource.com/#/c/1490/

Change-Id: Ia6e0feec4ea3c9a35e19d38aa634ca9eb6b2ffa0
Reviewed-on: https://go-review.googlesource.com/21699
Reviewed-by: Rob Pike <r@golang.org>
2016-04-23 08:08:30 +00:00
Nigel Tao
14f8673644 font: add a MeasureString function, not just a method.
It can be useful to measure some text without having to set up a Drawer.

Change-Id: I18b7b1fecc32ca69b7644d598ed21462e7c41edd
Reviewed-on: https://go-review.googlesource.com/21785
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-04-12 11:16:26 +00:00
Nigel Tao
4cff43048f example/font: use an "example" build tag instead of "ignore".
The golang-dev discussion is at
https://groups.google.com/d/topic/golang-dev/qKpxZiNABcY/discussion

Change-Id: I55d626fd9b4c5585d11c585a8553fb5184d0ace7
Reviewed-on: https://go-review.googlesource.com/21788
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-04-12 11:14:18 +00:00
Nigel Tao
c4e9f1b429 math/fixed: have Floor, Round and Ceil return int, not Int26_6.
Change-Id: I1714bfbaf355771fb5d01508ac1dfe11c3db927a
Reviewed-on: https://go-review.googlesource.com/21787
Reviewed-by: Rob Pike <r@golang.org>
2016-04-10 05:23:37 +00:00
Nigel Tao
0991244d9d math/fixed: add Floor, Round and Ceil methods.
Change-Id: I7ed8c79a9098f45b38db947b5d99d021358e4e96
Reviewed-on: https://go-review.googlesource.com/21700
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-04-10 01:36:18 +00:00
Nigel Tao
22f1b5f81b font/plan9font: optimize the conversion to image.Alpha.
Also remove the dependency on the image/draw package. That package will
give the right answer for arbitrary source images, including those of
type plan9Image, but doing the conversion directly avoids bouncing uint8
or color.Alpha values through the general-purpose draw.Image,
image.Image and color.Color interfaces.

It is possible to optimize this even further, but this will do for now.

benchmark                   old ns/op     new ns/op     delta
BenchmarkParseSubfont-8     2298492       492443        -78.58%

Change-Id: Iea9436bffa097a1ba0052dbabf21516bce8b61e0
Reviewed-on: https://go-review.googlesource.com/21693
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-04-10 01:11:56 +00:00
Ethan Burns
7a320489ae plan9font: use image.Alpha for subface images.
image.Alpha is fast-pathed in draw.Draw, plan9Image is not.

Change-Id: I5ed8fc4d310bb5c6ec2cffdd0ba4295dae2274cf
Reviewed-on: https://go-review.googlesource.com/21453
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-04-07 03:46:29 +00:00
Nigel Tao
8b5ac8f8e5 image/font: make a zero Weight mean a normal weight.
Change-Id: I2000bdf1c49174b9eaefe1c680138392e3434ace
Reviewed-on: https://go-review.googlesource.com/21440
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-04-02 04:27:04 +00:00
Nigel Tao
0ebebfd658 webp: fix tests for webp/nycbcra deprecation.
The previous commit (00fe24ef "webp/nycbcra: deprecate package") was
incomplete.

Change-Id: I6af5e1633b9c291e72b02877b308eae6e5624ef5
Reviewed-on: https://go-review.googlesource.com/21441
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-04-02 01:02:22 +00:00
Nigel Tao
00fe24ef7b webp/nycbcra: deprecate package.
The standard image and image/color packages have NYCbCrA support, as of Go 1.6.

Change-Id: I3ed2a502b3b9fe720968ac21901115e20a11456a
Reviewed-on: https://go-review.googlesource.com/21066
Reviewed-by: Rob Pike <r@golang.org>
2016-03-27 23:18:01 +00:00
Nigel Tao
f1e9747265 font: add Metrics.Descent.
Change-Id: Id38e7e54264e0e77a28afd8e10cf574610b47336
Reviewed-on: https://go-review.googlesource.com/21019
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-23 23:23:04 +00:00
Ethan Burns
7b1c29e1d6 font: add Face.Metrics.
Fixes golang/go#14885

Change-Id: I3aa2d323c97c76cc78d981d4bf6ea9e95c9bf9d2
Reviewed-on: https://go-review.googlesource.com/21035
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2016-03-23 23:05:57 +00:00
Nigel Tao
7c492694a6 cmd/webp-manual-test: blacklist some versions of the dwebp binary.
In particular, the 0.4.0 version of /usr/bin/dwebp that comes with
Ubuntu 14.04 LTS "Trusty", is known to be bad.

As per https://chromium.googlesource.com/webm/libwebp/+/master/NEWS
(grep for 239), versions 0.4.1 and 0.4.2 are also bad.

The alpha_color_cache.webp test file that triggers the discrepancy
between the (correct) Go implementation and the (buggy) libwebp C
implementation was added on 2015-01-23 in
f64fb2da01
in response to https://bugs.chromium.org/p/webp/issues/detail?id=239

Change-Id: Ifee19be0af634b9bf36ff0e16957648e05be840a
Reviewed-on: https://go-review.googlesource.com/18186
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-01-07 22:46:02 +00:00
Nigel Tao
baddd3465a font/basicfont: new package for a basic font face.
The key feature is that its data is entirely self-contained and does not
require loading from separate files.

Change-Id: I4ef72b52cde93597be89dcfd55659f418c6cab23
Reviewed-on: https://go-review.googlesource.com/14486
Reviewed-by: Rob Pike <r@golang.org>
2015-09-16 11:25:57 +00:00
Nigel Tao
2dc9880a10 colornames: fix copyright year.
These files were added in 2015:
https://go-review.googlesource.com/#/c/13181/

Presumably they were copy/pasted from something written in 2011.

Change-Id: I3defb4e02d03beb835e8a16c89bcae44c292e914
Reviewed-on: https://go-review.googlesource.com/14487
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-11 03:52:25 +00:00
Nigel Tao
b3d8467d91 font: fix up some old x/exp/shiny references.
Also add canonical import paths for the newly merged packages.

Change-Id: I96fe3a964ba08e718fc9163c980ef7ea9da551fe
Reviewed-on: https://go-review.googlesource.com/14148
Reviewed-by: David Symonds <dsymonds@golang.org>
2015-09-01 05:21:00 +00:00
Nigel Tao
00f88f596f Merge x/exp/shiny/font to x/image/font. 2015-09-01 14:51:18 +10:00
Nigel Tao
b53870fbcf shiny/font/plan9font: add an example test.
The testdata/fixed font files come from the Plan 9 Port, and were all
marked as public domain. The total size of the new testdata is 112K.

Change-Id: I8cf5de4e5abd1aec7e6550d330271f2acdc12402
Reviewed-on: https://go-review.googlesource.com/13888
Reviewed-by: Rob Pike <r@golang.org>
2015-09-01 04:36:16 +00:00
Nigel Tao
5ae59125bf shiny/font: have Face.Glyph return an advance width, not a new dot.
This is consistent with Face.GlyphBounds and Face.GlyphAdvance.

Change-Id: I9da6b4f2fdb8f093fc9567c717e8fbbecc624e30
Reviewed-on: https://go-review.googlesource.com/14090
Reviewed-by: David Symonds <dsymonds@golang.org>
2015-08-31 01:31:05 +00:00
Nigel Tao
627898392a shiny/font: add per-glyph metrics.
Change-Id: Ie5c7e29b4eb7bd87b8e99de941f2f94b042e268f
Reviewed-on: https://go-review.googlesource.com/13827
Reviewed-by: Rob Pike <r@golang.org>
2015-08-24 05:53:06 +00:00
Nigel Tao
8ab1ac6834 math/fixed: add rectangle types and the R function.
Change-Id: Ibb3785bcd57f13c7b6f1dc37526f65e44b4ac695
Reviewed-on: https://go-review.googlesource.com/13823
Reviewed-by: Rob Pike <r@golang.org>
2015-08-24 01:31:27 +00:00
Nigel Tao
ab08d42a8a shiny/font: add Hinting, Stretch, Style and Weight option types.
These will be used by other vector font packages, such as the truetype
package, to select specific faces.

Change-Id: I3db8c97335089c2076811e8f85d9a8868fc900bd
Reviewed-on: https://go-review.googlesource.com/13714
Reviewed-by: Rob Pike <r@golang.org>
2015-08-20 02:16:59 +00:00
Nigel Tao
e87ffe258c shiny/font/plan9font: implement ParseFont.
Also delete font.MultiFace. We can resurrect a font.MultiFace type if we
need it in the future, but for now, it's simpler if it lives in the
plan9font package.

Change-Id: I1493b47696c323424e7d91cb7fac15505bfdd023
Reviewed-on: https://go-review.googlesource.com/13520
Reviewed-by: Rob Pike <r@golang.org>
2015-08-19 04:10:22 +00:00
Nigel Tao
d9c0088098 math/fixed: add I and P helper functions.
The P function is especially common in e.g. Freetype code that works
with both the integer-pixel (X,Y) coordinates used by the stdlib image
package and sub-pixel (X,Y) coordinates used by its raster package.

Change-Id: I68be8ca71ceb24f40277ecc39a0896323f6671f5
Reviewed-on: https://go-review.googlesource.com/13652
Reviewed-by: Rob Pike <r@golang.org>
2015-08-17 07:17:06 +00:00
Hariharan Srinath
b137518d47 colornames: new package for named colors
This package provides named colors as defined in the SVG 1.1 spec.
Named colors are parsed from the SVG 1.1 spec web page at
http://www.w3.org/TR/SVG/types.html and written using go generate

fixes golang/go#11734

Change-Id: Ia75a166b3714a36a07be64c7d331231b5b2d0cf2
Reviewed-on: https://go-review.googlesource.com/13181
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-08-16 00:08:16 +00:00
Nigel Tao
b96af5338f math/fixed: add Point methods (Add, Sub, Mul, Div).
These mirror the image.Point methods in the standard library.

Change-Id: I7309af308a8182e325af20b47341f72703cbc95a
Reviewed-on: https://go-review.googlesource.com/13603
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-08-13 13:30:46 +00:00
Nigel Tao
eecb4e626f shiny/font: new package for drawing text on an image.
Package font defines an interface for font faces.

Other packages provide font face implementations. For example, a
truetype package (not part of this CL) would provide one based on .ttf
font files.

This CL also introduces the golang.org/x/exp/shiny/font/plan9font
package, a concrete implementation of the font.Face interface for the
Plan 9 bitmap font format.

Change-Id: Iead8914caaa58c7562b18a86b45002ae47486903
Reviewed-on: https://go-review.googlesource.com/13463
Reviewed-by: Rob Pike <r@golang.org>
2015-08-11 05:46:15 +00:00
Nigel Tao
3029cff51e math/fixed: add point types.
Change-Id: Ie9ae62eab3c484034ee8207a2b2e573ec6f1464e
Reviewed-on: https://go-review.googlesource.com/13294
Reviewed-by: Rob Pike <r@golang.org>
2015-08-07 00:23:53 +00:00
Nigel Tao
8e3389fa81 draw: have Scale and Transform recognize straight copies.
This is only for the NearestNeighbor and ApproxBiLinear Interpolators. A
Kernel interpolator will add blur even when the dst and src rectangles
are the same size.

We do not bother recognizing Transforms that are Scales. The performance
difference is minimal, as you still need to do a per-dst-pixel inverse
mapping either way.

benchmark                           old ns/op     new ns/op     delta
BenchmarkSimpleScaleCopy-8          4866297       29586         -99.39%
BenchmarkSimpleTransformCopy-8      4875991       29531         -99.39%
BenchmarkSimpleTransformScale-8     1208147       1223206       +1.25%

Change-Id: If649ad27a4e81bcbb24b18315745c02c9186a5b7
Reviewed-on: https://go-review.googlesource.com/13004
Reviewed-by: Rob Pike <r@golang.org>
2015-08-02 10:47:07 +00:00
Nigel Tao
5ec5e003b2 math/fixed: new package.
Fixes golang/go#11906

Change-Id: I2b43311ff145e8453cd255f085c82add6da7de5b
Reviewed-on: https://go-review.googlesource.com/12863
Reviewed-by: Rob Pike <r@golang.org>
2015-07-30 06:07:28 +00:00
Nigel Tao
5f5d3e0618 draw: skip TestFastPaths for Go 1.4.
Fixes golang/go#11921

Change-Id: Iafca8b21523d486ce9b2be494b8fb93216573968
Reviewed-on: https://go-review.googlesource.com/12861
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-07-30 05:48:34 +00:00
Russ Cox
c6de6b60d2 vp8: split expression to placate 386 compiler
Fixes golang/go#11917.

Change-Id: I2eff23bd98be7531d9a115714ca50e45d3064584
Reviewed-on: https://go-review.googlesource.com/12856
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-07-29 22:52:57 +00:00
Nigel Tao
5c9906b535 image/draw: have Transform take a f64.Aff3 instead of a *f64.Aff3.
It's more args (in terms of bytes), but fewer allocations (Transformer
is an interface). Either way, it's not really that big of a deal, but
the value instead of the pointer seems conceptually more correct.

Change-Id: Ibea76da17cbda0d9633110fd56044b4e2c690e81
Reviewed-on: https://go-review.googlesource.com/12669
Reviewed-by: Rob Pike <r@golang.org>
2015-07-29 01:18:37 +00:00
Nigel Tao
8ca9b58be9 shiny/screen: new package.
Change-Id: Ib0a6296b9c117d64fc76fc6abe59ccb7da3bbae1
Reviewed-on: https://go-review.googlesource.com/12568
Reviewed-by: Rob Pike <r@golang.org>
2015-07-24 06:42:10 +00:00
Nigel Tao
6b7a488d1e draw: tweak the YCbCr to RGBA conversion formula.
This is the golang.org/x equivalent of the golang.org/cl/12220 change to
the standard library.

Change-Id: I220d1398902dec374472ef5b08db8501607cc971
Reviewed-on: https://go-review.googlesource.com/12222
Reviewed-by: Rob Pike <r@golang.org>
2015-07-15 05:30:06 +00:00