156 Commits

Author SHA1 Message Date
Stan Iliev
cccd03859c Don't apply filter in readback, when there is no scaling
Fix check for scaling in SkiaOpenGLReadback: old code was not
taking into account that matrix rotation swaps width/height.

Test: Passed PixelCopyTest#testWindowProducerCopyToRGBA16F
Bug: 110097060
Bug: 111776948
Change-Id: I0d26416fa72a026bc376417773d5a73548b1f1a5
Merged-In: I0d26416fa72a026bc376417773d5a73548b1f1a5
(cherry picked from commit d50edd004b60bec3f1d36066725129276b4a53ec)
(cherry picked from commit ee7b63aa646c937e326ac5f39f07f724020533bb)
2018-08-29 15:03:08 +08:00
Stan Iliev
421449a4a6 Fix TextureView.getBitmap with scale layer transform
Fix TextureView.getBitmap to capture content only from the layer.

Bug: 111401911
Test: A new test TextureViewTest.testTransformScale is passing
Change-Id: I2b9cee17fc48de7b12ed03d5b4f173ce5445dbfe
Merged-In: I2b9cee17fc48de7b12ed03d5b4f173ce5445dbfe
(cherry-picked from ff129aefe2b68c5dc6fe51a9b1d34f98750d4973)
(cherry picked from commit 9675537555913a6aa7c25a71a6b854a083e22ede)
2018-08-29 14:54:53 +08:00
Derek Sollenberger
0fba15b2ba Bind correct FBO when drawing a WebView into a layer.
The WebView was unable to draw into either a standard clipped
layer or the "fading edges" unclipped layer. This CL and its
companion test cases ensure that both work with simple and
complex clips.

Bug: 79619253
Bug: 80443556
Bug: 80477645
Test: atest CtsUiRenderingTestCases:.LayerTests
Merged-In: I0e16b724f74415a61cc2a841ccf4a491f293ac94
Change-Id: I4900222975fc841b11828916878fb0ea6d87dcda
2018-06-01 01:08:15 +00:00
Stan Iliev
357c63d1e9 Make sure frame buffer 0 is bound before calling GL functor
Make sure view port and frame buffer are set to the correct values
before calling GL functor (WebView) draw.
Improve correctness for stencil clip by doing a second flush that
guarantees the stencil clear will be executed after draw commands.

Bug: 79619253
Test: XFINITY Connect app draws correctly
Change-Id: Ieb3d0d70caf0469b6393e6287f8529cd86519301
2018-05-23 15:29:09 -04:00
TreeHugger Robot
a2113aa4ad Merge "AnimatedImageDrawable: Eliminate unnecessary calls to redraw" into pi-dev 2018-05-17 19:54:50 +00:00
Leon Scroggins III
4afdd1caa4 AnimatedImageDrawable: Eliminate unnecessary calls to redraw
Bug: 78866720
Test: Manual + systrace; existing CTS

Previously, we set hasAnimations to true when the AnimatedImageDrawable,
so that we would get a call to redraw. But if the image does not need to
show its next frame yet, the redraw was unnecessary.

Instead, add a new field to TreeInfo::Out, representing the delay time
until the image will need to be redrawn - i.e. when the duration of the
current frame has passed. Each call to prepareTree will post at most one
message to redraw, in time for the earliest animated image to be
redrawn. Post the message for one rendered frame ahead of time, so that
when it is time to show the next frame, the image has already gotten the
message to update.

On a screen with a single animated image, this drops the number of calls
to dispatchFrameCallbacks to as infrequent as possible. It is called
only when we need to draw a new frame of the image. On a screen with
multiple animated images, the calls may be redundant, but they will not
be more frequent than they would be without this change.

Switch to nsecs_t and systemTime internally, matching the rest of HWUI.

Remove mDidDraw and related. Its purpose was to prevent advancing the
animation while the image is not being drawn. But it isn't really
necessary. If it's not drawn, onDraw is not called, which is where we
trigger decoding. And onDraw already has a defense against getting too
far ahead - if its timer indicates that it should skip a frame or show
it very briefly, it will back up its timer. More importantly, mDidDraw
caused a bug, when combined with less frequent redraws. If the display
list containing the drawable doesn't need to be redrawn for other
reasons, the drawable's timer never advanced, so its animation stopped.

Fix software drawing. Compute the milliseconds in the future to draw the
next frame, and add that to SystemClock.uptimeMillis() to compute the
time to pass to scheduleSelf.

Change-Id: I13aab49922fa300f73b327be25561d7120c09ec4
2018-05-16 18:51:07 -04:00
Leon Scroggins
b638985cc1 Merge "Use filtering when drawing nine-patches" into pi-dev 2018-05-09 16:38:41 +00:00
Leon Scroggins III
5a663768c4 Use filtering when drawing nine-patches
Bug: 77917978
Test: Look at toggles; CtsUiRenderingTestCases

Prior to this change, the toggles look pixelated due to using a
"nearest" filter instead of a "bilerp".

This matches the behavior of the hwui renderer.

Depends on changes in Skia (Ib7d0abdd51981bddf36ec5c3fd84bb651f405f0f)
to respect the filter quality when drawing to a GPU canvas and to
remove the resulting "bleeding" effect from drawImageLattice.

Change-Id: I59d81a17f351e18574539479a38a580a02e1619b
2018-05-08 17:23:11 +00:00
John Reck
bf39913bbc Merge "Ensure GL & Gralloc both support FP16 before using it" into pi-dev 2018-05-07 20:26:02 +00:00
John Reck
b29c772429 Ensure GL & Gralloc both support FP16 before using it
Change-Id: I3bda750b6011d9a69969fc938a230c2445ee8dae
Merged-In: Id8a53885178d698c7b2fd6fc5ea8d4e36ce2ef15
Fixes: 77973662
Test: builds & CTS passes
2018-05-07 16:49:45 +00:00
Derek Sollenberger
2324991a77 Support readback of TextureView into 565 and extended sRGB.
Bug: 78906699
Test: CtsViewTestCases
Change-Id: I89e8544a883dcb3eb222c164ab57d20e55a073c3
2018-05-04 18:46:52 +00:00
Derek Sollenberger
551d08e2d5 Respect a Layer's (e.g. SurfaceTexture) colorSpace when compositing
This CL extracts the android_dataspace from the GLConsumer and converts
it to a SkColorSpace.  HWUI always expects to composite into an sRGB
destination so when we draw the layer we run the draw through a
colorFilter that converts the input colorSpace into that of the
destination.

Test: CtsViewTestCases
Bug: 78016220
Merged-In: Ic0446a0d861e86a5a9d0382346b57fcc45c8a61b
Change-Id: Ic0446a0d861e86a5a9d0382346b57fcc45c8a61b
2018-05-01 02:45:43 +00:00
Derek Sollenberger
92a9eb9713 Unpin bitmaps but don't purge all scratch resources.
This is a partial revert of b1f27aae89a9da9fbf3cb15a47f1a401db5a7974.

Test: hwui_unit_tests
Bug: 77654081
Change-Id: I5a58c156a280edfe3e9973ac3a8a30c97a2cff8b
2018-04-12 13:42:19 -04:00
Derek Sollenberger
0057db22fe Print detailed memory usage of Skia for dumpsys gfxinfo
Bug: 74435803
Test: adb shell dumpsys gfxinfo [package_name]
Change-Id: I1f2bcab500fb47c5e0b50c7459d4a876b063916b
2018-04-02 15:37:06 -04:00
Stan Iliev
003a9f6738 Fix memory leak in ShaderCache
Fix memory leak in a limited memory situation within
ShaderCache::load().

Bug: 76213660
Test: Passed ShaderCacheTest unit test, ran a build on device.
Change-Id: Ibb6ea8fe167eb22bcbbaffc4cfffac12eda98c42
2018-03-30 14:19:39 +00:00
Leon Scroggins III
1a12ab26d4 Fix Skia's impl for TextureView.getBitmap
Bug: 73392905
Test: New test added with I2d4ef440f943a50b9367976ba1444f4350071bfd

When providing a width and height, getBitmap should scale to the
destination. Add a parameter to LayerDrawable::DrawLayer for a
destination rectangle to scale to. Pass the size of the bitmap in
SkiaOpenGLPipeline::copyLayerInto down to DrawLayer. The only other
caller of DrawLayer is unaffected.

Change-Id: I7aa192181c2d15bc8fd4de2fb15c4d276b05d2ac
2018-03-29 19:30:28 +00:00
Stan Iliev
216b1572b4 Better error reporting for createOrUpdateLayer
Pass error handler down to the pipeline object, which allows
skia pipelines to print cache memory usage.
In case of an error, print arguments that were used to invoke
SkSurface::MakeRenderTarget.

Test: Ran android build on a device
Bug: 76115654
Change-Id: I5baddfa66debd505eddc3117cf94aa6ae69bedaa
2018-03-28 13:49:21 -04:00
Stan Iliev
aadc032045 Clear the frame buffer for F16 pixel format
This is a workaround for Qualcomm bug and should be reverted
after a proper fixed is found.

Bug: 74976293
Test: Ran Photo app
Change-Id: I9e0a4634f02c3553635f058eb588b510a63273ba
2018-03-23 10:50:11 -04:00
Stan Iliev
cebb647802 kClear blend mode is drawn as kDstOut
kClear blend mode is drawn as kDstOut on hardware canvas for
compatibility with Android O and older.
On SDK released with Android P, the kClear blend mode is respected.

Bug: 71602378
Test: Ran Flo app
Change-Id: I6b0fa8b8bf5aa14aa5a351a914bf2ed0469ac660
(cherry picked from commit f9a461feafded09a0949f5acfd42187dc857a823)
2018-03-15 15:28:15 +00:00
Derek Sollenberger
52230bc215 Remove Skia RenderPipeline saveLayer logic for software layers.
Test: CtsUiRenderingTestCases:LayerTests
Bug: 72052698
Change-Id: Ief845c409755e6bc61849a6ab3506ef60161f231
2018-02-20 10:59:44 -05:00
Stan Iliev
65e678fdb1 Cache VectorDrawable bounds at record time
Cache VectorDrawable bounds at record time, because the same
drawable object may be used several times with different bounds.

Bug: 71737362
Test: Wrote a new unit test, tried sample app attached to the bug
Change-Id: If7be934acf0c16b328cb0f95d849e463dcd3b88b
2018-02-08 19:01:08 +00:00
TreeHugger Robot
70f93ee673 Merge "Add API to set tonal shadow color" 2018-01-31 23:17:12 +00:00
John Reck
d8be4a0abe Add API to set tonal shadow color
Bug: 68211332
Test: HwAccelerationTests's coloredshadow demo & CTS test in topic
Change-Id: I09f5d1067b3200564a9d47219f70985edf3a2527
2018-01-31 11:28:11 -08:00
Leon Scroggins III
5b7f426ff0 Use a separate thread to decode AnimatedImageDrawable
Bug: 63908092
Test: Manual: Ie18811ba29a1db163aca08472b04ae185e9344f0

Depends on https://skia-review.googlesource.com/#/c/skia/+/101544. That
change removes the Skia class's time checks, and leaving it up to the
client to keep track of the time. In this case, the client wants to keep
track of the time because it only wants to update while it is being
drawn. If it goes off screen (for example), it will just resume where it
left off when it returns on screen. This allows for smooth animations.

If an AnimatedImageDrawable is being drawn to a SkiaRecordingCanvas,
decode on the new (lazily-created) AnimatedImageThread.

When running, always decode one frame ahead on the AnimatedImageThread
so that it will be ready when it is time to display.

During prepareTree, update the time and check whether there is a new
frame ready to draw or the next frame needs to be decoded. In either
case, return true. The next frame to be decoded will be triggered by
onDraw.

Change-Id: If447976e9df417060a950f658dbca9cf7980dd02
2018-01-29 21:08:18 -05:00
Lingfeng Yang
3a9f223dd1 Don't use shader disk cache on emulator
bug: 71900691

Emulator user might switch renderers, migrate a snapshot to a different
machine with a different shader binary format, etc.

Plus, program binaries don't seem to work so well on some desktop GPUs.

Change-Id: I0c6239acbd556097494aa903d6603c963d3141cb
2018-01-24 12:21:46 -08:00
Derek Sollenberger
2d14213849 Initial implmentation of AnimatedImageDrawables on the RenderThread.
The current implementation schedules the next frame of the images
to be decoded after the current frame completes but potentially
schedules tasks that will result in a no-op execution if a new
frame is not yet needed.

Test: HwAccelerationTest
Change-Id: I0510cb5a1b801abd651327e924deb586af0306d6
2018-01-24 13:11:39 +00:00
Stan Iliev
7e100e912c Improve layer rendering quality
Increase filter quality when rendering a layer into the frame
buffer from kNone_SkFilterQuality to kLow_SkFilterQuality.
This visibly improves the quality if the layer is scaled.
For example the circle shutter button in camera app looks
better in pressed state (there is no jagged edge).

Test: Ran camera app
Bug: 72144993
Change-Id: I138d930a25301a369876d76a2cd322df0324f0f2
2018-01-22 16:10:26 -05:00
Stan Iliev
a31973fe3a Create an empty stub for Vulkan readback
Create a stub for Vulkan readback. This avoids crashing,
because OpenGL readback does not work for Vulkan.

Test: Ran calc and gmail apps with skiavk pipeline.
Change-Id: I11cddde0a1efae1aa549e7a47d01051ec975f470
2018-01-12 11:50:29 -05:00
Stan Iliev
ba72f9a288 Remove error log messages when skia shader cache is disabled
Ideally processes with a render thread, would turn on shader
caching, but system_server is an exception.

Test: checked logcat for ShaderCache not initialized messages
Bug: 71718344
Change-Id: I5d4df6ae912a6fec3f019c9c831a1177937ea53b
2018-01-09 15:59:35 -05:00
Mike Reed
ebf96fbed7 SkPixelSerialize is deprecated (and unneeded in this case)
Test: make

Change-Id: Icc421586de82a516cb5e32b60949315d1108a9a3
2017-12-13 13:44:13 -05:00
Stan Iliev
e12d7315dd Enable fast drawing for solid color nine patch rectangles
Pass a hint to Skia, about which lattice rectangles are solid
color rectangles.

Bug: 69796044
Test: Measured ninepatch performance using sample app from the bug
Change-Id: Ib07b1b64c78ab16195f9af88a989d28682084565
2017-12-11 18:22:17 +00:00
Greg Daniel
660d6eca99 Update GrContext creation calls to use sk_sp
Test: manual testing

Change-Id: I68d8706ffa7bc7c6622ea0b8c45d7297a131f6bf
2017-12-11 09:39:16 -05:00
Derek Sollenberger
03e6cff7a6 Allocate textures in multiples of LAYER_SIZE.
This matches the behavior of the old HWUI renderer and avoids
jank when trying to release a series of small textures.

Test: UiBenchJankTests #testResizeHwLayer
Bug: 69566781
Change-Id: Idc01f8438e85d4810032fd30a141132a6cdd47a1
2017-12-05 10:41:07 -05:00
Yuqian Li
5ebbc8e5e3 Always draw render node with a non-empty projected display list
(cherry picked from commit f701ad3b4b43ea3c26d5881652a840120fca222d)

Test: tested lockscreen ripple on taimen-eng

Bug: 68859852
Change-Id: I234bba143dd4bbd5e6895dd2534eafb012ea1f16
2017-11-29 16:10:29 +00:00
John Reck
3c0369bf02 Create colored shadows demo
Test: HwAccelerationTest demo
Bug: 68211332
Change-Id: Ia53a6ac2854570d0495b355bbebee1dcec2f47ba
2017-11-13 16:53:48 -08:00
Derek Sollenberger
c061b43847 Merge "Fix bug in View system recording where Skia dropped the colorFilter." 2017-11-10 19:44:42 +00:00
Derek Sollenberger
4eb214459f Fix bug in View system recording where Skia dropped the colorFilter.
Test: CtsUiRenderingTestCases added ColorFilterTests::testColorMatrix
Bug: 69071705
Change-Id: I45268c9a40e47d44045d795ccb772ea93c3e699d
2017-11-09 16:35:56 -05:00
Stan Iliev
f1f3c38908 Use Skia API to detect if FP16 render buffer is supported
Use Skia GrCaps to detect if we can render into a FP16 buffer.
Exclude Extension class initialization from SkiaGL pipeline.

Bug: 68383159
Test: Passed testWindowProducerCopyToRGBA16F on gce_x86_phone emu
Change-Id: I3355bad891ed5403fbd94d18bb8ba110a3b77325
2017-11-09 12:56:34 -05:00
Stan Iliev
d495f43992 Implement SkSL cache
Implement SkSL cache by reusing code and logic from egl_cache_t.

Test: Improves startup times for gmail by 15ms and 10ms for calc app.
Bug: 66740665
Change-Id: I9ba479c649ba97a2c29a48d40579ba001264c957
2017-11-08 18:55:41 +00:00
John Reck
1bcacfdcab Format the world (or just HWUI)
Test: No code changes, just ran through clang-format
Change-Id: Id23aa4ec7eebc0446fe3a30260f33e7fd455bb8c
2017-11-03 10:57:44 -07:00
Romain Guy
8472ac67fd Fix PixelCopyTest failure in CTS
This feature needs support for renderable float textures, but the checks
were only guaranteeing support for float texture reads.

Bug: 68754504
Test: CtsViewTestCases

Change-Id: I0ce4a81cb8e09c10a5f1e65234685767a24ef8c4
2017-11-01 13:06:54 -07:00
TreeHugger Robot
a89c2a3160 Merge "Fix testWindowProducerCopyToRGBA16F test on x86 emulator" 2017-10-31 21:07:55 +00:00
Stan Iliev
7475d0f8db Fix testWindowProducerCopyToRGBA16F test on x86 emulator
Fix readback to return correct error code on X86 emulator, when
half float pixel format is not supported.

Test: Ran and passed all CtsViewTestCases tests on x86 emulator
Bug: 68383159
Change-Id: Id66484b73488e2c8d29fbecbd45a97af285a0710
2017-10-31 11:47:54 -04:00
Stan Iliev
cf91788ec6 Fix PixelCopy readback
Apply correct texture transform and use filter if source and dest
have different size.

Test: Ran and passed CtsUiRenderingTestCases,
Test: CtsGraphicsTestCases, CtsViewTestCases tests and the
Test: DecodeAccuracyTest.
Bug:68051015
Change-Id: Iee885e243e43497c9294f7475c0c5b9c1a783754
2017-10-30 13:46:20 -04:00
TreeHugger Robot
30dfc68a9f Merge "Convert skpCaptureEnabled compile time flag into a property" 2017-10-20 23:57:03 +00:00
TreeHugger Robot
59dc558e89 Merge "Fix crash in "Tree::updateBitmapCache"" 2017-10-20 22:20:57 +00:00
Stan Iliev
e9d0012bbf Convert skpCaptureEnabled compile time flag into a property
Convert SkiaPipeline::skpCaptureEnabled into a system property.
Add ability to capture drawing in layers. Add ability to capture
animations/sequence of frames. Fix crash when recording a
TextureView.

Test: Ran capture script.
Change-Id: I463eecf6ec90a601a6cc172ad1901bd4bcc86ac8
2017-10-20 17:49:12 -04:00
Stan Iliev
47fed6ba6a Fix crash in "Tree::updateBitmapCache"
Fix crash caused by updating vectordrawable cache for objects
from previous frames, which may have been deleted.

Bug: 67940327
Test: Ran CtsUiRenderingTestCases test
Change-Id: I4466235e78e9b7937a0d4428240574d9e3d0989f
2017-10-20 16:03:25 -04:00
Stan Iliev
d56d2188fc Fix crash in Vulkan pipeline at boot time
Fix a crash caused by calling OpenGL APIs with Vulkan pipeline
(likely a regression from ag/2706458).

Test: Ran CtsViewTestCases tests with SkiaGL pipeline.
Change-Id: Ibabeb4229ef88de57c99f2961a10a68ca71b25ab
2017-10-18 13:12:32 -04:00
Stan Iliev
a73b0be1ea Fix layer transform matrix for TextureView
Fix order of matrix multipication and use drawImage instead of
shader.

Test: Ran camera app, message app and smart face lock app.
Bug: 67405584
Change-Id: I3df161d58218e1b1845f1c1ca2db2b12c51b3532
2017-10-06 12:22:07 -04:00