709 Commits

Author SHA1 Message Date
Romain Guy
2055abaa0a Allow layers with a stencil buffer to be resized on the fly
Bug #7146141

This change moves the resizeLayer() from LayerCache (where it should
never have been anyway) to Layer. This makes a little more sense.

Change-Id: I8b2f9c19c558e738405a58b9e71ec5799fc6be88
2013-01-18 16:42:51 -08:00
Romain Guy
8ce00301a0 Implement clipRect with a transform, clipRegion & clipPath
Bug #7146141

When non-rectangular clipping occurs in a layer the render buffer
used as the stencil buffer is not cached. If this happens on a
View's hardware layer the render buffer will live for as long
as the layer is bound to the view. When a stencil buffer is
required because of a call to Canvas.saveLayer() it will be allocated
on every frame. A future change will address this problem.

If "show GPU overdraw" is enabled, non-rectangular clips are not
supported anymore and we fall back to rectangular clips instead.
This is a limitation imposed by OpenGL ES that cannot be worked
around at this time.

This change also improves the Matrix4 implementation to easily
detect when a rect remains a rect after transform.

Change-Id: I0e69fb901792d38bc0c4ca1bf9fdb02d7db415b9
2013-01-17 15:39:31 -08:00
Romain Guy
735738c4dd Preliminary Support for region clipping
Region clipping, using Canvas.clipPath or Canvas.clipRegion, requires
a stencil buffer to be always present. In addition, extra wiring is
required in JNI and display lists.

This change only adds the necessary JNI/C++ APIs and some extra
plumbing to start the real work on properly supporting region
clipping.

A new debug define called DEBUG_CLIP_REGIONS can be used to draw
the current clip region. It is off by default, as is region
clipping.

The default implementation of clipPath() and clipRegion(), now
in native, mimics the previous Dalvik implementation to prevent
regressions.

Change-Id: I7903e7cfd7412b9b9b622566d4dbfce7bdcec00c
2013-01-14 14:27:54 -08:00
Romain Guy
5341cead27 Cleanup 9patch mesh matching code
Bug #7970966

The bug described in #7970966 should normally never happen but just in
case, change the detection code to be more robust.

Change-Id: I7040a6087590e34abe8803cb8f83f051d77f3944
2013-01-09 14:15:58 -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
Romain Guy
9acd1b4fa8 Merge "Add visual profiling feature" 2013-01-04 19:24:10 -08:00
Romain Guy
672433d90f Add visual profiling feature
When profiling is enabled with debug.hwui.profile set to true,
setting debug.hwui.profile_visualizer to true will display the
profiling data directly on screen.

Change-Id: I3d5fe3f0347090815087b1cbfce66b8e76d9347b
2013-01-04 19:21:54 -08:00
Romain Guy
886b275e52 Properly support ALPHA_8 bitmaps in all drawBitmap() methods
Change-Id: I869993c59e0a0d76f369c09acbae711753908f48
2013-01-04 15:15:16 -08:00
Romain Guy
15a65bfee5 Remove unnecessary & uninitialized variable
Bug #7728929

The uninitialized variable was taken into account to compute
the hash of gradient cache entries, thus causing cache corruptions
and sometimes infinite loops (it would also cause the cache to fill
up.)

Change-Id: Ic807a9bf901888b121a6a781a81dafc33075ed2a
2013-01-03 14:45:39 -08:00
Romain Guy
dcfc836b45 Remove C++11 related warning
Change-Id: I250ff7bd0ea49908e11b14c995d77312cd09a8b4
2013-01-03 13:08:57 -08:00
Romain Guy
53018e520d Merge "Apply dev. settings at runtime Bug #7434649" 2012-11-30 17:00:10 -08:00
Romain Guy
5bb3c730f5 Apply dev. settings at runtime
Bug #7434649

Change-Id: I16f00eaa8a5eefd9f9849e196cf2cb1659215390
2012-11-30 16:29:33 -08:00
Romain Guy
69fcbccf47 Fix crash in TextDropShadowCache
The lengths used to copy/read arrays were completely wrong.

Change-Id: If21f23a73cce59bbd32975760e6d728eeeb9e40d
2012-11-30 15:29:15 -08:00
Chris Craik
c4aa38a1e3 am c0da873e: am a9473881: am 2435f98d: Merge "Use the same interrupt/resume logic for all functor calls" into jb-mr1.1-dev
* commit 'c0da873ee25e1e67fd0454ebc2473a5c3cac002c':
  Use the same interrupt/resume logic for all functor calls
2012-11-29 14:32:45 -08:00
Chris Craik
c0da873ee2 am a9473881: am 2435f98d: Merge "Use the same interrupt/resume logic for all functor calls" into jb-mr1.1-dev
* commit 'a9473881eb066b41ea2fb3389b5c0031c2ab4f38':
  Use the same interrupt/resume logic for all functor calls
2012-11-29 14:26:33 -08:00
Romain Guy
b8dca777ca Merge "Use LruCache instead of GenerationCache in libhwui" 2012-11-29 13:58:57 -08:00
Romain Guy
059e12ccd2 Use LruCache instead of GenerationCache in libhwui
Change-Id: Ic26ddc7151eb5462bcd243b21daf7187ed6d3bec
2012-11-29 11:44:02 -08:00
Chris Craik
d15321bbf5 Use the same interrupt/resume logic for all functor calls
bug:7093396

The functor was able to change the renderer's blend mode without it
being restored in process mode. This single path of updating gl caches
reduces likelihood of this occurring in the future.

Change-Id: Ie367532f9c683299f02bc4f635d7cb31f96db39f
2012-11-28 14:45:04 -08:00
Sangkyu Lee
7bb3cfe1cc Another optimization of glyph cache uploads
Previously, cache textures were updated whenever mCurrentCacheTexuture was changed.
Since updating cache textures needs glTexSubImage2D call, frequent changing
of mCurrentCacheTexture (which can easily happen when an app uses lots of unique glyphs
even with precaching) caused many glTexSubImage2D calls and bad framerates.
This patch optimized isssueDrawCommand function. Consequently, changing mCurrentCacheTexture doesn't
cause glTexSubImage2D call any more and it will improve font rendering performance.

Change-Id: Id19d959fa0e69eeb2a39f83a57e311d7394586b2
Signed-off-by: Sangkyu Lee <geteuid@gmail.com>
2012-11-28 09:28:50 +09:00
Chris Craik
7fae5216d2 Avoid tesselation path when useCenter is set
bug:7458300

The tesselation path doesn't handle sharp joins.

Change-Id: I28bf03f3b72fc584a205daa40934dda17031098f
2012-11-01 11:27:03 -07:00
Chet Haase
fbba753f62 Merge "Handle offscreen animations correctly" into jb-mr1-dev 2012-10-23 15:46:04 -07:00
Chet Haase
3561d062ff Handle offscreen animations correctly
A bug in software rendering caused animations on views that are offscreen
to not get drawn, therefore the animation doesn't continue (since old-style
animations depend on the logic in the drawing code to keep running). Fix is
to special case the isAnimating case in ViewRoot to go ahead and schedule
a traversal even if the dirty rect does not intersect with the visible region.

Issue #7396035 Animations starting offscreen don't draw run/end/draw properly (sw rendering only)

Change-Id: Iae25b3a424ddc5a16ba431ecd68cf42d5500db3f
2012-10-23 15:30:15 -07:00
Romain Guy
41308e2936 Properly draw the window background on window resize
Bug #7385090

This change gets rid of two silly asumptions:
- That a layer needs to be cleared with opaque black (it shouldn't,
it's already cleared to transparent and the view will cover it up
with its own background)
- The the clip should be dirty at the beginning of a frame only
when the render target is opaque

Change-Id: I415b6d3cab196057fb0281419a53fef601a44e28
2012-10-22 20:02:43 -07:00
Chet Haase
547e66531d Don't null the reference to Bitmap pixels until we're really ready
A change in the VM triggers a native memory error more aggressively than before,
showing that there's a bug in the logic of recycling bitmaps. Since the pixel
memory is allocated on the Java heap, nulling out the reference to that memory
in the Java level Bitmap object can cause that memory to get collected at any time.
Meanwhile, we may have a reference to that memory at the native level for rendering
purposes, causing an error if/when we access that memory after it has been collected
by the VM.

The fix is to avoid setting the reference to the pixels to null unless we are
not referring to it in native code. This is determined at the time we call
recycle() - we return a boolean to indicate whether the native code is still
using the memory. if not, the Java code can null out the reference and allow the
VM to collect it. Otherwise, it will get collected later when the encompassing
Bitmap object is collected.

Issue #7339156 HTML5 tests crash the app (Vellamo)

Change-Id: I3a0d6b9a6c5dd3b86cc2b0ff7719007e774b5e3c
2012-10-22 15:25:19 -07:00
Romain Guy
7c25aab491 Defer layer rendering to avoid stalls
Bug #7326824

When a layer is taken out of the cache and initialized it gets cleared
to prepare it for future rendering. This triggers the following sequence
of operations:

glBindFramebuffer(layer.fbo)
attach texture storage to FBO
glClear()
glBindFramebuffer(defaultFbo)

The clear forces a resolve on tilers which stalls the CPU for a little
while, thus producing jank during animations. This change moves the
clear to the next frame when we know we will have to execute a resolve
anyway.

Change-Id: Ic1939c25df20ed65a4c48dc81ee549b2cd8b6ec3
2012-10-18 15:05:02 -07:00
Romain Guy
b2e2f24706 Take into account the texture layer's transform for clipping
Bug #7370212

Change-Id: Ibdc3161306f54a1cfe66e08458f05ee01a13b1df
2012-10-17 18:18:35 -07:00
Romain Guy
5243957080 Enable mipmapping, without a deadlock this time
Bug #7353771

Change-Id: I89a08a58608e374f1c604a26ee0769d5850b2f7b
2012-10-17 12:14:11 -07:00
Chet Haase
be29d82f74 Merge "Correctly adjust clip regions that lie offscreen" into jb-mr1-dev 2012-10-17 07:51:46 -07:00
Mathias Agopian
a33d161250 workaround to unbreak the build (deadlock during boot)
bug: 7363206
Change-Id: Ie79c309e367ba07336a5299af9fd59c6bd2390e7
2012-10-16 21:26:43 -07:00
Romain Guy
1b85122bd2 Merge "Add API to enable mipmaps on Bitmap Bug #7353771" into jb-mr1-dev 2012-10-16 19:05:49 -07:00
Romain Guy
713e1bb9df Add API to enable mipmaps on Bitmap
Bug #7353771

This API can be used when scaling large images down to a small size
to get nicer looking results.

Change-Id: If09087eed36077eee5355f6047a3ca67747d7d9e
2012-10-16 18:44:09 -07:00
Chet Haase
aa42c9af6e Correctly adjust clip regions that lie offscreen
We were clamping the x/y location of the scissor to 0,0, but not adjusting
the width/height appropriately. This fix adjusts width/height and also clamps
them to 0 to correctly clip out offscreen operations.

Issue #7221524 Top left and top right portions of the screen blanks out after some time

Change-Id: I47f23336ea612409ed86652b9a68e272819ef00e
2012-10-16 17:36:16 -07:00
Romain Guy
5778cb9a98 Merge "Always use the correct pixel store size Bug #7357394" into jb-mr1-dev 2012-10-16 13:50:54 -07:00
Romain Guy
d43b22da29 Always use the correct pixel store size
Bug #7357394

When a bitmap is reused it may change configuration which can lead
to a different pixel store alignment. Our current texture cache
implementation assumes this never happens and keeps the old alignment
which can lead to distorted texture (if the bitmap goes from
ARGB8888 to RGB565 for instance.)

Change-Id: Ic57acf2403411ae4d0924e92f221298350612617
2012-10-16 11:25:06 -07:00
Romain Guy
a92bb4dc96 Support clipping in Canvas.drawBitmapMesh()
Bug #7354162

Change-Id: Ifd1d0b365e8a4d88e0ff0629c9ee13f27e1a7331
2012-10-16 11:09:26 -07:00
Chris Craik
780c12875c HW Acceleration support for stroked arcs with BUTT caps
bug:4419017

Change-Id: I7371bfb36cef460da861a47d4d945218c6d0c3d0
2012-10-15 13:49:58 -07:00
Chris Craik
3add43ab0e Merge "fix stroke sub-hairline threshold" into jb-mr1-dev 2012-10-12 13:00:59 -07:00
Chris Craik
2154af209f fix stroke sub-hairline threshold
bug:7339943

Change-Id: I4051a03f4cd5bd2c313840208540601fb7a056e2
2012-10-12 12:45:08 -07:00
Romain Guy
c37f349ecf Prevent possible divide by 0
Bug #7307304

Should never happen, but eh :))

Change-Id: Ic7a09fd5c7a3622e6b4963f9ee6920e232018e2e
2012-10-10 17:13:36 -07:00
Romain Guy
41d35aef06 Allow 9patches to shrink
Bug #7307304

Change-Id: I1fabf6df99c18c86ab1ec0e1e398a3d6d4098496
2012-10-10 16:06:04 -07:00
Chris Craik
bb5f014ae8 Merge "Use offset in line drawing" into jb-mr1-dev 2012-10-08 09:46:05 -07:00
Romain Guy
50ae66a554 Work around a possible driver bug
Bug #7296475

When re-enabling the scissor the driver seems to ignore the already
existing scissor box. This change resets the scissor box when the
test state changes.

Change-Id: I3a68433164f99d21fbab769a26c56fe416c1539a
2012-10-07 15:23:55 -07:00
Chris Craik
b30cb10a0c Use offset in line drawing
Partial revert of cb4d6009

bug:7299070
Change-Id: I1db7b035e3015e0f6d15c95aef71ea74dbeca13e
2012-10-05 19:14:02 -07:00
Romain Guy
cf8675ee17 Draw stroked rectangle as meshes instead of textures
Bug #7233734

Stroked rectangles were rendered using software generated textures
which would lead to slightly misaligned results. Instead, let's use
the new convex path rendering code that will do the right thing
(and save a lot of bandwidth.)

Change-Id: Ib95ff581e56c1ecead97e4919298e6fd146ca167
2012-10-02 13:33:10 -07:00
Chris Craik
bf09ffb4e0 Quick reject empty paths
bug:7260035

Adding a circle of radius 0 to a path is a no-op in skia, so detect
this case both in the PathRenderer, and in quickReject().

Change-Id: I7a172db49a5d5351b4734b39d4e4ca6379658096
2012-10-01 13:50:37 -07:00
Chet Haase
6a2d17f713 Fix texture corruption
When memory gets low on a device, activities flush everything they can.
Hardware-accelerated activites, such as Launcher, flush GL resources and destroy
the GL context. However, some resources were still hanging around, due to deferred
destruction policies (we don't delete layers until the DisplayLists they are in
are finalized, to ensure we don't deref deleted objects). This meant that we were
referring to obsolete GL data in these objects. in particular, it meant that we might
come around later, after a new GL context was created, and delete a texture object
that was incorrect. We use the layer's "texture id" to refer to the texture underlying the
layer. But if there's a new GL context, then this texture ID is no longer valid, and
we may be deleting the texture that a different object (layer, icon, whatever) is referring
to, because the driver may return that same ID under the new GL context.

The fix is to more aggressively delete things that we know will not be used again
when the GL context is destroyed. In particular, we delete all resources being used
by all DisplayLists at GL context destruction time.

Issue #7195815 Textures corruption on all devices, in many apps

Change-Id: I52d2d208173690dbb794a83402d38f14ea4c6c22
2012-09-30 15:35:08 -07: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
Hiroshi Lockheimer
a7a257d657 Merge "Plug memory leak that happens when reusing display lists Bug #7195815" into jb-mr1-dev 2012-09-27 22:23:28 -07:00
Romain Guy
034de6b1ec Plug memory leak that happens when reusing display lists
Bug #7195815

We did not reclaim resources when reusing an existing DisplayList to
record a new empty list of commands. This would lead to various memory
leaks: bitmaps, paints, paths, matrices, etc.

This is not a common case but some apps run into this situation,
such as Launcher.

Change-Id: I2eb14ac86a212123f8edbe42b70a7c1c51fa4145
2012-09-27 19:01:55 -07:00
Romain Guy
a852ff3a4b Merge changes I9873540e,I4f6c38e3 into jb-mr1-dev
* changes:
  Skia's ColorMatrix vector is in the 0..255 range not 0..1 Bug #7248980
  Don't use the QCOM_tiled_rendering extension with functors Bug #7247880
2012-09-27 18:45:42 -07:00