799 Commits

Author SHA1 Message Date
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
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
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
Derek Sollenberger
a0dc404092 Fix namespace for picture
Change-Id: Id21ebcf2ba4befb4af15cd1d493428a64599afc1
2014-06-18 15:17:50 -04:00
Raph Levien
c802c8cda2 Merge "Implement drawTextOnPath with Minikin" 2014-06-17 21:46:58 +00:00
Raph Levien
9d2b5e1930 Implement drawTextOnPath with Minikin
This patch contains an implementation of drawTextOnPath for both
software and hardware Canvas using Minikin for text layout. One of the
steps for switching all remaining text operations to Minikin so the old
TextLayout and Skia fallback fonts mechanisms can be deleted.

Bug: 11750374 Resolve TODO items for Minikin
Change-Id: I06bfe74a101fa1dcdfc38f530f7194d71e522a85
2014-06-18 11:04:24 -07:00
Derek Sollenberger
bc8bd76bc7 Merge "Refactor android.graphics.Picture JNI bindings." 2014-06-17 21:13:21 +00:00
Antonio Calabrese
2460958133 Added primitive parameters to various functions requiring rectangles.
Change-Id: I5a2678fa989f0ff34404b8236787a8153b05f113

bug:14322352
2014-06-17 20:17:59 +00:00
Derek Sollenberger
4b0959d8db Refactor android.graphics.Picture JNI bindings.
This is the first CL in a series of CLs to refactor the Graphics JNI bindings.

bug: 15672762
Change-Id: I1455fa1330c7426407c06eeaad81ad37a57373b1
2014-06-17 15:31:43 -04:00
Anish Athalye
a7aa1b0aa5 Implement Paint.breakText() using Minikin
Change-Id: I36cee2d840ce1bd24a9a06f0c680880396b7398a
2014-06-17 00:31:19 +00:00
Raph Levien
051910b9f9 Clean up dirFlags / bidiFlags confusion
The dirFlags and bidiFlags enums are distinct, and have different
meanings. The former is a determined direction for a run of text, while
the latter is a request for the bidi algorithm. They have been used
interchangeably, and this has caused some problems, notably running the
bidi algorithm needlessly when the direction for a run is already
determined.

This patch cleans up the confusion, by always naming each occurrence
explicitly "boolean isRtl" or "int bidiFlags" (the previous code often
just used "int flags", which added to the confusion), and converts
between the meanings when a function takes an isRtl argument but passes
it to another function expecting bidiFlags.

Fixes b/15089607 Clean up bidi flag mess

Change-Id: I410b6604376e853dd12c255e7f5a9d2b9a310dd9
2014-06-16 14:36:08 -07:00
Florin Malita
cf6edd2b22 Merge "Pass full matrix + clip save flags to the native SkCanvas." 2014-06-10 21:32:31 +00:00
Leon Scroggins III
17a8bfc38a In Bitmap.reconfigure, update the pixelref's info.
This fixes CTS tests which are crashing on an SkASSERT due to a
mismatch of SkImageInfo between the SkPixelRef and SkBitmap.

Also directly call ref() and unref() instead of SkSafeRef/SkSafeUnref,
since we would already crash if the SkPixelRef in question was NULL.

Also if the user attempts to reconfigure to 4444, use 8888 instead.

Change-Id: I473ef225c6cd1c92d67ae103c53c6cff0dad92de
2014-06-11 18:53:42 -04:00
Robert Phillips
b59508fce5 Changes to framework for ToT Skia.
Consists of 3 cherry-pick from changes by robertphillips@google.com
in master-skia:

-----------------------------------------------------------------------

New AndroidPicture wrapper class

Address code review comments & use new SkPictureRecorder::partialReplay
entry point

Addressing code review issues

Switch MakePartialCopy to makePartialCopy

Conflicts:
	core/jni/android/graphics/Picture.cpp

Ie530ab15b3d549f0ecfb0ecc131f9144a7b72a91

Remove AndroidPicture from GraphicsJNI and split into .h and .cpp

-----------------------------------------------------------------------

Fix lingering legacy picture recording behavior
Address code review issues

Iaf870c2c400dbe70dc32d6d445574904f5ea718f

-----------------------------------------------------------------------

Update Android to new SkCanvas::drawPicture interface

As of Skia 9b14f26d (Alter SkCanvas::drawPicture (devirtualize,
take const SkPicture, take pointer) -
https://codereview.chromium.org/313613004) SkCanvas::drawPicture
has an alternate signature. The old entry point is deprecated.

I63395da61ecc3b58bfd2bc094752081f4b2f7535

-----------------------------------------------------------------------

Change-Id: I041133aeb5639abd853370e512acf93870f82aea
2014-06-11 18:27:48 -04:00
Florin Malita
b85056018b Pass full matrix + clip save flags to the native SkCanvas.
With granular state flags being deprecated, always pass full
save flags to the native canvas.

Legacy behavior is emulated in NativeCanvasWrapper, with a focus
on minimizing the overhead when there are no side effects to be
persisted.

Change-Id: Ifdad2ff9bb3a1f9736c6c41afc9ec6c07f62320e
2014-06-10 16:55:00 -04:00
Raph Levien
0627ec08dc Support fake italics
This patch adds fake italics, using essentially the same mechanism as
the fake bold implementation. Also combines fake bold/italic settings
with ones explicitly set in the paint.

Change-Id: Ia7eb3ddc8a6192d191711ba723ffd0d1d9d93f2e
2014-06-10 11:49:44 -07:00
Raph Levien
1fc0fa87d4 Support for fake bold in Minikin builds
Part of the fix for bug 15436379 Fake bold doesn't fully work (Minikin)

This patch queries the Minikin layout for when fake bold is needed,
and applies that to both shaping and drawing paint.

Also simplifies refcounting (the lifetime of all MinikinFont objects
is subsumed by the enclosing FontCollection).

Note: the fake bold flag set by the user is ignored in this patch.

Fake italics would be possible using the same mechanism, but it's
slightly more complicated (fake and user-set textSkewX values would need
to be combined, and the latter restored after drawing).

Change-Id: Ica2c4604846cbb37e5a783778b18d8993c9d4563
2014-06-10 11:37:55 -07:00
Raph Levien
71f75f1e7b Merge "Fix getFontMetrics problems" 2014-06-06 17:10:32 +00:00
Raph Levien
817ef4ae79 Fix getFontMetrics problems
Fixes a number of individual problems. In Minikin builds, gets base font
from TypefaceImpl rather than using whatever random font was in the
paint. Respects elegant metrics in ascent and descent methods as well as
getFontMetrics. Sets fixed ascent and descent values to 1900, -500,
which matches the Roboto font.

Part of the fix for bug 15467288 "Inconsistent line heights on
Minikin builds"

Change-Id: I12915f4a62de28932469c7279241eecf7320c47b
2014-06-06 10:06:01 -07:00