815 Commits

Author SHA1 Message Date
Raph Levien
772d576b97 Merge "New weight-aware font config" into lmp-dev 2014-08-27 16:24:37 +00:00
Raph Levien
2a5fab9d47 Merge "Fix incorrect return value on missing glyph" into lmp-dev 2014-08-27 16:24:14 +00:00
Raph Levien
531dab6d3a Fix incorrect return value on missing glyph
The GetGlyph function returns a boolean indicating whether the glyph
exists in the font. However, we were testing the pointer, so the test
would always succeed even if the glyph was missing. This interfered with
fallback algorithms for rendering compatibility characters.

Bug: 15816880
Bug: 16856221
Change-Id: I95cd45bb8f5e8ddf74cf23e6e624fbf30172e00a
2014-08-26 22:19:29 -07:00
Raph Levien
117cbebe81 New weight-aware font config
Parse new fonts.xml config file, and resolve weight selection based on
the base weight of the font (as defined by a weight alias specified in
the config file) and the requested bold flag. This change improves the
appearance of bold spans for alternate weights of Roboto.

In addition, this patch enables weight selection for fallback fonts.
For example, if an additional font with a weight of 100 is added to the
Hebrew font family in the fallback list, then requesting
"sans-serif-thin" would select that font for Hebrew text.

Bug: 14538154
Change-Id: I99a04fad4f7bf01c75726e760d42735dd9003496
2014-08-26 19:37:45 -07:00
John Reck
1698297daf Merge "DO NOT MERGE Copy shaders" into lmp-dev 2014-08-26 14:53:34 +00:00
John Reck
c1469f39b5 DO NOT MERGE Copy shaders
Bug: 16733996

Change-Id: I84afc1b24a23dd6ddf5ab48fb2bfcbe779f8d3e3
2014-08-25 15:27:11 -07:00
Raph Levien
908040534d Preserve paint parameters in Paint copy constructor
The copy constructor for Paint was setting default values for additional
parameters, rather than copying them from the original object, resulting
in incorrect locale in the software text drawing path.

Fix for bug 17149910 "Chinese font is used on IME even if the system
language is Japanese"

Change-Id: I25f377ce4e0ea66946a27ea46a2db524872ae36f
2014-08-25 09:36:29 -07:00
John Reck
01edef10b9 Revert immutable Shader change
Bug: 16733996

Change-Id: I51686aaf8f6ae8d0e390e298ad70f98f81c5f555
2014-08-22 11:15:37 -07:00
Chris Craik
bd8db2e87e Add bounds checking to nine patch scaling
bug:17114103

Better handle the case, when scaling the divs in a nine patch, where
divs fall outside of the bounds of the bitmap.

Change-Id: I244b9c45b938c2a15f29e4563a86825ee9439b5f
2014-08-20 16:37:16 -07:00
Derek Sollenberger
6f03023ece Remove dependency on SkPaintOptionsAndroid
Change-Id: I579a3503697efe3b8fd9bc809a6c9bfbf735cb1b
2014-08-07 14:38:51 -04:00
Behdad Esfahbod
e9ad3931fa Add fontFeatureSettings to TextView and attrs
New API is hidden.

Bug: 15246510
Change-Id: I8cdbbd3a36fc280e07569dbb130f8c237062fff5
2014-08-01 21:35:05 +00:00
Chris Craik
8e554924c5 Merge "Add outline alpha" into lmp-dev 2014-07-31 21:44:36 +00:00
Chris Craik
77b5cad3ef Add outline alpha
bug:16140822
bug:16566746

This allows background drawables to alter the opacity of a shadow
being cast with their own alpha values.

Change-Id: I49698cc7c1bf4b2b55ffe2f82899543ca62bc61c
2014-07-31 12:29:57 -07:00
Behdad Esfahbod
805f6ebf17 Support FontFeatureSettings in Paint
New API is hidden.

Bug: 15246510
Change-Id: Idefca06a366de0d87f53d123b5291788448de4d0
2014-07-30 21:38:23 +00:00
Raph Levien
ed1e6962ba Merge "Bump refcount of canvas created for Picture" into lmp-dev 2014-07-30 20:38:44 +00:00
Raph Levien
febccd05f2 Bump refcount of canvas created for Picture
Both the Canvas and Picture objects will unref the canvas in their
finalizers, so an extra ref is needed. This had been present but was
inadvertently removed in the patch "Refactor android.graphics.Picture
JNI bindings." This patch simply restores the previous ref and comment.

Bug: 16399257
Change-Id: I9911826bd0e668bd25546ef54b0c9c1d467538c8
2014-07-30 13:41:10 -07:00
Behdad Esfahbod
fa80f7491d Add letter-spacing to Paint and TextView
New API is hidden.

Bug: 15594400
Change-Id: I5cbe7aebef0b7280eb13924f2a706c0cb4a4688e
2014-07-24 18:46:07 -04:00
Derek Sollenberger
c41d941f1b Disable fallback chaining in Skia.
Change-Id: I6e57b525bc4953a5b8969bb4c3e71b4a53de33d3
2014-07-30 14:40:00 -04:00
Behdad Esfahbod
e21e2a2d1d Clean up Minikin includes
Include headers where they are used.  Add header guards to MinikinSkia.h

Change-Id: If341231625348290d28a7d625561fffc171a8407
2014-07-30 14:58:40 +00:00
Behdad Esfahbod
5ec789608b Use new minikin Layout::doLayout() that doesn't use a CSS string
The CSS version will be removed in minikin soon.

Bug: 16651112
Change-Id: Icebcbde6869e64399f160e1773e843cdd0199bc8
2014-07-29 14:32:57 -04:00
Behdad Esfahbod
c437f6eef2 Merge "Further centralize Minikin interaction" into lmp-dev 2014-07-24 15:37:54 +00:00
Behdad Esfahbod
63c5c78a72 Further centralize Minikin interaction
Part of the fix for bug 15246510 and others.

Change-Id: Ie99000989dfcd7a81aaa1233dec522344f852f31
2014-07-25 19:23:49 +00:00
Behdad Esfahbod
1fc68395d3 Remove unused TextLayout.h
Respective code was removed when switching to Minikin.

Change-Id: I353c834457145ccd9462a439dfdf16d4adb8b695
2014-07-25 14:06:35 -04:00
Derek Sollenberger
cae05e0b4c Move Canvas.h to a new location so that it can be shared with HWUI.
Bug: 15672762
Change-Id: Ia59e986cd4034e16b2e54e8d594e6941a6c9fb1b
2014-07-25 11:39:37 -04:00
Derek Sollenberger
acb4099def Refactor text drawing to move minikin interactions outside of the canvas interface.
bug:15672762
Change-Id: Iad63855424b4eeccef67a7341a9c2b0018c64c30
2014-07-24 09:46:58 -04:00
Leon Scroggins III
866cf65cc3 Make updateLocalMatrix replace the current Matrix.
Fixes a bug introduced in I3c3316377874e89fccc85afb864bc038b0ef3890.

CreateLocalMatrixShader combines the existing matrix with the new
matrix, which is not what we want. Keep track of the original
SkShader at all times, and always create the local matrix shader
with the original. Store the SkShader with a local matrix as
Shader.native_with_local_matrix.

Make Shader.native_instance private. Instead of allowing direct
access, add an init() method which sets it, and getNativeInstance(),
which returns either native_instance or native_with_local_matrix,
as appropriate.

Make Shader subclasses call init(), instead of setting native_instance
directly.

Pass native_with_local_matrix pointer to nativeSetLocalMatrix and
nativeDestructor, which unrefs it (if not null).

Since nativeSetLocalMatrix no longer replaces the original, do not
unref it.

Add a comment to Shader.updateLocalMatrix that it does not affect
ComposeShaders created with this Shader. (This should have been a
part of I3c3316377874e89fccc85afb864bc038b0ef3890.)

BUG:16293121
Change-Id: Ieb31c7e1fe99081f6b81493178f4a18d3c5df643
2014-07-24 09:30:23 -04:00
Chris Craik
f23f5de173 Merge "[Bitmap] Add null pointer protection in Bitmap_sameAs()" into lmp-dev 2014-07-22 16:21:19 +00:00
henry.uh_chen
53001ca3a6 [Bitmap] Add null pointer protection in Bitmap_sameAs()
Symptom: SkBitmap::getAddr(int, int) may return NULL due to unrecognized config
(ex: kRLE_Index8_Config). This will cause memcmp method to crash. Since bm0 and
bm1 both have pixel data() (have passed NULL == getPixels() check), those 2
bitmaps should be valid (only unrecognized), we return JNI_FALSE to warn user
those 2 unrecognized config bitmaps may be different.

Cherry-pick of 3a1bffa835f279628e50385af3c85789bc737f64 from AOSP

Change-Id: I6970c27de412110a3035d0a783112c4cd3ebc35b
2014-07-22 13:46:17 -07:00
Behdad Esfahbod
6ba30b85dd Add android.Paint that inherits SkPaint
The idea is that extra paint parameters that only affect text layout
(not rendering) will go in android.Paint instead of going into
SkPaintOptionsAndroid.  We will eventually move those out of SkPaint
too.

This is currently implemented in PaintImpl.cpp.  Will be renamed when
current Paint.cpp that has JNI bits is moved to android_graphics_Paint.cpp.

Change-Id: Iba66c34dea5da503a13b9c864cb9f2211ac4ba7d
2014-07-22 14:01:09 -04:00
Derek Sollenberger
2cb8c3c9e5 Remove invalid SkASSERT that prevents us from running with SK_DEBUG
Change-Id: I5634990e6cb962d72b686f7f103b9af7d96d4b55
2014-07-21 12:46:33 -04:00
Derek Sollenberger
8872b38ef4 Separate Canvas JNI code from the implementation.
This introduces Canvas.h which is a pure virtual interface that
is intended to be used by both Skia and HWUI implementation. To help
stage this transition this CL only introduces the interface and Skia
implementation.  The interface is not intended to be final and will
undoubtedly go through iterations in both style and location as we
look to introduce the HWUI implementation.

BUG:15672762
Change-Id: Ibaccdddb87d3b9358f4f0c1d317ead5282d4ee16
2014-07-21 12:08:57 -04:00
John Reck
580ff8142b Revert "Separate Canvas JNI code from the implementation."
This reverts commit e28a5afee885cd69a5be5809f88116b601cb1a72.

 Appears to cause memory corruption and random appearances of
 chinese

 Bug: 16343240
 Bug: 16336642

Change-Id: Ife169181f40adff4b12948ed5f9d3a88dcec935b
2014-07-17 17:36:24 +00:00
Derek Sollenberger
f5d6c555c3 Separate Canvas JNI code from the implementation. DO NOT MERGE
This introduces Canvas.h which is a pure virtual interface that
is intended to be used by both Skia and HWUI implementation. To help
stage this transition this CL only introduces the interface and Skia
implementation.  The interface is not intended to be final and will
undoubtedly go through iterations in both style and location as we
look to introduce the HWUI implementation.

BUG:15672762
Change-Id: Idefadede356f688edb8eb09b4a02aa01b4077f62
2014-07-15 15:08:29 +00:00
Chris Craik
47cd8e921d Implement outline support for nine patches
b/15856895

Nine patches now have outline round rect metadata stored as optional
png tags. aapt generates these automatically by inspecting the bitmap
pixels to estimate outline bounds and round rect radius, based on
opacity.

Change-Id: I226e328a97873010d9e1adb797ac48f93a31183c
2014-07-14 15:01:27 -07:00
Leon Scroggins III
ab87983a11 Simplify Shader.setLocalMatrix.
Previously, calling setLocalMatrix updated any Paint that had the
Shader attached. This depended on deprecated behavior in Skia. Use
new Skia APIs, and do not modify any Paints that use the Shader.

In addition, update callers to call setShader (again) after modifying
the Shader.

Sample app at ag/499573 for testing.

Depends on I673801444f0a8fd4f192b5b7effdde1aa83e702b in external/skia.

BUG:14315916
Change-Id: I3c3316377874e89fccc85afb864bc038b0ef3890
2014-07-10 18:01:22 -04:00
Svet Ganov
525a66b2bb Adding print preview.
This change adds the pring preview part of the new print UX. The
UI has two parts, the top section is the print options and the
bottom section print preview with a list of pages. The user can
interact only with one of them. When print options are expanded
they cover the preview content and a scrim is laid out on top of
the preview. Tapping the scrim collapses the print options. When
the user types in page ranges and closes the options to look at
the preview, the latter is updated to show only these pages. In
the list of pages the user can further prune pages by deselecting
them.

Change-Id: I0b23d2c598afe2a34400ccfa43e4e935af83c72f
2014-07-09 18:43:38 +00:00
Mike Reed
1103b32559 SkBitmap::Config is deprecated, use SkColorType
Change-Id: Ic953741325607bf85598c097bb3ab648d4a08996
2014-07-08 15:05:38 -04:00
Mike Reed
42a1d08df7 SkBitmap::Config is deprecated, use SkColorType
Change-Id: Ida181d2aac760072cf2d01409edac37699dea216
2014-07-07 18:11:24 -04:00
Mike Reed
4a9c3891d4 kNative_8888_SkColorType is now kN32_SkColorType
Change-Id: I13421a21de611203c62c1c1c36570a8cc803907b
2014-07-07 15:47:55 -04:00
Alan Viverette
c054966b71 Make optical insets actually work
Change-Id: I9fabf4cb939cc7a868f95580e7229745acde0418
2014-07-04 01:10:38 +00:00
Raph Levien
27bb05f2dc Fix native crash when typeface is missing
Creating a typeface from a missing file crashes when it tries to extract
the style from the font. This patch just uses default style when the
resulting font object is NULL.

Bug: 15930808
Change-Id: I9438687100026f336db7aa204fe3a0232eee2db6
2014-07-02 15:07:39 -07:00
Leon Scroggins III
57ee620ced Read premultiplied status from the SkBitmap.
Replace the Java variable with mRequestPremultiplied, to better
reflect what it represents. In both native and Java, the SkBitmap
is used as the decision maker of whether a Bitmap is premultiplied.
When changing other settings, mRequestedPremultiplied is used to
determine whether it should be premultiplied (if the new config/
hasAlpha-ness etc supports it).

ChooseFromColorProc now reads both the colortype (instead of the
deprecated Config) and alphatype on the SkBitmap. Same with
ChooseToColorProc. In the process, this caught a bug, where the
wrong procs were being used for Index8.

Replace instances of SkBitmap::Config with SkColorType where I
was already changing code.

Use the new versions of setConfig/allocPixels that take an SkImageInfo
as a parameter.

Document isPremultiplied's return value for ALPHA_8.

BUG:13618134
Change-Id: I91fc1f1e46e9294364b1af0ab4bdb37c68d7058e
2014-07-01 14:05:37 -04:00
Dan Stoza
493f2e1190 SurfaceTexture: Allow creation in detached mode
Adds a constructor that doesn't require a GLES texture name and sets
up the SurfaceTexture in detached mode.

Bug: 15616428
Change-Id: I375495f481bfbe43b3830ab7d124cef8f1be0ac6
2014-06-26 13:36:19 -07:00
Raph Levien
3d528c403c Fix build breakage
Other files were including GraphicsJNI.h and didn't have Minikin in the
include path. This patch eliminates the offending include.

Change-Id: I05c9dbf80b93f1731fd0192015e2c9c68a9dd3c6
2014-06-26 09:06:21 -07:00
Raph Levien
3660789f06 Switch all text layout to Minikin
This patch switches all text layout operations to use Minikin, removes
the USE_MINIKIN #ifdef, and deletes some of the code that was only used
in the old TextLayout path (although some more refactoring remains).

Change-Id: I51b5c4e2bb46cfd9d204c12b9f16f135c769f5b5
2014-06-26 08:23:48 -07:00
Raph Levien
d194262f53 Delete Paint.getTextGlyphs()
The Paint.getTextGlyphs() method was used for testing the old Arabic
shaper and is entirely obsolete. Note that this is the very last
dependency (other than some enums in the header) for the old TextLayout
code path.

Change-Id: I7b596f0c0942ed50987fc8e0478cd93e667f1f9e
2014-06-26 15:15:28 +00:00
Raph Levien
3744a64a8a Use Minikin's purgeCaches
In USE_MINIKIN builds, purge the Minikin caches rather than the
TextLayout caches.

Change-Id: Id6bf9db38488ed5023a61feab88004511393644c
2014-06-26 15:14:31 +00:00
Mike Reed
b933055cf3 stop using (deprecated) SkBitmap::Config
Change-Id: Ic75b5fc6996578e9d95bd3a220439ec1541d7c3b
2014-06-20 10:28:37 -04:00
Raph Levien
e368b6bcfd Use Minikin grapheme cluster breaking
This patch uses the Minikin implementation of grapheme cluster breaking,
which improves the behavior of left and right arrow keys for moving the
cursor. Among other things, it fixes the behavior of jumping over the
"fi" ligature in Roboto.

Part of a fix for b/15653110 Improve behavior of arrow keys in EditText

Change-Id: I80ca54c973d85c49f23b81d51a0fe07a7a853d81
2014-06-19 11:51:54 -07:00
Raph Levien
3f0d616722 Simple implementation of drawPosText
The existing implementation of drawPosText is broken in various subtle
ways, in any case doesn't work with Minikin. This patch just implements
it by drawing a separate run for each Unicode character, which should
have the least surprising results for complex scripts such as Khmer.

Part of b/11750374 Resolve TODO items for Minikin

Change-Id: I874ae3c163f0cbe3cdf0160564fab04305aed5aa
2014-06-19 11:22:45 -07:00