Commit Graph

4158 Commits

Author SHA1 Message Date
TreeHugger Robot
f623bfa355 Merge "Remove PackageManager.getResourcesForApplicationAsUser API" 2020-10-23 05:31:13 +00:00
Vishnu Nair
ce1a648484 Allow creating child surfaces from BlastBufferQueue
App such as Chrome create child surfaces and parent them to
surfaces provided by SurfaceView. When we enable the blast
adapter for SurfaceView, the IGBP returned to the app is
created in the client and SurfaceFlinger does not know about it.
When the app creates a child surface and provides the IGBP as the
parent surface identifier, SF fails to validate the IGBP and the
surface is not created. This can be avoid if the client creates the
child surface from the SV SurfaceControl but we still need to
support existing APIs.

To fix this, when we create a Surface from the adapter, pass in
the handle of the Blast SurfaceControl. When calling
ASurfaceControl_createFromWindow, use this handle to identify
the parent.

Bug: 168917217
Test: adb shell settings put global use_blast_adapter_sv 1 & launch chrome
Change-Id: I879b411c47e8558397516bd7b7278813e79e005f
2020-10-22 18:03:22 -07:00
Felka Chang
f922ae3179 Remove PackageManager.getResourcesForApplicationAsUser API
To switch another user to do something should create the context of the
specified user by using Context.createContextAsUser rather than call
*AsUser API directly.

To change Icon not to use PackageManager.getResourcesForApplicationAsUser
lets StatusBarIconViewTest no need to mock
getResourcesForApplicationAsUser in mock PackageManager instance.

Test: make -j droid cts gts vts
Test: make -j docs
Test: atest SystemUITests \
    FrameworksServicesTests:com.android.server.pm \
    CtsGraphicsTestCases:android.graphics.drawable.cts.IconTest \
    FrameworksCoreTests:android.graphics.drawable.IconTest
Bug: 170928809
Change-Id: I4a2ec54b6e137a9c9efcfba0589c08ea8cac86ce
2020-10-23 01:39:09 +08:00
TreeHugger Robot
5746484a09 Merge "Fix wrong offset of BiDi text by TextShaper" 2020-10-21 20:05:28 +00:00
Jeff Sharkey
1c08f48253 Apply fixes for EfficientStringsChecker.
The recently-built Error Prone checker has found many instances where
we're always paying the cost of StringBuilder concatenation, even in
the typical cases where preconditions are successfully met.

Benchmarks have shown that even when replacing these with varargs
formatter strings, the default case is 20x faster.

Bug: 170978902
Test: none
Exempt-From-Owner-Approval: trivial refactoring
Change-Id: If8c00bc73467bfb91ec16c162969c9d26ca53646
2020-10-20 22:00:16 -06:00
Seigo Nonaka
170e0949f3 Fix wrong offset of BiDi text by TextShaper
This CL includes:
- Fix relative offset of BidiRun by reviving width calculation in TextLine.
- Fix bidi level buffer offset. It shuold be relative to the substring, but
  the absolute offset was passed.
- Removed paint argument from PositionedGlyph which is not used.

Bug: 171275519
Test: atest android.graphics.text.cts.TextRunShaperTest
Test: atest android.text.cts.TextShaperTest

Change-Id: I36949089d744bdfae61995210b2051866a7510ac
2020-10-19 23:31:35 -07:00
TreeHugger Robot
767286e0ef Merge "Improve Font#equals and Font#hashCode for HashMap." 2020-10-18 01:47:34 +00:00
Vishnu Nair
6e2fec6efd Merge "BLAST: Ensure buffers are submitted before reporting draw finished" 2020-10-16 23:03:51 +00:00
Seigo Nonaka
31bf860bb6 Improve Font#equals and Font#hashCode for HashMap.
Font#equals and Font#hashCode reads bytes in the buffer and end up
with bad performance if we use it as key of HashMap.

To improve them, does following.

- Font#hashCode
Use buffer size as hash. Since we only accept OpenType compliant font
files (invalid font data will be IllegalArgumentException in ctor),
the hash collision due to same file size is unlikely happens.

The ByteBuffer#hashCode includes head position as hashCode but
intentionally exclude them from new hashCode since the head position
is not used by platform include native code.

- Font#equals
The ByteBuffer is frequently duplicated for many reasons, e.g. having
different reading head, etc, but the underlying mmaped memory address
has not changed. Fortunately we have this address in underlying font
object. Compare them as a shortcut of content equality.

With this change, the local benchmark for the Font key-ed HashMap look
up gets faster from 30ms to 4us. (on Pixel 3a)

Bug: 170494256
Test: atest FontTest

Change-Id: Ibc7f7aae0b3427e71209444eebb93753c340b711
2020-10-15 18:24:35 -07:00
TreeHugger Robot
d27f5a6049 Merge "Update Shader.TileMode documentation." 2020-10-16 00:59:02 +00:00
TreeHugger Robot
7347b89fec Merge "Update TextShaper APIs to address API council feedback" 2020-10-15 23:11:03 +00:00
Nader Jawad
394d6432c3 Update Shader.TileMode documentation.
Updated documentation for TileModel.DECAL to indicate that
"original domain" refers to the bounds of the shader and
transparent black will be drawn for regions outsdie of the
shader.

Fixes: 169331275
Test: N/A
Change-Id: I6afdf4354668197cd7f584071fc35f80e07053fe
2020-10-15 15:42:58 -07:00
Vishnu Nair
9bce5e0c04 BLAST: Ensure buffers are submitted before reporting draw finished
If blast sync is not enabled abut we need to report draw finished
for the next frame, call setNextTransaction. Blast buffer queue
will process any queued up buffers and ensure the buffer is
submitted before reporting draw finished.

Test: Test no flickers with blast enabled in splitscreen
Change-Id: If7a36eb0a9a2914dd37adfd20abcbe2b5074b16a
2020-10-15 11:48:42 -07: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
b4252a16db Add @PaintFlag annotation
Bug: N/A
Test: N/A
Change-Id: I331b08f6b3b91272371aad86c9cba01173ed01a9
2020-10-14 12:28:43 -07:00
TreeHugger Robot
54f1e21fcf Merge "Add Font file path if it is created from native." 2020-10-14 08:35:35 +00:00
Ady Abraham
439b20b2c7 Merge "pass frame deadline to Choreographer" 2020-10-13 23:03:55 +00:00
TreeHugger Robot
8f8021344e Merge "Add missing javadoc" 2020-10-12 16:43:16 +00:00
Seigo Nonaka
c519ed8ece Add Font file path if it is created from native.
Bug: 170492880
Test: TextShaperTest
Change-Id: I8d669861c6d3ef362467d9bcf04a404c2780199c
2020-10-09 12:45:01 -07:00
Ady Abraham
dfb13985af pass frame deadline to Choreographer
Pass the frame deadline calculated by SF to Choreographer so
hwui would be able to improve its stats by knowing if a frame is
likely to be late.

Bug: 169858174
Test: manual
Change-Id: Ib9fd93638b54f08d8dc72fa6b023e2dd7c276dc7
2020-10-09 11:17:32 -07:00
TreeHugger Robot
b06bedb886 Merge "Add basic support for input shaders to RuntimeShader." 2020-10-08 22:03:12 +00:00
Jeff Sharkey
f76ffeaff1 Merge changes from topic "oct6"
* changes:
  Upgrade AndroidFrameworkBinderIdentity to fatal.
  Tighten up Binder.clearCallingIdentity() usage.
  Tighten up Binder.clearCallingIdentity() usage.
  Tighten up Binder.clearCallingIdentity() usage.
2020-10-08 18:50:22 +00:00
Jeff Sharkey
2d2e07e2ff Tighten up Binder.clearCallingIdentity() usage.
The recently added AndroidFrameworkBinderIdentity Error Prone checker
examines code to ensure that any cleared identities are restored to
avoid obscure security vulnerabilities.

This change is a purely mechanical refactoring that adds the "final"
keyword to the cleared identity to ensure that it's not accidentally
modified before eventually being cleared.  Here's the exact command
used to generate this CL:

$ find . -name "*.java" -exec sed -Ei \
    's/    (long \w+ = .+?clearCallingIdentity)/    final \1/' \
    {} \;

Bug: 155703208
Test: make
Exempt-From-Owner-Approval: trivial refactoring
Change-Id: I832c9d70c3dfcd8d669cf71939d97837becc973a
2020-10-06 11:18:09 -06:00
Seigo Nonaka
39c482f21f Add Canvas#drawGlyphs
Bug: 168048923
Test: atest CanvasDrawGlyphsTest
Change-Id: I013335fa82883146044ea03fbbe67e1e26a35f6d
2020-10-02 23:09:45 -07:00
Derek Sollenberger
80e3a1a908 Add basic support for input shaders to RuntimeShader.
This adds the ability for Java RuntimeShaders to provide other
shaders as inputs.  This is a first pass API and should be updated
to mirror the SkRuntimeShaderBuilder API that enable callers to set
the uniforms and inputs shaders by name instead of passing arrays.

Test: HwAccelerationTests
Bug: n/a
Change-Id: I53a15ad864bede2fecc1e2459dca983d224114a0
2020-10-02 15:55:03 -04:00
Seigo Nonaka
760d3514ca Follow minikin library update for preventing copy-and-move Font
Bug: 169871852
Test: minikin_tests
Test: hwui_unit_tests
Test: atst CtsGraphicsTestCases
Change-Id: Ic8a272e5dec9feacf5e1c49542a0623782950108
2020-10-01 18:07:29 -07:00
Ady Abraham
67199f7051 Merge "Add vsyncId to transactions" 2020-10-01 17:55:19 +00:00
Vishnu Nair
c8b32797ea Merge "Add debug logs to BlastBufferQueue" 2020-10-01 01:59:07 +00:00
TreeHugger Robot
cf31bd4484 Merge "Revert "Create wrapper around Shader native implementation"" 2020-09-30 22:45:53 +00:00
Nader Jawad
5bed1f5332 Revert "Create wrapper around Shader native implementation"
This reverts commit fc42a99ea5.

Because we are moving away from a wrapper class to delegate
between SkImageFilter and SkShader and instead adding
RenderEffect on RenderNode, this wrapper implementation
is no longer necessary. There are some behavioral
differences between SkShader and SkImageFilter that
would lead to additional complexity in conversions
between these objects and potential bugs.
To simplify this, RenderEffect will be added
directly to RenderNode to support better
caching of rasterization layers that is necessary
for various visual effects like blur.

Test: N/A
Change-Id: I65dc9f8bd26aed8761af13491ae3f6d583208377
2020-09-30 11:55:48 -07:00
Vishnu Nair
faa3969d77 Add debug logs to BlastBufferQueue
Bug: 168917217
Test: Enable logs and check logcat
Change-Id: Ie7aa4a9fb60924589f8efccc1a64a46f85d6dde3
2020-09-30 09:44:43 -07:00
Seigo Nonaka
f4babd73dc Address API Council Feedback to android.graphics.fonts.Font
Bug: 169640906
Test: N/A
Change-Id: If5ef79f6a692a09f1464c65b55844742413526de
2020-09-29 18:58:41 -07:00
TreeHugger Robot
703427e52c Merge "Add TextShaper API" 2020-09-30 00:21:22 +00:00
Nader Jawad
390d6e8586 Added RenderEffect property on RenderNode
Introduced RenderEffect API to handle consuming
SkImageFilter parameters on RenderNode objects
in order to support blur.

Updated SilkFX demo to use RenderEffect
APIs on RenderNode instead of BlurShader

Bug: 168549524
Test: Added tests to RenderNode CTS test cases
Change-Id: I5005a322a6d75438dd104e6915630264406cf771
2020-09-29 14:20:02 -07:00
Seigo Nonaka
f3a1915b2e Add TextShaper API
TextShaper API provides a primitive text layout result, e.g. what glyph is used etc.

Here is the new APIs and its description

- PositionedGlyphs
This is a native instance backed object that gives layout information to developers.

- GlyphStyle
The glyph style is an object that holds the parameters that will be used for drawing.
This object is a subset of the Paint object for avoiding creating lots of Paint copy.

- TextShaper#shapeText
This does a text shaping and gives TextShaper.Result. This is a native backed primitive
shaping API.

- StyledTextShaper
This is a text shaper for a styled text. This will be the top-level developer facing
API for shaping text.

Bug: 168048923
Test: atest FontTest TextShaperTest StyledTextShaperTest
Change-Id: I2e91d1ef8503b25b28efc94da7de7cad49c4c1a9
2020-09-29 12:38:28 -07:00
Ady Abraham
2afd66e968 Add vsyncId to transactions
This change is the first in a series of changes to add vsyncIds to
transactions so that SurfaceFlinger could identity jank related
to transactions. In this change we are sending the vsyncIds for
transactions originated by WindowAnimator.

Bug: 166302754
Test: manually see transactions in frame timeline
Change-Id: Ib0e9f4dcc873ab671c2bfded87868bfea2bf9366
2020-09-29 12:15:22 -07:00
Vishnu Nair
cf143d4408 Add BlastBufferQueue adapter in SurfaceView
Add support for submitting buffers in SurfaceView via BLAST using
BlastBufferQueue adapter.

Introduce a new config wm_use_blast_adapter_sv, that is disabled by
default to enable the adapter.

When enabled, the blast SC is created as a child of the main
SurfaceView SC and the main SC is set as a container layer. This layer
will continue to handle position, visibility and transforms while the
blast SC will handle buffer updates via the adapter.

Test: atest SurfaceViewBufferTests
Test: go/wm-smoke w/ & w/o adb shell adb shell settings set global use_blast_adapter_sv 1
Bug: b/168504870, b/168917217

Change-Id: I826eef39e03ea339df54400be0709eaba6c88797
2020-09-24 21:45:18 +00:00
John Reck
7752430d67 Add missing javadoc
Bug: 169331021
Test: none
Change-Id: I9400164b4c403298f62fa14ad64ed0f1ca858336
2020-09-24 10:52:39 -07:00
Seigo Nonaka
1ed4f6441f Add necessary APIs for supporting glyph level drawing
This CL adds following APIs

Font#cloneWithSettings
  This API provides a faster Font instance creation for different
  variation settings.

Font#getBounds
  This API provides glyph advance and bounding box information.

Font#getMetrics
  This API provides font metrics that will be used for deciding line
  height and/or baseline.

Bug: 168136332
Test: atest FontTest
Test: TreeHugger

Change-Id: I335557ce47ea0ca8e012c2a48b804c00bb348392
2020-09-23 13:01:38 -07:00
TreeHugger Robot
f03c5aa5f6 Merge "Added support for edge treatment parameters for BlurShader" 2020-09-23 00:37:40 +00:00
TreeHugger Robot
4bd5f7407a Merge "Expose ParcelableColorSpace" 2020-09-22 18:38:17 +00:00
Nader Jawad
6c2296137e Added support for edge treatment parameters for BlurShader
Added configurable parameters for edge treatment for
BlurShader to determine how edge pixels are to be
computed as part of the blur kernel. This provides
the option to sample the edge pixels of the source
for larger windows as well as using transparent
(default behavior)

Fixes: 167714368
Test: Added CTS tests to verify results of edge treatment parameters
Change-Id: I3880ff4aa2e2a4eba831a0aa6d2ec77b07e84813
2020-09-21 20:52:35 -07:00
John Reck
f7e38f301c Expose ParcelableColorSpace
Bug: 148412652
Test: ParcelableColorSpaceTest CTS
Change-Id: I3749fe903b2644b8a0d1e44893ee38a0b0a4e0a1
2020-09-17 16:22:36 -07:00
Ady Abraham
41b5d5a764 Merge "Shared timeline plumbing" 2020-09-17 21:16:25 +00:00
Steven Thomas
6fabb5aa17 Shared timeline plumbing
Add plumbing to get shared timeline data from Surface Flinger to HWUI
and back.

Bug: 162890382
Bug: 162888881
Bug: 162890407

Test: manual using ALOG messages in SF
Change-Id: I85c5eb56d2fa933889518854e7b79b1e65e29af3
2020-09-16 22:58:39 -07:00
Emilian Peev
0173af0189 Add RAW_DEPTH10 image format
Add support for 10bit opaque and private RAW_DEPTH10 image format
which is similar to RAW_DEPTH.

Bug: 167250258
Test: Manual using camera application.
Change-Id: Ib2ee11570429d7a9a53e9dd6bc2042a1f5eaa760
2020-09-14 23:34:49 +00:00
Leon Scroggins
de50855fed Merge "ImageDecoder: Use AssetFileDescriptor's length" 2020-09-14 14:40:43 +00:00
Leon Scroggins III
c3fda89b05 ImageDecoder: Use AssetFileDescriptor's length
Bug: 166069819
Test: ImageDecoderTest (cts)

The contained asset may only be a subset of the AssetFileDescriptor.
SkWebpCodec reads the entire stream into a contiguous block of memory.
(This is because libwebp does not provide a streaming API for creating
its demuxer.) If the AssetFileDescriptor contains data after the webp
file, this wastes memory. In some cases, there may be a *lot* of data
after the webp file, so this can use too much memory, particularly on
low memory devices.

Change-Id: I8d8e520f43a7ef0d7e4534ef165d8c7e4d2a0b55
2020-09-11 16:58:51 -04:00
Leon Scroggins III
d608691c29 Update maxTargetSdk for createAshmemBitmap
Bug: 150395371
Test: make

Follow-on to I359187a5c70b5e241c7f5879d50fde2a7449c818. Apps built
against R should have @UnsupportedAppUsage access to createAshmemBitmap,
since asShared does not exist yet. But apps built against S should use
the new API.

Note that the R branches have *no* maxTargetSdk set for this method.
This was added in S before it was possible to set R as maxTargetSdk.

Change-Id: If2313809084bc70613214b562847ae3a792df259
2020-08-21 17:42:37 +00:00
Nader Jawad
322cb9c4e8 Added BlurShader API
Created BlurShader framework API along with
native implementation as an implementation of
the Shader wrapper that maps to either
SkShader or SkImageFilter

Bug: 143468037
Test: Added CTS test to verify BlurShader

Change-Id: I05fcf7ba79e9d552f8b0738f7382f7826cd94e21
2020-08-19 13:49:50 -07:00