Commit Graph

691 Commits

Author SHA1 Message Date
Seebs b6533006e7 smaller imdraw optimizations
For polyline, don't compute each normal twice; when we're going through a line,
the "next" normal for segment N is always the "previous" normal for segment
N+1, and we can compute fewer of them.
2017-06-09 10:37:47 -05:00
Seebs 9d1fc5bd1f use point pool
For internal operations (anything using getAndClearPoints), there's a
pretty good chance that the operation will repeatedly invoke something
like fillPolygon(), meaning that it needs to push "a few" points
and then invoke something that uses those points.

So, we add a slice for containing spare slices of points, and on the
way out of each such function, shove the current imd.points (as used
inside that function) onto a stack, and set imd.points to [0:0] of
the thing it was called with.

Performance goes from 11-13fps to 17-18fps on my test case.
2017-06-09 10:37:47 -05:00
Seebs c321515d3c Simplify Matrix math, use 6-value affine matrixes.
It turns out that affine matrices are much simpler than the 3x3 matrices
they imply, and we can use this to dramatically streamline some code.
For a test program, this was about a 50% gain in frame rate just from
the cost of the applyMatrixAndMask calls in imdraw, which were calling
matrix.Project() many times. Simplifying matrix.Project, alone, got a
nearly 50% frame rate boost!

Also modify pixelgl's SetMatrix to copy the six values of a 3x2
Affine into the corresponding locations of a 3x3 matrix.
2017-06-09 10:37:43 -05:00
Seebs 1586e600a0 The initializer is surprisingly expensive.
Removing the call to Alpha(1) and replacing it with an inline definition
produces measurable improvements. Replacing each instance of ZV with
Vec{} further improves things. We keep an inline RGBA because there
are circumstances (mostly when using pictures) where we don't want to
have to set colors to get default behavior.

For a fairly triangle-heavy thing, this reduces time spent in SetLen
from something over 10% of execution time to around 2.5% of execution
time.
2017-06-07 21:25:54 -05:00
faiface 9bd9df98f2 add text tutorial link to README 2017-05-30 02:53:24 +02:00
faiface 793d1e6a9a fix typo in doc 2017-05-28 18:50:56 +02:00
faiface f0c42c6e56 add Canvas.Frame method 2017-05-28 18:44:30 +02:00
faiface fa2c741fcf switch to OpenGL 2.1 2017-05-27 13:14:13 +02:00
faiface 28aad855b8 remove accidentaly set theme 2017-05-25 22:51:17 +02:00
Michal Štrba f179118d9e Set theme jekyll-theme-time-machine 2017-05-25 20:03:02 +02:00
faiface 4a0a68effc update drawing features in README 2017-05-24 20:39:11 +02:00
faiface 4dc0fb6f8b add text input mention to README 2017-05-24 14:42:00 +02:00
faiface bbde3a6109 add text drawing feature mention to README 2017-05-24 14:36:18 +02:00
faiface a056444410 fix link in README 2017-05-24 14:34:49 +02:00
faiface a5603e8379 replace xor screenshot with typewriter screenshot in README 2017-05-24 14:33:50 +02:00
faiface b8a287a654 clarify Rect doc 2017-05-21 19:38:21 +02:00
faiface ce8408054d fix typo in ToRGBA doc 2017-05-21 19:33:01 +02:00
faiface 523e6d3e9a fix Matrix doc 2017-05-21 19:30:29 +02:00
faiface fcfeb200b6 replace complex128 Vec with a struct 2017-05-21 19:25:06 +02:00
faiface 8221ab58bc remove Text.SetMatrix and Text.SetColorMask, add Text.Draw(target, matrix) and Text.DrawColorMask(target, matrix, mask) 2017-05-21 18:23:51 +02:00
faiface 9b7b8d5a0e minor change 2017-05-21 18:23:20 +02:00
faiface 85ef4290b8 update Sprite's doc 2017-05-21 15:31:07 +02:00
faiface 37cd58f0ae remove Text.Matrix() and Text.ColorMask() getters 2017-05-19 01:58:34 +02:00
faiface aa50147c35 change Text properties to fields 2017-05-18 23:59:42 +02:00
faiface 022f25895a change IMDraw properties to fields 2017-05-18 23:50:45 +02:00
faiface 6735475b44 change Sprite.Draw and Canvas.Draw signatures (include Matrix) 2017-05-17 23:45:22 +02:00
faiface fdddde2780 accept zero target size in Rect.Resized 2017-05-15 01:15:16 +02:00
faiface fb51cd9ecb improve Atlas creation time 2-3 times 2017-05-11 19:48:43 +02:00
faiface be2434cfa8 add Window.Repeat 2017-05-10 23:54:06 +02:00
faiface 9062f1eae9 fix and simplify input handling in Window 2017-05-10 21:22:47 +02:00
faiface c9319763d7 add Window.Typed 2017-05-10 21:10:10 +02:00
faiface 9554cd9c20 change text.New to take an Atlas 2017-05-10 17:56:09 +02:00
faiface ef86fe9b20 add text package doc 2017-05-09 16:48:26 +02:00
faiface 101637439e add Text.Matrix and Text.ColorMask 2017-05-09 16:46:11 +02:00
faiface b0e2bd1035 add examples on LineHeight and TabWidth to Text doc 2017-05-09 16:40:44 +02:00
faiface e1f364e5d1 add note about not destroying face.Face to Atlas doc 2017-05-09 16:39:03 +02:00
faiface ef5de4c8c3 mention control characters in Text doc 2017-05-09 16:36:59 +02:00
faiface ee6871c7b8 remove accidental markdown formating from Text doc 2017-05-09 16:35:51 +02:00
faiface fc8eafe3d5 fix typo in Text doc 2017-05-09 16:34:54 +02:00
faiface 81e2e645bd minor change in Text doc 2017-05-09 16:34:13 +02:00
faiface 067d9f48d9 minor change in Atlas doc 2017-05-09 16:32:29 +02:00
faiface 3035fcac9c clarify doc 2017-05-09 16:31:09 +02:00
faiface c5df68f8bb add Text doc 2017-05-09 16:27:55 +02:00
faiface c1f3267176 minor change 2017-05-09 15:26:50 +02:00
faiface e1dba0eb54 add Atlas doc 2017-05-09 15:25:08 +02:00
faiface e7a7ac4026 don't cache kerning in Atlas (too expensive and no benefit) 2017-05-09 15:10:35 +02:00
faiface 847b48292b improve Atlas creation, atlas is now square picture (was one row of characters) 2017-05-09 14:20:34 +02:00
faiface cfa9180bb7 fix PictureDataFromImage (wrong bounds when Min not (0, 0)) 2017-05-09 01:04:04 +02:00
faiface 6ce4094935 rename Text.LineHeight(scale) -> height, since now it's absolute height 2017-05-07 22:03:56 +02:00
faiface c0378a703e rename Glyph.Orig -> Dot 2017-05-07 21:49:26 +02:00