73 Commits

Author SHA1 Message Date
Chris Craik
48a8f431fa Move several property queries to Properties class
bug:17478770

This removes a lot of redundant property query code, and puts the
queries all in one place, so defining them automatically will be simpler
in the future.

Change-Id: I0428550e6081f07bc6554ffdf73b22284325abb8
2016-02-05 17:38:22 -08:00
John Reck
38e0c32852 Track texture memory globally
Also mostly consolidates texture creation

Change-Id: Ifea01303afda531dcec99b8fe2a0f64cf2f24420
2016-01-14 13:42:12 -08:00
John Reck
9557dcd53b Merge "Fix HWUI Path Cache dangling pointer" am: 37bf3ec9d2 am: 7516d4d866
am: 1b85ce17a3

* commit '1b85ce17a316973a170b3932f2d0a9b02063eaa3':
  Fix HWUI Path Cache dangling pointer
2015-11-10 23:36:27 +00:00
Digish Pandya
2e4f67c388 Fix HWUI Path Cache dangling pointer
When precache, PathTexture is added to PathCache, and it is released after drawn if we want to clean it.
But the PathCache LRU still holds the entry of the PathTexture object. When trim the cache in
the end of each frame, LRU finds that its mListener is not NULL and invoke the functor, however,
mListerer points to the released PathTexture object and is a dangling pointer, thus leads to crash.
Smart pointer don't help here since they only manage scopes, while PathTexture is also controled by
its cleanup field.
The fix is to also remove the LRU entry of PathTexture*, it will also release the texture object
and there won't be texture leaks.

Change-Id: Iaa0621df5dc71532e9e75b38ad94384353930b95
2015-11-09 14:22:25 +05:30
John Reck
6b50780363 Remove almost-all android::Singleton users
Bug: 25426213
Change-Id: I88e6206e8915cce95c3a8a8a82a4bb8fbf668141
2015-11-03 10:09:59 -08:00
Chris Craik
11718bc17b Remove shader based gamma approach
Also fixes some INIT_LOGD logs

Change-Id: I212a71a1e7b366aea41f7c3c8cc169d509d6e4a2
2015-09-22 11:58:32 -07:00
John Reck
272a685f17 Replace most usages of utils/Vector.h
Change-Id: I540d1b3523244d6c71fc52d6fb30555271c25644
2015-07-30 09:51:52 -07:00
Chris Craik
5a4690bf26 Clean up unncessary defines
LOG_TAG and TRACE_TAG are already defined in the makefile

Change-Id: I9e53e3dacbe018441edd74cb7c8c90846defee74
2015-07-14 13:25:38 -07:00
Chris Craik
e6a15ee3d0 Remove all usage of fmin and fmax
bug:22208220

Removes needless call, and upconversion to doubles in multiple places.

Change-Id: I1b949fa5f206446ac34de800154c0147d6bd8034
2015-07-07 18:42:42 -07:00
Chris Craik
cf8426c4eb Add tracing for path texture upload
Change-Id: I4918e5a3c7e01b321d428b20babd48bf69a708e4
2015-05-13 17:05:48 -07:00
Chris Craik
42455fc918 Remove usage of Texture::cleanup in PathCache
bug:21039605

Was causing double-deletes, is unneeded.

Change-Id: I5c0a21d076fae7039d777ca09b21492f97fea98b
2015-05-11 19:10:24 -07:00
Chris Craik
2507c34d91 Cleanup properties
bug:19967854

Separate properties from Caches, into static, RenderThread-only class.

Also rewrites the means for java to set properties to correctly handle
threading, and adds an override for profile bars so that SysUi doesn't clutter
the screen with them.

Change-Id: I6e21a96065f52b9ecc49d1a126244804ba106fa9
2015-05-05 10:36:09 -07:00
Chris Craik
dee66b6d99 Simplify TaskManager fallback path
Change-Id: Ie3833449f7fe6aa69b9f71eb8bab1bef0fe434aa
2015-04-20 14:54:49 -07:00
Chris Craik
e2bb380bc2 Use glops for text rendering
Change-Id: I5e155c8baf3149f0ff231ec3c89dbff6bb8eae92
2015-03-18 16:10:24 -07:00
Derek Sollenberger
ee248599d4 Refactor DisplayList path caching.
This removes dependence on SkPath ptrs that HWUI does not control
the lifecycle of. This clears up some errors where the paths are
not generated from Java, but rather the Skia test suites.

Cherry-pick of a change that originally landed in master-skia and is
dependent on a skia merge (ag/655422).

Change-Id: I41b9797a2b0af5d6b4ea51891565469d4f1d832d
2015-03-13 08:05:55 -04:00
John Reck
3f5175fccd resolved conflicts for merge of c7e6b93a to master
Change-Id: I4b791f37193727a0306214645f2f98cdf218cad0
2015-02-04 14:47:23 -08:00
John Reck
c7e6b93aba am af6eaf65: Merge "Fix ANR caused by hwuiTask thread" automerge: 5ad36d4
* commit 'af6eaf656ec0de5fcbea03968daffe2c845e2089':
  Fix ANR caused by hwuiTask thread
2015-02-04 22:08:27 +00:00
Chris Craik
44eb2c0086 Refactor blending and texture gl state
Change-Id: Ia6b3c8b2afd3dfcee7f3ce401d846b789612054a
2015-01-30 10:49:05 -08:00
Chris Craik
96a5c4c7ba Move more GL state management to RenderState and its directory
Change-Id: Ic68584e1c08dc64be2ad43450cb6caa1de834fdc
2015-01-28 16:32:39 -08:00
Sangkyu Lee
c3c58e015f Fix ANR caused by hwuiTask thread
If hwuiTask thread is exited while HWUI renders something,
some tasks can remain unfinished forever.
This can make ANR problem if RenderThread waits this kind of tasks.

According to the current implementation, hwuiTask threads are
exited when HWUI receives trimMemory() callback with level >= 20
and some applications such as SystemUI can receive trimMemory()
with level >= 20 even though they renders something yet.
(For instance, when RecentsActivity in SystemUI is finished,
HWUI receives trimMemory() callback with level >= 20
but SystemUI should still render the status bar and navigation bar.)

This patch prevents the tasks from remaining unfinished and
make the tasks executed immediately if they cannot be added
to their TaskProcessors.

Change-Id: I5bd26439aa5f183b1a7c1ce466362e27554b4d16
2015-01-12 13:10:52 +09:00
Chris Craik
d41c4d8c73 Add overrides and switch to nullptr keyword for all files
Adds remaining missing overrides and nullptr usages, missed due to
an extreme failure in tool usage.

Change-Id: I56abd72975a3999ad13330003c348db40f59aebf
2015-01-05 16:49:13 -08:00
John Reck
f088c349df Fix style
Change-Id: I7227b0eac126bf470ed50249a7809b845872983b
2014-12-12 09:49:29 -08:00
Andreas Gampe
64bb413a66 Revert "resolved conflicts for merge of 220c3f4f to master"
Reverted as hwui doesn't agree.

This reverts commit 8a902d9f24e83c87b054adb5836b4a5b8a257be9.

Change-Id: I109e7b02bee2921e2155ded6df36f52e6f574b5a
2014-11-22 00:35:09 +00:00
John Reck
8b59a528b5 Revert "Frameworks/base: Unused parameters in hwui"
This reverts commit 42ddc18d108f789705ad4eb697ce9599ad322507.

Change-Id: I3574a936a39a96314db6437d0a1eb58d260d893d
2014-11-22 00:10:02 +00:00
Andreas Gampe
2ab8298dc3 resolved conflicts for merge of 99377df1 to lmp-mr1-dev-plus-aosp
Change-Id: I3a98f55832ac447b1ed0dd129c7a93d088025943
2014-11-21 14:19:06 -08:00
Andreas Gampe
42ddc18d10 Frameworks/base: Unused parameters in hwui
Remove Clang cutout for unused parameters. Fix warnings.

Remove Clang cutout for deprecated Skia function usage. Has been
fixed in the L push.

Change-Id: I7ea073ff67127cc1e14e798b655e2c50615fe8e7
2014-11-21 10:39:21 -08:00
Chris Craik
f2235b6a48 resolve merge conflicts of 57b641a to lmp-mr1-dev-plus-aosp.
Change-Id: I1be708f5a0cd4d64021a57f1063d54330f1d2d7e
2014-11-20 16:38:06 -08:00
Chris Craik
70850ea258 Improve logging around performance critical events
bug:17702227

Add details useful to developers (such as layer size/View name), and
switch away from logging implementation names/details, since they
are generally not relevant to developers.

Change-Id: Iee605d182f241450f7e75a6d0c283d51fa1312f5
2014-11-19 17:24:30 -08:00
Andreas Gampe
1e19674107 Frameworks/base: Wall Werror in libs/hwui
Turn on -Wall -Werror in libs/hwui. Fix errors.

Change-Id: I74962d08c889712dacbd0d86d6760fc10802b6bd
2014-11-10 15:58:04 -08:00
Chris Craik
98d608dba6 Minor cleanups around color usage
Change-Id: I56733cbe933a58d5977c032f056abb35265ee252
2014-07-17 12:25:11 -07:00
Chris Craik
906d47fd2b Deep copy SkPath parameter to PathCache task
bug:15440706
Change-Id: I2b5b25f620df838cb1155cc8502d86ad3644c212
2014-06-30 18:02:23 +00:00
Mike Reed
b933055cf3 stop using (deprecated) SkBitmap::Config
Change-Id: Ic75b5fc6996578e9d95bd3a220439ec1541d7c3b
2014-06-20 10:28:37 -04:00
Chris Craik
1e5cf9aced am b1c76a1a: Merge "Tessellate on worker threads" into lmp-preview-dev
* commit 'b1c76a1abcfb2f33e12fef37ec71d20724863b5e':
  Tessellate on worker threads
2014-06-10 17:22:31 +00:00
Chris Craik
05f3d6e511 Tessellate on worker threads
Tessellate and cache (where possible) shadow and round rect
tessellation tasks.

Change-Id: I2cfda8e11d83d51ea74af871235cf26e8f831d40
2014-06-10 01:53:17 +00:00
Kenny Root
25e40de45f resolved conflicts for merge of b68f5f09 to master
Change-Id: Ib8dd3a353f40a3357c8dc5ac591cd5e3ab4d0a4b
2014-05-30 11:51:20 -07:00
yuyang
7061f7d791 Fix a resource race bug in PathCache
When enabled defer rendering, it will do precache for DrawPathOp.
The paint used for creating PathTask in precache just get the address
of mFilteredPaint of OpenGLRenderer. So for the following defer
operation like DrawTextOp has possibility change the mFilteredPaint
by getPaint while another WorkerThread in PathCache is using the paint
which pointed to the same address of mFilteredPaint to generate bitmap.
As a result, it will generate a wrong bitmap for generateTexture in
PathCache. To fix it, do a copy of paint when creating PathTask.

CRs-Fixed: 664244

Change-Id: I5516f5b143458b88d3573d15b7ebb34f688800c7
2014-05-30 08:26:37 +05:30
Chris Craik
300bdfa13d am 328b7ee6: am aecb8c43: am 7b4cce68: am c3bac8a0: Merge "Fix graphics corruption caused by HWUI caches"
* commit '328b7ee6a2ba2dc8f162fa57dbafd4bfc89bb72e':
  Fix graphics corruption caused by HWUI caches
2014-02-26 19:31:16 +00:00
Sangkyu Lee
36fad8f6fc Fix graphics corruption caused by HWUI caches
Some caches(PatchCache, TextureCache, PathCache) for HWUI
uses deferred removal for their cache entries even though
actual resource objects are immediately freed by
ResourceCache.
For this reason, the uniqueness of a resource address in
the caches is not guaranteed in specific cases.
(Because malloc() can return the same address when malloc()
and free() called very frequently.)

So it can be possible the cache have two cache entries for
two different resources but the same memory address.
(Of course one of the resources is already freed.)
It also can be possible mGarbage vector in PatchCache has
duplicated addresses and this can lead to duplicated free
blocks in the free block list and graphics corruption.
(Deferred removal was implmeneted based on an assumption of
unique resource addresses.)

So this patch makes sure resource objects are freed after
the resources are removed from the caches to guarantee
the uniqueness of a resource address and prevent graphics
corruption.

Change-Id: I040f033a4fc783d2c4bc04b113589657c36fb15b
Signed-off-by: Sangkyu Lee <sk82.lee@lge.com>
2014-02-26 10:43:26 -08:00
Chris Craik
d218a92c0a Use const where possible for drawing parameters
They should never be modified by a Renderer, only read and copied.

Change-Id: I9d8d55dca19115ee9dfeb2bb3f092ba2fb327cd4
2014-01-03 13:55:08 -08:00
Romain Guy
5d92320084 Second attempt at avoiding infinite loop in PathCache::trim()
Bug #10347089

Change-Id: I70f5a3933e848632473acc6636c88be5dc6ac430
2013-08-21 18:42:46 -07:00
Romain Guy
0a8c51b1d0 Properly account for created paths in the cache
Change-Id: I47b89b3085cefab6daac9194e7bfd3c140b37fa2
2013-08-21 17:35:38 -07:00
Romain Guy
e3b0a0117a Refcount 9-patches and properly handle GC events
This change adds refcounting of Res_png_9patch instances, the native
data structure used to represent 9-patches. The Dalvik NinePatch class
now holds a native pointer instead of a Dalvik byte[]. This pointer
is used whenever we need to draw the 9-patch (software or hardware.)

Since we are now tracking garbage collection of NinePatch objects
libhwui's PatchCache must keep a list of free blocks in the VBO
used to store the meshes.

This change also removes unnecessary instances tracking from
GLES20DisplayList. Bitmaps and 9-patches are refcounted at the
native level and do not need to be tracked by the Dalvik layer.

Change-Id: Ib8682d573a538aaf1945f8ec5a9bd5da5d16f74b
2013-06-26 17:15:08 -07:00
Romain Guy
be1b127c7b Assume a texture is unbound after deleting it
Bug #9316260

The GL specification indicates that deleting a bound texture has
the side effect of binding the default texture (name=0). This change
replaces all calls to glDeleteTextures() by Caches::deleteTexture()
to properly keep track of texture bindings.

Change-Id: Ifbc60ef433e0f9776a668dd5bd5f0adbc65a77a0
2013-06-06 16:26:51 -07:00
Romain Guy
8aa195d708 Introduce Caches::bindTexture() to reduce glBindTexture calls
Change-Id: Ic345422567c020c0a9035ff51dcf2ae2a1fc59f4
2013-06-04 18:58:36 -07:00
Romain Guy
4500a8d5d7 Path precaching creates duplicate cache entries
Bug #8478275

Change-Id: Ib541ea051e42e01cc0d277790e9c09de38ef72ee
2013-03-26 17:29:51 -07:00
Romain Guy
c5cbee7d78 Stop worker threads on memory trim & fix bad pointer access
Change-Id: I6fe7e31aeb6dd41fa65ab952caed97bc2da510d7
2013-03-20 19:16:53 -07:00
Romain Guy
c46d07a29e Merge all shapes/paths caches to PathCache
This change will greatly simplify the multi-threading of all
shape types.

This change also uses PathTessellator to render convex paths.

Change-Id: I4e65bc95c9d24ecae2183b72204de5c2dfb6ada4
2013-03-18 18:32:17 -07:00
Romain Guy
0f809f3b79 Prevent infinite loop when trimming the path cache
Change-Id: I04b5fa498336068f997c68d8613b35a99f67adbe
2013-03-13 14:32:45 -07:00
Romain Guy
5dc7fa7096 Add TaskManager API
This API can be used to run arbitrary tasks on a pool of worker
threads. The number of threads is calculated based on the number
of CPU cores available.

The API is made of 3 classes:

TaskManager
      Creates and manages the worker threads.

Task
      Describes the work to be done and the type of the output.
      A task contains a future used to wait for the worker thread
      to be done computing the result of the task.

TaskProcessor
      The processor dispatches tasks to the TaskManager and is
      responsible for performing the computation required by
      each task. A processor will only be asked to process tasks
      sent to the manager through the processor.

A typical use case:

class MyTask: Task<MyType>

class MyProcessor: TaskProcessor<MyType>

TaskManager m = new TaskManager();
MyProcessor p = new MyProcessor(m);
MyTask t = new MyTask();
p.add(t);

// Waits until the result is available
MyType result = t->getResult();

Change-Id: I1fe845ba4c49bb0e1b0627ab147f9a861c8e0749
2013-03-12 15:06:42 -07:00
Romain Guy
ca89e2a687 Precache paths from a worker thread
Change-Id: I3e7b53d67e0e03e403beaf55c39350ead7f1e309
2013-03-11 17:05:28 -07:00