Commit Graph

209 Commits

Author SHA1 Message Date
John Reck
9e91be3541 Fix Nullability annotation
The initial commit of the @Nullable annotation appears
to have been based off of the javadocs. However, the actual
code does not appear to have allowed for null at that time.

It's not entirely clear if null was ever allowed, but it
hasn't been allowed since API 14 at least

Test: make
Fixes: 195924626
Change-Id: Ibffdc7b90cbfc3bc65a4a08bee52e2e3412bed3e
2021-08-13 22:42:44 +00:00
John Reck
a00eef21de Remove SaveFlags from saveLayer(Alpha)
This has been hardcoded as ALL_SAVE_FLAGS for a couple releases now.

Since it's now permanent behavior, remove the last bit of plumbing
for SaveFlags on saveLayer

Test: builds & boots
Change-Id: Iec92f27199d0b4781c2293dcdcfd45a1562a1b4e
2020-11-16 18:26:08 -05:00
Mathew Inwood
8e742f928e Add maxTargetSdk restriction to unused APIs.
These are APIs that have @UnsupportedAppUsage but for which we don't
have any evidence of them currently being used, so should be safe to
remove from the unsupported list.

This is a resubmit of ag/12929664 with some APIs excluded that caused
test failures; see bugs 171886397, 171888296, 171864568.

APIs excluded:
Landroid/bluetooth/le/ScanRecord;->parseFromBytes([B)Landroid/bluetooth/le/ScanRecord;
Landroid/os/Process;->myPpid()I
Landroid/os/SharedMemory;->getFd()I
Landroid/hardware/input/InputManager;->INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH:I

Bug: 170729553
Test: Treehugger
Change-Id: I8285daa8530260251ecad6f3f38f98e263629ca7
2020-10-29 11:51:12 +00:00
Hongwei Wang
050275cd83 Revert "Add maxTargetSdk restriction to unused APIs."
This reverts commit 72f07d6a8a.

Reason for revert: Droidcop-triggered revert due to breakage https://android-build.googleplex.com/builds/quarterdeck?testMethod=testAppZygotePreload&testClass=android.app.cts.ServiceTest&atpConfigName=suite%2Ftest-mapping-presubmit-retry_cloud-tf&testModule=CtsAppTestCases&fkbb=6936597&lkbb=6936969&lkgb=6936551&testResults=true&branch=git_master&target=cf_x86_phone-userdebug>, bug b/171886397

Bug: 171886397
Change-Id: Ibe0f0430a3451477c1ee8ef56a596e91ea1e7672
2020-10-28 20:16:22 +00:00
Mathew Inwood
72f07d6a8a Add maxTargetSdk restriction to unused APIs.
These are APIs that have @UnsupportedAppUsage but for which we don't
have any evidence of them currently being used, so should be safe to
remove from the unsupported list.

Bug: 170729553
Test: Treehugger
Change-Id: I4c8fd0006f950de9955242e93968fb0996ceb372
2020-10-27 15:46:07 +00:00
Seigo Nonaka
c489d627c9 Update TextShaper APIs to address API council feedback
This CL contains followings:
- Rename TextShaper to TextRunShaper, StyledTextShaper to TextShaper
- Renamed getTotalAdvance to getAdvance
- Rename getStyle to getGlyphStyle
- Rename getOriginX/Y to getOffsetX/Y
- Rename getPositionX/Y to getGlyphX/Y
- Fixed some documentation errors.
- Remvoed GlyphStyle. Added GlyphConsumer instead.

Bug: 170255480
Test: atest TextShaperRunTest GlyphStyleTest TextShaperTest

Change-Id: I0ffd7a3374e9cd1e04872240c2d0da26bc530244
2020-10-14 21:12:36 -07:00
Seigo Nonaka
39c482f21f Add Canvas#drawGlyphs
Bug: 168048923
Test: atest CanvasDrawGlyphsTest
Change-Id: I013335fa82883146044ea03fbbe67e1e26a35f6d
2020-10-02 23:09:45 -07:00
Leon Scroggins III
3b8b654519 Remove @hide from Matrix
Bug: 152983829
Test: make
Test: I77ec845b5503df6f90deb6a2176836d9aacb74d1

Make IDENTITY_MATRIX a public API. It had @UnsupportedAppUsage, and it
is a useful thing to have.

Replace printShortString with dump, to match Point#dump (added in
I5e25dbbe47b3c690d7d763a0082beb8d8a9c86d3) and others. Make this public
as well.

Remove @UnsupportedAppUsage from native_instance, which appears to be a
false positive (no usage found on the dashboard). Also make it private,
forcing other classes to call ni().

Document why ni() needs to be @hide (usage by classes outside the
package but inside the module). Also add a FIXME that PdfRenderer should
*not* be calling it, since we plan for it to be outside the module.

Make toShortString(StringBuilder) private. Switch its only external
client to the public version. (While I see a few public
"toShortString()" methods in the public API, I do not see any that take
a StringBuilder parameter.)

Fix a typo.

Change-Id: I356fb6729764f1777830fc3a91216e869bf6de16
2020-05-18 13:56:09 -04:00
Leon Scroggins
d50178eae6 Merge "Switch Java calls to enableZ and disableZ; remove isRecordingFor" 2020-05-07 18:07:22 +00:00
Leon Scroggins
f0cee43934 Merge "Make Canvas#drawPatch public" 2020-05-06 20:33:55 +00:00
Leon Scroggins III
0f53e10c07 Switch Java calls to enableZ and disableZ; remove isRecordingFor
Bug: 155422223
Test: make

insertInOrderBarrier and insertReorderBarrier are @hide and deprecated.
Remove them and update all callers to enableZ and disableZ, which are
already public.

Update native code to refer to enableZ instead of insertReorderBarrier.

In addition, remove @hide Canvas#isRecordingFor. This method was
originally used to prevent a single RenderNode from being in two display
lists. This is now supported, so there's no reason to avoid it. The one
caller used it to determine whether to reorder drawing its child Views
(which, as the comment says, makes sense to determine based on whether
the Canvas isHardwareAccelerated) and whether to call
insertReorderBarrier/insertInOrderBarrier (now enableZ/disableZ). In the
latter case, there is no need for a conditional, since enableZ/disableZ
only work on a hardware Canvas.

Change-Id: Ib216a19d6aeff40b2e23532bacd62d1795c2ab27
2020-05-06 09:38:39 -04:00
Leon Scroggins
1078c5c051 Merge "Remove/document @hidden APIs in Canvas" 2020-05-05 14:09:52 +00:00
Leon Scroggins III
491ed067dd Make Canvas#drawPatch public
Bug: 155422223
Bug: 155661807
Test: NinePatchTest#testDraw
Test: NinePatchDrawableTest#testDraw

As part of the move to a mainline module, code outside the module cannot
access @hidden APIs on Canvas. Although no code outside the module calls
these methods, there is a Canvas subclass that overrides it - NopCanvas,
which overrides it to do nothing. This is useful, and cannot be achieved
another way. (If NopCanvas did not override drawPatch, it would crash
when attempting to draw a NinePatchDrawable.)

In addition, this method is already public on RecordingCanvas. (This is
likely an accident; it contains no documentation for the method.)

Lastly, it is somewhat arbitrary that the way to draw a NinePatch
directly was to call NinePatch#draw. This is the reverse of how Canvas
drawing generally works. The newly public method matches the typical
pattern (Canvas#draw<Something>(Something, Paint)) and is already called
by NinePatch#draw.

Change-Id: I16d7dc7391e3ad5777fdd7023472545c6104af69
2020-05-04 20:54:58 +00:00
Leon Scroggins III
cf0806108d Remove/document @hidden APIs in Canvas
Bug: 155422223
Test: make

For Canvas to be in a mainline module, it cannot be have @hidden APIs
accessed from outside the module. Remove @hide where simple:

- document why Canvas(long) is needed to be public + @hide
  - remove its UnsupportedAppUsage, which was a false positive
- remove EdgeType.nativeInt (which was @hide) - no longer used
- make VertexMode.nativeInt package protected

Change-Id: I508758889c586f336c2963e1b61d01dc3dc58be7
2020-05-04 20:54:02 +00:00
Leon Scroggins III
7c784b8b16 Remove Canvas#getGL
Bug: 155422223
Test: make

This method is @UnsupportedAppUsage but low usage. It is @hide but
unused internally. Remove it so Canvas can move to a mainline module.

Change-Id: Ida6710d3640c1c6ce03eb4f5634dd4e8df581d1d
2020-05-04 18:02:45 +00:00
Leon Scroggins III
9a49427384 Move Canvas compatibility settings into Compatibility class
Bug: 155422223
Test: make

Follow on to Ie7172fb93364a1e04ab844b8fa64887bf9d8b005. Remove @hidden
APIs on Canvas - instead call setCompatibilityVersion from the
Compatibility class already in the Java package. This is a step towards
moving Canvas into a mainline module. Note that this means these are set
when the application is bound, rather than when the first View is
created.

Change-Id: I3f73d77ba7351a6cb653dd550210698c6482e1bb
2020-05-04 18:00:25 +00:00
Leon Scroggins III
2410b90e06 Deprecate Canvas.EdgeType
Bug: 129694386
Test: No change in behavior, no new tests

EdgeType is only used as a parameter to quickReject, but it is always
ignored. Deprecate it and the existing quickReject methods. Add new
versions of quickReject without EdgeType parameters. Switch clients to
the new versions.

Change-Id: Id932f10915a8c4959fe0e85f507ce7fd2da8a576
2020-01-23 20:43:34 +00:00
Artur Satayev
00f8b53650 Use new UnsupportedAppUsage annotation.
Existing annotations in libcore/ and frameworks/ will deleted after the migration. This also means that any java library that compiles @UnsupportedAppUsage requires a direct dependency on "unsupportedappusage" java_library.

Bug: 145132366
Test: m && diff unsupportedappusage_index.csv
Change-Id: I8ffa1da1bcd43c25f4ff817575db77a33c0f3d31
2020-01-07 14:40:02 +00:00
Joshua Baxter
d20c23b15f docs: Fix docs for Canvas#drawTextOnPath
add parameter descriptions for index and count in drawTextOnPath
fix a couple of typos

test: make ds-docs
Bug: 36969777
Change-Id: I7c451fac4468fb2066b9b29a321fad57785a8a36
2019-11-06 20:58:32 +00:00
Derek Sollenberger
9d25cc242f Fix fading edge effect from impacting neighboring pixels
Bug: 132354626
Bug: 129117085
Test: skia unit tests and test cases described in the bug
Change-Id: Ieaa7c831dd6298ac0565e6f1837b1c1dbd4545da
(cherry picked from commit ac33a48751)
2019-05-17 17:59:57 +00:00
Nader Jawad
531db61ac1 Added BlendMode equivalent APIs to replace deprecated PorterDuff
variants

Updated various framework Views to have equivalent BlendMode APIs
to replace the deprecated PorterDuff equivalents.
Updated InspectableProperty annotations to refer to the same
xml attributes as the original tintmode APIs

Bug: 126726419
Test: Added CTS tests to verify new BlendMode APIs
Change-Id: Id9ab36d3d4d29f351250723e9d13d49bc6062c83
Merged-In: Id9ab36d3d4d29f351250723e9d13d49bc6062c83
2019-04-17 21:11:39 +00:00
TreeHugger Robot
d4b6ff816d Merge "Pass Bitmap's native instance to JNI where feasible" 2019-03-27 23:08:42 +00:00
Leon Scroggins III
71fae62f5f Pass Bitmap's native instance to JNI where feasible
Test: CtsGraphicsTestCases, CtsUiRenderingTestCases,
      CtsRenderscriptTestCases

This is significantly faster than passing the Java object down and then
calling a JNI method to retrieve the pointer. See
https://buganizer.corp.google.com/issues/16656908#comment19

In some cases this changes what used to be native crashes (due to
android::BitmapWrapper:assertValid's LOG_ALWAYS_FATAL_IF) into
NullPointerExceptions (if a caller used a null Bitmap).

In addition:
- Remove unnecessary JNIEnv param from toBitmap(jlong)
- Change instances of toBitmap(JNIEnv*, jobject) to the above
- Replace calls to GraphicsJNI::getSkBitmap() to inline calls to
  toBitmap/getSkBitmap
- make Canvas#nInitRaster @FastNative (FIXME: Could these be
  @CriticalNative?)

Change-Id: I6194097be1b6e6952eba70e1e7052a5a250eed93
2019-03-27 13:39:23 -04:00
Leon Scroggins III
fda4f61060 Clean up references to @ColorLong
Bug: 120904891
Test: make docs && look at the output

Remove instances of {@link ColorLong}. Although the link is supposed to
go to
    https://developer.android.com/reference/android/annotation/ColorLong.html
my web browser redirects me to
    https://developer.android.com/reference
Perhaps there's a bug somewhere in the generation (I am able to navigate
to
    https://developer.android.com/reference/android/support/annotation/ColorLong?hl=en
by searching on developer.android.com - notice the addition of
"support"), but I still think it would make more sense to send users to
the page for android.graphics.Color directly.

Switch over to {@code ColorLong} (which does not generate a link) and a
reference to look at the {@link Color} class.

Update parameter named "c" to one named "color".

Unify various Canvas#drawColor APIs to say "to draw onto the canvas"
(previously some said this, while others said "to draw with").

Change-Id: I78eff5c35e350f763aac0416f6ec1ccf12f89418
2019-03-21 16:04:06 -04:00
Leon Scroggins III
bbdb731275 Stop double-counting native memory in graphics classes
Bug: 121304803
Test: Infeasible

Previously, the NativeAllocationRegistry needed to report how much
native memory was being held onto by the Java class in order to get a
more accurate count of how much memory was in use. But recent changes
allow the system to have an even more accurate view of the native memory
with mallinfo(). Further, the AOSP change
Idccb8b50d26c8c3e93cc34040d784f74dfcdbf51 introduces new APIs that allow
distinguishing between large native malloc allocations, which should
cause more frequent mallinfo() checks, and whose sizes need be available
to ahat etc, and smaller native malloc allocations.

Bitmap and AnimatedImageDrawable use the version for large native malloc
allocations. The rest pass an implied size of 0. Note that many of the
old Registries used somewhat arbitrary sizes, reinforcing the fact that
the new way of keeping track of this is better.

Add Bitmap::pixelStorageType to differentiate between types of memory
that should be accounted for by the Registry.

Update Bitmap::getAllocationByteCount to report the actual size of
ashmem allocation.

Fix a typo in LineBreaker.java, discovered while looking to find
existing callers of Bitmap's constructor.

Change-Id: I57c407258450aeaf08b47df32432466639d9faed
2019-03-14 14:50:46 +00:00
Nader Jawad
fbe2eabd3b Added Nullability annotations to new Canvas APIs
Added @NonNull annotation to drawDoubleRoundRect float array
parameters

Bug: 126702234
Test: N/A
Change-Id: Ib81fcc4ad6d5f2c471e4f6fb5ace4bdfc1d89b33
2019-03-07 09:43:34 -08:00
Leon Scroggins III
bee5e20495 Add Canvas#drawColor(@ColorLong)
Bug: 120904891
Test: I857b8c1c9346285b2f6e4670c501c9d0d4053a0e

Change-Id: If08e8b805a4bba1a526efcd3cb05d4cd19f82eff
2019-01-30 10:10:04 -05:00
Seigo Nonaka
74cababfd5 Merge "Add Canvas.drawTextRun(MeasuredText)" 2019-01-15 08:55:13 +00:00
Derek Sollenberger
24fc901e5f Improve performance of unclipped save layers.
Instead of allocating a separate renderTarget and switching
between them on each draw the new implementation follows the same
pattern that the old HWUI renderer used. The area of the layer is
now copied to a buffer on the GPU, the area is then cleared, rendered
as normal, and finally the texture is redrawn using dst_over blending.

This results in no render target switches and is considerably faster
on some hardware.

Test: CtsGraphicsTestCases, CtsUiRenderingTestCases
Bug: 119222339
Change-Id: I716aac1fc31e4c7a171373d37dee82034c01cf18
2018-12-20 10:04:46 -05:00
Nader Jawad
8168f6fa28 Merge "Added support for additional Blend Modes" 2018-12-13 21:02:37 +00:00
Nader Jawad
55e49d8816 Added support for additional Blend Modes
Created new BlendMode enum that maps to XferModes with additional
supported native values that map to SkBlendMode constants
Created new BlendModeColorFilter
Deprecated PorterDuffColorMode and PorterDuffColorFilter in
favor of BlendMode and BlendModeColorFilter.
Updated Paint API to use setBlendMode and deprecated setXfermode

Bug: 119671925
Bug: 112166079
Bug: 73224934
Test: Added CTS tests for BlendMode and BlendModeColorFilter
Change-Id: Idd50e2f0b81975c5ecf6f1c0edd4eb68198d9131
2018-12-10 15:38:59 -08:00
Seigo Nonaka
18c9aa3e66 Add Canvas.drawTextRun(MeasuredText)
This API is needed to port PrecomputedText in support library.

Bug: 112327179
Test: atest CtsWidgetTestCases
Test: atest CtsGraphicsTestCases
Test: atest CtsTextTestCases
Change-Id: Ib3aa4cc9e486bdcf6e4cbbfa75c0d2cf6960e982
2018-11-28 17:17:31 -08:00
Nader Jawad
29cad18bd3 Hidden API usage Landroid/graphics/Canvas;->mBitmap:Landroid/graphics/Bitmap;
Added maxTargetSdk version for Android P for access of mBitmap field
through reflection. The bitmap field is configured by application usages
only already so there is no need for apps to query the Bitmap from the
Canvas and should do so directly. Getters on Canvas is generally seen
as an anti-pattern.

Bug: 117521088
Test: none
Change-Id: Ie2318248f7682fd4e0a46121bc6e9f5c1546dcfb
2018-11-28 17:10:08 -08:00
John Reck
ddeaa487da Make RenderNode public API
Bug: 112709971
Test: CtsUiRenderingTestCases:.testclasses.RenderNodeTests
Change-Id: I57d64165b842d03565eda5f4d37343c4f9c45d42
2018-11-02 14:24:32 -07:00
Nader Jawad
adfe1d991b Added support for Canvas#drawDoubleRoundRect in application Canvas API
Exposed Skia's underlying drawDRRect method used to draw a double
rounded rectangle

Bug: 117181396
Test: Added test case to verify Canvas#drawDRRect and re-ran CanvasTests
Change-Id: I4e1954c8ffc82811dc541488d1df9b37309faf51
2018-10-02 17:12:15 -07:00
Mathew Inwood
8c854f86a4 Move some members to the "Q blacklist".
Based on some analysis, these fields/methods are likely false positives.
Set maxTargetSdk=P so that any apps using them are required to migrate off
them in future. See the bug for more details.

Exempted-From-Owner-Approval: Automatic changes to the codebase
affecting only @UnsupportedAppUsage annotations, themselves added
without requiring owners approval earlier.

Bug: 115609023
Test: m
Change-Id: I719b5c94e5b1f4fa562dd5d655953422958ad37e
2018-09-14 13:18:34 +01:00
Laura Davis
39c212abc6 Merge "Docs: fixed typo" into pi-dev am: 63e36667da
am: 902341345b

Change-Id: I41d0f700ebf4f6e47af90ca1af6738144f3fc3ff
2018-08-01 11:18:13 -07:00
Mathew Inwood
0d649f291a Add @UnsupportedAppUsage annotations
For packages:
  android.graphics
  android.graphics.drawable
  android.graphics.drawable.shapes
  android.graphics.fonts
  android.graphics.pdf

This is an automatically generated CL. See go/UnsupportedAppUsage
for more details.

Exempted-From-Owner-Approval: Mechanical changes to the codebase
which have been approved by Android API council and announced on
android-eng@

Bug: 110868826
Test: m
Change-Id: I7fc1162d2c63df8751a4660607e8ce72070efed8
2018-07-31 14:29:22 +01:00
Laura Davis
42d27af0da Docs: fixed typo
Test: make ds-docs

Bug: 111817624
Change-Id: I908e06419ab56220b41be6f821cff3258691b3b9
2018-07-27 12:07:27 -07:00
Derek Sollenberger
2ad19e5146 Temporarily allow StackView to use a canvas.clipRectUnion
StackView currently expands the clip of the view which is a prohibited
operation in API Level 28.  This CL currently allows this specialized
use case to work in this situation until we can update StackView
to not clip to its bounds and then just intersect with this clip
provided by its parent.

Test: CtsWidgetTestCases
Bug: 77642155
Change-Id: Icc003ad3946bb226368ec2030d4707753f4f55e9
2018-04-18 16:19:59 -04:00
Derek Sollenberger
2d4f01ba7f Restore saveLayer APIs back into the public API.
The saveLayer APIs are restored from @removed but will treat input
as ALL_SAVE_FLAGS and generate exceptions on newer API levels.

We internally used these calls in one situation that now use a
different @hide API to support the previous behavior until we
refactor that code.

Partial revert of "Remove deprecated android.graphics.Canvas APIs"
This reverts commit 7b837616ae.

Bug: 77276963
Bug: 73777445
Test: CtsGraphicsTestCases
Change-Id: I7acd4ffd5ac41a58d2be8b48cf50119c2b896708
2018-03-30 14:40:04 -04:00
Derek Sollenberger
7b837616ae Remove deprecated android.graphics.Canvas APIs
Bug: 73777445
Test: compile
Change-Id: Ie68f2fbe3c3be82f3c20529d535875d4cc204b7c
2018-03-27 14:36:50 +00:00
Mike Reed
322bc57a33 detect api version, and start respecting offsets
Test: make

Bug: 36471624
Change-Id: Ica10c557bf35e8d707fabbafab49d22109916fd3
2018-03-21 17:39:01 +00:00
Stan Iliev
7717e22c85 Draw text with a hairline stroke as if it is fill style
Dew to a side effect of HWUI opengl pipeline, the hairline stroke
is not respected, but it is drawn as a fill style. Implement the
same behaviour for skiagl pipeline with SDK API 27 and older.
On SDK released with Android P, the hairline stroke is respected.

Bug: 72494357
Test: Ran duolingo app
Change-Id: I48bdcf3ddec4bf65b5e93e01c5002177c4e3da90
2018-02-08 23:04:47 +00:00
John Reck
938e884a1f Avoid setting high contrast in every view draw
Test: high contrast text still works
Change-Id: I6674d1aca8dddf7eb9725a5346aed12ef1dbc195
2017-08-24 16:15:58 -07:00
Derek Sollenberger
d70695ee34 Add an O-release targetAPI check for Canvas.setBitmap.
For apps targeting releases earlier than O setBitmap will attempt
to preserve the matrix from the previous bitmap.  It does not however
attempt to reconstruct the save/restore stack or the clip.

Test: manual test of messenger app referenced in the bug
Bug: 37589964
Change-Id: I67f0928a3f84a8be41da38ef1868e79bdeb03e46
2017-05-11 09:28:02 -04:00
Derek Sollenberger
eb69cbbe22 Change behavior of setBitmap to cleanly reset the canvas
- identity matrix
 - no save stack
 - wide-open clip

This reverts commit 4f641d1e45

Test: bit CtsGraphicsTestCases:.CanvasTest
Bug: 36218535
Change-Id: Id11deb06e37d6df61f1f171d424ab150d812a7a8
2017-04-11 14:00:25 -04:00
Tony Mantler
4f641d1e45 Revert "Change behavior of setBitmap to cleanly reset the canvas - identity matrix - no save stack - wide-open clip"
https://buganizer.corp.google.com/issues/36218535

This reverts commit 269f989fbf.

Change-Id: Ib2473e4fce90c9abaa39eea2b77082ae26197b80
2017-03-14 22:40:31 +00:00
Mike Reed
269f989fbf Change behavior of setBitmap to cleanly reset the canvas
- identity matrix
- no save stack
- wide-open clip

Behavior around the new bitmap is the same.

Tests : CtsGraphicsTestCases

Change-Id: Ieaf8c2a1b96262ed33940dd852a86089eb93efdb
2017-03-13 15:39:57 +00:00
Derek Sollenberger
7183b6908b Merge "Deprecate Canvas save/saveLayer flags." 2017-02-14 13:31:21 +00:00