423 Commits

Author SHA1 Message Date
Victoria Lease
6eb2810318 am 183f97b7: am 1c12f9e7: malloc some advances
* commit '183f97b72faf7a0f45ad66e1b3fd9a4343cc7482':
  malloc some advances
2014-03-19 14:32:15 -07:00
Victoria Lease
183f97b72f am 1c12f9e7: malloc some advances
* commit '1c12f9e76298c757423155ad812890d27effafe8':
  malloc some advances
2014-03-19 14:27:19 -07:00
Victoria Lease
1c12f9e762 malloc some advances
Bug: 13506939
Change-Id: I87ad616960c4f16bc55d8b906049dbd4f001d6a5
(cherry picked from commit 3af2a37e057b31617b8f4eeb22ac3ef85c3fd5aa)
2014-03-18 16:22:20 +00: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
Bart Sears
0ee71adde0 Merge "Fix native crash while saving a panorama." into jb-mr1-dev 2012-10-17 10:20:50 -07:00
Wu-cheng Li
4b63f14c96 Fix native crash while saving a panorama.
YuvToJpegEncoder should handle the case when the height is not
multiples of 16.

bug:7165606

Change-Id: I02f142b233c4f5c0cd8df5e3d1eaebbf62d28052
2012-10-17 18:06:59 +08: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
Keun young Park
038953da05 fix wrong read size in ToColor_S4444_Opaque
- S4444 takes 16bits, not 32bits
- This caused sporadic failure in CTS BitmapFactoryTest#testDecodeStream4

Bug: 7179389
Change-Id: Ib36a3a569b3149d74f36ae67a069a7b65a72e895
2012-10-12 11:36:13 -07:00
Raph Levien
577b07197b Fix for 7281523 android.text.cts.SelectionTest#testMoveRight failures
The failures were caused by the implementation of doTextRunCursor
passing a too-small value for contextCount into the underlying
getTextRunAdvances call (it wasn't accounting for the start offset).
Thus, when getTextRunAdvances made a copy of the text for its cache key,
it was getting a partial copy.

This patch fixes the size so the cache key always has a full copy of the
text.

Change-Id: I57e3ac6de7aef0e1f1c7000dc3d653f9b0d623d2
2012-10-04 23:15:12 -07:00
Raph Levien
e174ae210e Fix for testPaintFlagsDrawFilter CTS test
This fixes bug 6948776
android.graphics.cts.PaintFlagsDrawFilterTest#testPaintFlagsDrawFilter
failures on JO

When we moved the drawing of text decorations (underline, strikethrough)
from Skia to our own drawing (so we could take into account the metrics
computed by TextLayoutEngine), we just used the raw flags from the
paint, which ignored the overrides that a DrawFilter can effect.

The patch simply checks for the existence of a DrawFilter in the canvas,
and applies it to a copy of the paint where present. This will be one
extra paint copy where the filter exists, but that's expected to be rare
(other than running this CTS test, of course).

Change-Id: I664c478b73a3a1cc43599ee11bbc02c69b7a96c2
2012-10-03 15:26:47 -07:00
Raph Levien
832815cb53 Fix for bug 7234184 F/TextLayoutCache: Failed to put an entry...
This bug was triggered by user code concurrently mutating the character
array while calling into a drawText method in another thread. When the
value of the array changed, it caused inconsistent state, leading to
assert failures.

This is arguably bad behavior by the user code, but it shouldn't cause a
native crash. The fix is to do a defensive copy of the text into the
key, so the value is guaranteed to remain constant throughout the text
layout process. The change is mostly deletion of code, because there was
an optimization to try to avoid such a copy. That optimization was not
actually effective, however, because the indexOfKey() operation in the
KeyedVector underlying the TextLayoutCache did the copy anyway. Thus,
even though this change looks like it's introducing a copy where there
wasn't one before, the actual performance impact should be nil.

Note that the ability to handle a mutating argument is now part of the
contract for TextLayoutEngine::getValue(), and is now documented. That
contract may change, as the result of future optimization. Also, care
was taken to only use the value after the copy.

Other performance issues with TextLayoutCache are tracked in bug
7271109.

Change-Id: I9c90e8e4d501f3f37e2f22a7851f032808d46fbe
2012-10-02 12:32:40 -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
Raph Levien
1b10241a8f Fix for bug 6936752 Tamil text gets truncated on right-hand side
The getTextRunAdvances() method wasn't accounting for the true width of
the text. On closer examination, in Tamil the clusters consist of a
number of glyphs each of which has a nonzero advance (in some other
scripts, the first glyph in the cluster has an advance, and others are
effectively zero). Previously, we were just using the advance of the
first glyph in the cluster. This patch changes the behavior to sum the
advances of all the glyphs within the cluster.

Change-Id: I77a51235f4bb0dfaa72cbb920a8c3b217ad25404
2012-09-24 16:14:38 -07:00
Raph Levien
005bfc694d Fix for native crash on image decode OOM
When decoding an image with scaling, if the allocation of the bitmap
data for the scaled bitmap failed, we were just ignoring it and going
on. This was yielding strange native crashes (bug 7196860 and bug
7175536). This patch checks whether the allocation succeeds, and returns
a null bitmap if not.

Of course, if the app really is OOM because it's allocated too many
bitmaps, it'll still get the OOME, but that's a lot nicer than a native
crash or memory corruption.

Change-Id: I8384059ab11c2ab9e93e283b9438d79e6709b7b1
2012-09-20 22:51:47 -07:00
Jamie Gennis
94998c9c4e Merge "SurfaceTexture: remove call to doGLFenceWait" into jb-mr1-dev 2012-09-18 14:32:01 -07:00
Jamie Gennis
917a3b34a3 SurfaceTexture: remove call to doGLFenceWait
This call is no longer needed as the default behavior of the native
SurfaceTexture class is to do the wait whenever updateTexImage is called.

Change-Id: I995686a5989409e21b00fac913bd33c11f806998
2012-09-17 19:00:19 -07:00
Raph Levien
c1eff0857e am e5905684: am eceb3171: am f4afc401: Merge "framework: fix bug for uninitialized variable"
* commit 'e590568417aa824e7b0e76ae727556d329cb57cf':
  framework: fix bug for uninitialized variable
2012-09-14 12:19:03 -07:00
Raph Levien
eceb317116 am f4afc401: Merge "framework: fix bug for uninitialized variable"
* commit 'f4afc40101c00800c4dc53f165b93f741327416d':
  framework: fix bug for uninitialized variable
2012-09-14 12:15:03 -07:00
Raph Levien
eb1f5349f8 Merge "Fix for b7155617 race condition in TextLayoutCache.cpp" into jb-mr1-dev 2012-09-12 15:44:58 -07:00
Raph Levien
13ba4e478d Fix for b7155617 race condition in TextLayoutCache.cpp
There was the possibility for a race between clearing the caches and
using fonts. This patch simply protects both under the same mLock held
by the TextLayoutCache object.

Change-Id: Ib366e16a9a9ba702a46bc078d1bc0602713991e5
2012-09-12 15:15:51 -07:00
Jamie Gennis
f09263e957 SurfaceTexture: add updateTexImage synchronization
This change makes the SurfaceTexture JNI updateTexImage call the native
SurfaceTexture's doGLFenceWait method to perform the needed synchronization.

Change-Id: Ie70a1fe6b44d439d1ffe7b97689a421ff8c02fda
2012-09-09 17:53:27 -07:00
Zhou Chang
46e942d500 framework: fix bug for uninitialized variable
Some application display error due to uninitialized varibale.
This patch fix the bug

Change-Id: I660169e325ffae60d95c7774aaaeaebf693adf3d
Author: Chang Zhou <chang.zhou@intel.com>
Signed-off-by: Chang Zhou <chang.zhou@intel.com>
Signed-off-by: Chong Xing <chong.xing@intel.com>
Signed-off-by: Hongyu Zhang <hongyu.zhang@intel.com>
Signed-off-by: Shuo Gao <shuo.gao@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
Signed-off-by: Jack Ren <jack.ren@intel.com>
Author-tracking-BZ: 45356
2012-08-31 10:53:04 +08:00
Jean-Baptiste Queru
38f197863a am 14c0c989: am 4ba4caed: Merge "Fix SkBitmap::fPixels not being locked correctly"
* commit '14c0c989d21531056a5d0a0739c3ffdd1b04b295':
  Fix SkBitmap::fPixels not being locked correctly
2012-08-29 12:00:10 -07:00
Jean-Baptiste Queru
14c0c989d2 am 4ba4caed: Merge "Fix SkBitmap::fPixels not being locked correctly"
* commit '4ba4caede125ff602b0d93f577f9054a07791ff7':
  Fix SkBitmap::fPixels not being locked correctly
2012-08-29 11:55:20 -07:00
Michal Stawinski
35ef567140 Fix SkBitmap::fPixels not being locked correctly
In some cases bitmap's pixels where freed during encoding, which
caused a null pointer dereference.
This fix makes sure that underlaying buffer is locked for the whole
process of compression.

Change-Id: I0ac56821f5d333072271dc2670fa30f1562adfa3
2012-08-29 15:54:01 +02:00
Billy Hewlett
ac1cbaf2e5 DO NOT MERGE Han Preference
Cherry-pick Ib5dd86950156c5a438f25c289acb839206bb455a from master.

Data: label MTLmr3m with "ja" locale attribute, fallback_fonts-ja.xml removed,
as we only need a single fallback font file
Code: Add locale and variant to TextLayoutCache.  Paint.java sets textLocale as
the language (for example, "ja") rather than the language/locale concatenated
(for example "ja_JP")

This checkin, along with Change-Id: Id8c91ae0be6cad8a7ef77a0cd5803676290986c1,
allows text view objects to set their locale dynamically and skia will use the
correct font for the locale.

Change-Id: Ieb60b0d7a39fcfef4f8ce90cd4f6065d33673710
2012-08-20 08:51:23 -07:00
Romain Guy
42e1e0d482 Improve gradients
Avoid using textures for common gradients (two stops from 0.0 to 1.0)

Change-Id: Iff55d21b126c8cfc4cfb701669f2339c8f6b131a
2012-07-31 18:55:16 -07:00
Romain Guy
a0aa479c0e am 97e27072: am dfac68ea: Merge "Corrected typo when checking InputStream methods"
* commit '97e270721bf29d25b513c1f2be71a8543d048f5d':
  Corrected typo when checking InputStream methods
2012-07-27 15:54:30 -07:00
Romain Guy
97e270721b am dfac68ea: Merge "Corrected typo when checking InputStream methods"
* commit 'dfac68eacc60c130e54345d98bd45c99573cb627':
  Corrected typo when checking InputStream methods
2012-07-27 15:49:23 -07:00
Edward Savage-Jones
8ac41bb79e Corrected typo when checking InputStream methods
Corrected a small typo where Java InputStream methods are
incorrectly checked when creating a JNI InputStream adaptor.

Change-Id: I5f14897e0d5ddceb4b2af6be46769713f0487624
2012-07-27 15:14:24 +02:00
Raph Levien
161ebab85d Increase text layout cache size in bytes
The mark positioning changes increase the number of bytes needed per
glyph from 6 to 14. This patch compensates by allocating more total
memory for the text layout cache.

Change-Id: I3cf59547394a41779cf6e92e67688b0fdc85f1a3
2012-07-18 16:16:41 -07:00
Raph Levien
4f3c8f7026 Fix overly verbose logging in TextLayoutCache
I meant to log certain debug values only when DEBUG_GLYPHS was set, but
I used #ifdef instead of #if (when it's not set, it's 0, rather than
undefined).

Change-Id: Ic27fee7dd355009c1873f0a2e12614849bbceebd
2012-07-18 15:40:44 -07:00
Raph Levien
2301d32f7e Software-only implementation of glyph positioning (bug 5443796)
This patch implements glyph positioning in the Skia-based renderer. Note
that it depends on a fix for bug 6833339 being in place (correct
calculation of advance widths under skew and scale transforms),
otherwise there will be regressions.

Careful attention was paid to correct results in a wide variety of
conditions: alignments, text decorations, scale, skew, etc. Many of
these are exercised in the test app attached to bug 6833339.

Note that this patch also changes slightly the way that the total
advance is calculated - the running is accumulated and passed through to
computeRunValues(), so that the x positions of each glyph can be set
according to the total advance of all glyphs (in all runs) appearing
before (plus, of course, the offset for mark positioning).

After committing this patch, text rendering will no longer match between
the software and hardware rendering cases. Implementing positioning in
the hardware renderer will resolve that, and fully implement bug 5443796.

Change-Id: Ie0f7835d48bc120475a19afbfe159aa5304fcaa8
2012-07-17 18:11:28 -07:00
Victoria Lease
cae28fa051 Merge "Remove hardcoded typeface pointers" 2012-07-11 12:49:12 -07:00
Billy Hewlett
d6deccb346 Remove hardcoded typeface pointers
There were a number of extraneous typeface pointers, one per
language, in TextLayoutCache.  Removing these makes adding additional
supported fonts easier.  This checkin now properly
unrefs typefaces returned by SkCreateTypefaceForScript.  Additionally,
all harfbuzz shaped fonts (with exceptions Greek, Cyrillic, Hangul)
should call SkCreateTypefaceForScript.

Change-Id: I7dcf603a89e5ff52c6dab8fb87ae1807a79c351c
2012-07-11 08:55:59 -07:00
Romain Guy
907524851a Properly resize paletted bitmaps when adjusting for density
If an app used a GIF file in the wrong density bucket, the auto-scaling
code would not properly resize the bitmap.

This issue affects third party applications, here is the external bug
report:

http://code.google.com/p/android/issues/detail?id=34619

DO NOT MERGE

Change-Id: I7f99b28ad6e6c28bdbcb29bbbadcb215268ff710
2012-07-10 13:16:46 -07:00
Romain Guy
053a82cc18 Properly resize paletted bitmaps when adjusting for density
If an app used a GIF file in the wrong density bucket, the auto-scaling
code would not properly resize the bitmap.

Change-Id: I28f6506a94b20d11b3ba53ac442abec2b92e093e
2012-07-10 12:02:33 -07:00
Raph Levien
f62034d896 Initialize shaper offset array. Needed for bug 5443796.
Harfbuzz apparently requires the offset array to be initialized to zero,
otherwise it can report corrupt glyph positions. This change also
contains a small amount of refactoring to avoid code duplication.

Change-Id: I2553974f40bc8e0549876c7d31243960ca92a8a2
2012-06-26 08:59:17 -07:00
Raph Levien
6212a4f2ed Fix broken build when DEBUG_GLYPHS is set
Some of the logging lines referred to the "path" variable which no
longer exists. We log the Harfbuzz script instead, which hopefully
provides enough context.

This change only affects debug builds, but we will want to be working
intensively in this space.

Change-Id: I86c3b58c9fa2a8c47812ef5f0b5ce64fd8dcdc20
2012-06-25 14:29:52 -07:00
Billy Hewlett
960511848a Revert "Revert "Use Elegant fonts for Webkit, Compact fonts for Textview""
This reverts commit 6fadccd2484233ed570218b3f97c085ef1a1ec28
2012-06-21 09:58:42 -07:00
Billy Hewlett
6fadccd248 Revert "Use Elegant fonts for Webkit, Compact fonts for Textview"
This reverts commit ecf80965d05e44b3701b3392aeb02028daacf1b0
2012-06-21 09:45:30 -07:00
Billy Hewlett
ecf80965d0 Use Elegant fonts for Webkit, Compact fonts for Textview
Fonts can be marked with elegant or compact in fallback_fonts.xml.
Webkit uses elegant fonts, Textview uses compact fonts (the default),
unmarked fonts are used by both.

    Bug: 6649136

Change-Id: Ie0debcddc13350bf60fe3139cd7ae533e466f02b
2012-06-20 09:07:09 -07:00
Victoria Lease
29b9885c25 Merge "Fix hardcoded font path. Allow adding new font path thru Skia changes. Bug: 6609231" 2012-06-07 08:33:15 -07:00
Billy Hewlett
517f67fe4b Fix hardcoded font path. Allow adding new font path thru Skia changes.
Bug: 6609231

Change-Id: I7b28c6f7ac1c227c7059b486635cadb39a6eacc3
2012-06-04 17:15:46 -07:00
Raph Levien
75394d6d1b Fix bug 6558006: SystemUI native heap is huge. Fix memory leak
TextLayoutCache was leaking HB_Face objects, not freeing them when
purging the mCachedHBFaces cache. More full analysis is in the bug.

Change-Id: Ie5cd8b00c36b9d31963183c601cde49cbb73fafb
2012-06-02 15:47:29 -07:00
Owen Lin
f970c2e6de Nvidia's patch for reusing bitmap in image region decoding.
bug: 5884845
Change-Id: I43d4d86ee94591b0b53393dfba13c7cc5c4e428d
2012-05-17 12:48:02 -07:00
Fabrice Di Meglio
15cc68ced0 Fix bug #6495019 Character gets garbled when locale is changed
- add missing cached data clearing. The Shaper was caching the HB_Face so
clear them too
- do minor code refactoring

Change-Id: Ifa86cc63815bdb4b51ce688cf16e986415b1e8c1
2012-05-15 14:55:49 -07:00
Jeff Brown
8bd8d89693 Merge "Fix possible leak in bitmap decoding." into jb-dev 2012-05-09 17:42:40 -07:00
Jeff Brown
27d8383414 Fix possible leak in bitmap decoding.
In one particular error case, we might exit the function without
destroying the bitmap.

Bug: 6467873 (tangentially related)
Change-Id: I3a213cc0a53023d9d0d2a080aed15774f4c4c10c
2012-05-09 17:30:31 -07:00
Fabrice Di Meglio
92d7f9ff1c Merge "Fix bug #6408393 Character corruption is caused when locale is changed" into jb-dev 2012-05-08 10:54:41 -07:00