25 Commits

Author SHA1 Message Date
Romain Guy
661a87ec28 Reduce number of glDraw calls when drawing text
This change moves the mesh buffer from FontRenderer to CacheTexture
to help reduce the number of texture binds and glDraw calls when
drawing text that spans across multiple textures.

Change-Id: I7de574d88313ca3672879ca878c253ff5f131fc1
2013-03-19 17:24:13 -07:00
Romain Guy
115096f50a Minimize texture binds when drawing text
When several CacheTextures are used to draw text, sort the
draw batches by texture ID to minimize state changes in the
driver.

This change also tweaks the font cache size and renames
a property that was too long to be set using setprop.

Change-Id: I0a36dfffe58c9e75dd7384592d3343c192d042b1
2013-03-19 11:32:41 -07:00
Romain Guy
bd3055f95e Less aggressive glyphs precaching
The renderer used to pre-cache glyphs at record time. This then changed
to pre-caching at the beginning of every frame. This unfortunately entails
a lot of duplicate work on every frame, which amounts to 0.5 to 1ms in
some stock applications.

This change is somewhere in the middle: pre-caching happens the first
time a DrawTextOp is deferred or every time the screen-space transform
is different from the last pre-caching operation.

Change-Id: Id6d9e2599d90a5b75010b0f0a28746befbf3c205
2013-03-13 16:14:47 -07:00
Romain Guy
8afce816df Round scale factors to rasterize text
Harder, better, faster, stronger.

Change-Id: Iee4125de98c4e61603f56bb7f06002cc86458214
2013-03-06 19:09:59 -08:00
Romain Guy
624234f69b Take only the scale params into account to rasterize text
This change extracts the scale parameters of the current transform
to pass then to the font renderer. Rotation and perspective are
applied to the generated mesh inside the vertex shader. This limits
the number of glyphs we have to create in the font cache and thus
reduces memory churn.

Change-Id: Ic5b3bae2b2b0e0250a8ee723b071a1709725c749
2013-03-05 18:12:35 -08:00
Romain Guy
874f5c6e4a Fix math issue when transforming text in perspective
Change-Id: Iad6b4e477c11bd1ef5f0ceab2fabcd440030154d
2013-03-01 18:07:35 -08:00
Romain Guy
0f6675332c Precache glyphs at final raster size
The deferred display lists model now allows us to precache glyphs
at their exact size on screen.

This change also removes debug markers when the renderer defers
and reorders display lists. It also adds a flush event marker.

Change-Id: I66ec5216dc12b93ecfdad52a7146b1cfb31fbeb4
2013-03-01 16:04:53 -08:00
Romain Guy
a4adcf0239 Support 3D rotations when drawing text
If a perspective transform is set on the Canvas, drawText() should
not attempt to rasterize glyphs in screen space. This change uses
the old behavior instead (i.e. rasterize the glyphs at the native
font size and apply the transform on the resulting mesh.)

This change also adds an optimization: empty glyphs (spaces) do
not generate vertices anymore. This saves a lot of vertices in text
heavy applications such as Gmail.

Change-Id: Ib531384163f5165b5785501612a7b1474f3ff599
2013-02-28 16:04:48 -08:00
Romain Guy
c74f45a334 Properly scale text
This change does not apply to drawPosText() and drawTextOnPath() yet.

Prior to this change, glyphs were always rasterized based on the
font size specified in the paint. All transforms were then applied
on the resulting texture. This creates rather ugly results when
text is scaled and/or rotated.

With this change, the font renderer will apply the current transform
matrix to the glyph before they are rasterized. This generates much
better looking results.

Change-Id: I0141b6ff18db35e1213e7a3ab9db1ecaf03d7a9c
2013-02-27 15:49:57 -08:00
Romain Guy
e67307c816 Prevent crash when setting up a stencil-based clip
Bug #8177690

Clear the layers before we setup the stencil to avoid dereferencing
the recently deleted rects.

Change-Id: I5dce5f965672f276f9490636d85b6018d3ab9422
2013-02-11 18:04:23 -08:00
Derek Sollenberger
23e500d168 Merge "Merge remote-tracking branch 'goog/master-chromium' into 'goog/master'" 2013-02-06 12:57:38 +00:00
Romain Guy
b969a0de65 Add support for non-antialiased text
Change-Id: I17c073955ab94abc9b409e5fcfbc675faa07c5ba
2013-02-05 14:44:43 -08:00
Romain Guy
14c40b4756 Fix build
Change-Id: Ia465bd844b592fc05e59ad392ecc5ca4d34d24d7
2013-01-08 18:03:07 -08:00
Romain Guy
19d4f1806a resolved conflicts for merge of c88c60be to master-chromium
Change-Id: I3b4b42443312068e942aa779dfdc928afa7569fd
2013-01-08 17:38:15 -08:00
Romain Guy
e3a9b24b5e Add plumbing for better text scaling
Fonts are now described by a transform matrix. This lead to switching
from a vector to a hashmap. This change therefore adds new comparators
and hash computations to Font.

Change-Id: I2daffa7d6287c18554c606b8bfa06640d28b4530
2013-01-08 15:21:42 -08:00
Derek Sollenberger
ca79cf69d0 Update framework to support r5967 of Skia.
bug: 6906025
Change-Id: Iefdb830ec3aa2ab3472c1c142484a7aa21788a15
2012-12-12 15:28:54 -05:00
Romain Guy
a3dc55f83a Fix a couple of rendering issues
Bug #7253839

1. Make sure we don't make GL calls while recording display lists

2. Disable an early and trivial clip optimization in font renderer
   when a perspective transformation is used on the Canvas

Change-Id: I3f1052164239329346854f72d0a0d401fbfecf06
2012-09-28 13:55:44 -07:00
Romain Guy
d392b87e3d Merge changes Ib0a0b7d1,Ibec4b2aa into jb-mr1-dev
* changes:
  Fix overdraw debug on QCOM
  Make sure we never bind to texture #0 Bug #7195815
2012-09-23 15:00:46 -07:00
Romain Guy
574cf6070d Make sure we never bind to texture #0
Bug #7195815

Change-Id: Ibec4b2aa4c580419eb5eb61adae6c9c960694d0c
2012-09-23 14:45:31 -07:00
Chet Haase
b92d8f7979 Optimize glyph cache texture uploads
Only upload the changed area of the glyph cache, not the entire
bitmap. Note that we can't do the full-on optimization here of copying a sub-rect
of the bitmap because of GL ES 2 limitations, but we can at least copy the
horizontal stripe containing the dirty rect, which can still be a big
savings over uploading the entire bitmap.

Issue #7158326 Bad framerates on MR1 (Mako, Manta, Prime)

Change-Id: Iab38d53202650f757ead4658cf4287bdad2b3cb9
2012-09-23 12:16:02 -07:00
Romain Guy
521dc51fd4 Don't invalidate all the glyphs when flushing large textures
FontRenderer::flushLargeCaches identifies the large textures used to
cache glyphs and visits all the known fonts to mark their glyphs
invalid if they belong to one of these large textures.

Unfortunately, Font::invalidateTextureCache had a logic error
which would make it mark *all glyphs* as invalid, not matter
what texture they belong to. This means that any large cache
flush would cause all glyphs to be invalidate, thus forcing
the rendering system to recreate them on the next draw.

Font::invalidateTextureCache is supposed to behave this way:
- If the specified cacheTexture is NULL (default value), mark
all glyphs as invalid (see FontRenderer::flushAllAndInvalidate())
- If cacheTexture is *not* NULL, invalidate only the glyphs for
which glyph.cacheTexture == cacheTexture.

The previous condition read:

if (cacheTexture || glyph.cacheTexture == cacheTexture)

This test *always* passes.

Change-Id: I418886cb594c81c6178d0f9e9953d975e991cf22
2012-09-04 19:20:06 -07:00
Romain Guy
e43f785b7f Correctly check the height of a glyph prior to caching it
Change-Id: Iaf3977afc20fcde65bfda7b9e092b3e723241684
2012-09-04 18:58:46 -07:00
Romain Guy
8087246d99 Code cleanup in FontRenderer
Change-Id: Ic788721c224a77f0a76f4cd6d9817b62e390a5a7
2012-09-04 16:44:17 -07:00
Romain Guy
9b1204baf4 Small code cleanup in FontRenderer
Change-Id: I09c00debe9b0b4f45b232cae402ed19bdaeabfe4
2012-09-04 15:25:30 -07:00
Romain Guy
9f5dab3fc2 Refactor FontRenderer.cpp
FontRenderer.h defined several classes and structures that now live
in the font/ folder. This will make the code easier to read and
maintain.

Change-Id: I3dc044e9bde1d6515f8704f5c72462877d279fe2
2012-09-04 12:55:44 -07:00