Commit Graph

1537 Commits

Author SHA1 Message Date
Stan Iliev
1a025a7163 Refactor HWUI readback code to be backend independent
Implement readback from Surface, TextureView and HW Bitmap
for Vulkan pipeline by wrapping the graphics buffer in an SkImage.
Refactor both Vulkan and GL readback to use common code.
TextureView readback is moved from IRenderPipeline interface to
Readback class. Refactor all 3 readback flows to use common
implementation.

Test: Passed all view, uirendering and graphics CTS tests with GL
Test: Passed many CTS test with Vulkan, that require readback
Bug: 113673613
Change-Id: Ifbfd8170a5401f87a709b4b1b9fa058e8e11768d
2018-09-10 13:18:04 -04:00
Stan Iliev
564ca3e2c9 Reland "TextureView Vulkan support and optimized OpenGL draw"
Fix an issue with incorrect texture matrix, when there is 90/270 rotation.
This happened, because after refactoring SkImage has buffer width/height,
instead of layer width/height.
This reverts commit a683eb3945.

Bug: 113673613
Test: Ran TextureView CTS and lensblur in camera app
Change-Id: If3bcf9cd5195de09fd67a753708568a8e3ca3a9a
2018-09-05 01:58:34 +00:00
Stan Iliev
a683eb3945 Revert "Revert "Revert "TextureView Vulkan support and optimized OpenGL draw"""
This reverts commit 85f9096b52.

Reason for revert: lensblur broken.

Change-Id: I83ac163159fc537bc15936a0f8597a7512ca9d6e
2018-09-04 15:42:18 +00:00
Stan Iliev
85f9096b52 Revert "Revert "TextureView Vulkan support and optimized OpenGL draw""
This reverts commit 867c43de05.

Reason for revert: Fixed issue with unsupported hardware buffer formats by landing https://skia-review.googlesource.com/c/skia/+/150470 "Support more hardware buffer formats"

Bug: 113673613
Change-Id: I1f7c528f138e290160e75833c8d989d9535002ee
2018-08-31 22:13:15 +00:00
Stan Iliev
e6cfb09cc4 Merge "Revert "TextureView Vulkan support and optimized OpenGL draw"" 2018-08-30 18:56:41 +00:00
John Reck
867c43de05 Revert "TextureView Vulkan support and optimized OpenGL draw"
This reverts commit c8e22a6532.

Reason for revert: broke camera, b/113555199

Bug: 113555199
Change-Id: Iae9b462694d5de0cd99427afead63b567fb4d71d
2018-08-30 18:42:08 +00:00
TreeHugger Robot
54b9892f3c Merge "TextureView Vulkan support and optimized OpenGL draw" 2018-08-29 15:51:15 +00:00
Stan Iliev
c8e22a6532 TextureView Vulkan support and optimized OpenGL draw
Render TextureView as hardware bitmaps, instead of GL textures.
Cache SkImage for each observed GraphicBuffer, which is faster
even for GL.
Implement C++ SurfaceTexture, which allows Java SurfaceTexture
to be used with Vulkan HWUI render thread and application GL.
threads. Delete GLLayer and VkLayer classes and texture code
from old HWUI pipeline.

Test: Ran skiagl and skiavk pipeline with a TextureView app.
Test: TextureView CTS tests pass for GL pipeline.
Test: Ran Android NDK Native codec sample app.
Change-Id: Idc94f864ce2d34fd6ceff4be4fc7d3327e99879c
2018-08-29 10:22:03 -04:00
Brian Osman
91c9c28a85 Implement Bitmap get/setPixel(s) using SkBitmap::read/writePixels
Test: Ran CtsUiRenderingTestCases and android.graphics.cts
Change-Id: Ib32fb41d763a29919ac4744c876eb7af42fabab2
2018-08-21 13:27:34 -04:00
Seigo Nonaka
eaa917e694 Rewrite system fallback construction with new FontFamily
Bug: 111133573
Bug: 112196940
Test: atest CtsWidgetTestCases:EditTextTest
    CtsWidgetTestCases:TextViewFadingEdgeTest
    FrameworksCoreTests:TextViewFallbackLineSpacingTest
    FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
    CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
    CtsTextTestCases FrameworksCoreTests:android.text
    CtsWidgetTestCases:TextViewPrecomputedTextTest
    CtsGraphicsTestCases:android.graphics.fonts

Change-Id: I69e21940eaec4427f62abe59ae003b4f60855f22
2018-08-14 11:17:12 -07:00
Derek Sollenberger
b100231918 Default all new bitmaps to sRGB colorspace unless explicitly requested.
This fixes breakages in the WideColorGamutTests that resulted from a
change in Skia. Skia now treats all non-tagged sources as sRGB instead
of sometimes assuming sRGB_linear.

Test: atest CtsUiRenderingTestCases
Bug: 111836790
Change-Id: If7b1c00ad889446658f98e9ad644869e2eeabcdb
2018-08-06 14:51:13 -04:00
Seigo Nonaka
ef855275fc Merge "Introduce FontFamily and its builder" 2018-08-02 23:41:44 +00:00
Seigo Nonaka
88930f1df4 Introduce FontFamily and its builder
This CL is a ground work of the new Typeface construction API and
nobody uses this class except for CTS now.
I'll add new builder in Typeface to be able to create Typeface
from this FontFamily.

Bug: 72665240
Test: atest FontFamilyTest
Test: CtsWidgetTestCases:EditTextTest
    CtsWidgetTestCases:TextViewFadingEdgeTest
    FrameworksCoreTests:TextViewFallbackLineSpacingTest
    FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
    CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
    CtsTextTestCases FrameworksCoreTests:android.text
    CtsWidgetTestCases:TextViewPrecomputedTextTest

Change-Id: I15d412c367037554d911fc9e20c0cfb44aefb89a
2018-08-02 11:04:44 -07:00
John Reck
8530853158 Remove unneccessary #isHardwareAccelerated
Test: CameraTests#testBasicTranslate
Change-Id: I2b5378edc3c975609bd1b427eac5677f87f601ac
2018-08-01 16:39:22 -07:00
Seigo Nonaka
a1c21c0a02 Introduce Font and its builder class
This CL is a ground work of the new Typeface construction API and
nobody uses this class except for CTS.
I'll add FontFamily class to be able to bundle these Font clases
and register to the Typeface.

Bug: 72665240
Test: atest FontTest
Test: atest CtsWidgetTestCases:EditTextTest
    CtsWidgetTestCases:TextViewFadingEdgeTest
    FrameworksCoreTests:TextViewFallbackLineSpacingTest
    FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
    CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
    CtsTextTestCases FrameworksCoreTests:android.text
    CtsWidgetTestCases:TextViewPrecomputedTextTest

Change-Id: I68555a8b4bd6dd770ba7baae72d9a3777b2087a5
2018-07-26 16:38:44 -07:00
Ben Wagner
0ed10bedbb Replace SkDrawFilter with PaintFilter.
Skia is removing SkDrawFilter.

Test: refactoring CL. Existing unit tests still pass.
Change-Id: If81c1a2feabf7d377ae1d7bcb3e8cf0f599ad3ce
2018-07-11 12:07:22 -04:00
Ben Wagner
9f1730c4b9 Merge "Update sk_sp use for explicit." 2018-05-29 21:02:08 +00:00
Ben Wagner
6b62ac0a32 Update sk_sp use for explicit.
Skia's sk_sp class is moving from operator pointer to field to
explicit operator bool. As a result a few uses need to be updated.

Test: refactoring CL. Existing unit tests still pass.
Change-Id: I97ca0647c7c490554da7dd626c99b3447d7cbc84
2018-05-29 14:17:08 -04:00
Seigo Nonaka
0ca492fb4d Follow minikin header structure changes
Bug: N/A
Test: minikin_tests
Test: hwui_unit_tests
Change-Id: I2e3fd1a549fe3e9703d2ef93d03a5923005d4caa
2018-05-25 14:52:22 -07:00
TreeHugger Robot
5d4c20e752 Merge "Cleanup Bitmap#recycle" 2018-05-25 13:36:21 +00:00
Leon Scroggins III
5078c92245 Remove unused refSkPixelRef
Test: Build

Change-Id: Iac21b08217113787765b5be611f7e1e66b317904
2018-05-25 12:48:08 +00:00
Leon Scroggins III
f8adae1b33 Cleanup Bitmap#recycle
Test: Build, CTS

mNativePtr can never be 0 (it is final, and the constructor prevents
setting it to 0), so do not check for it. nativeRecycle only ever
returns true, so make it return void.

Change-Id: Ib94c0304ca7303d6899f085e64be7c051908d173
2018-05-24 15:31:20 -04:00
Leon Scroggins III
117f0c2833 Merge "AnimatedImageDrawable: Eliminate unnecessary calls to redraw" into pi-dev am: a2113aa4ad
am: 6353ff5bb5

Change-Id: I5258721b49834aba58e9bf19162e6a4588f68f0f
2018-05-17 13:16:13 -07: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
4127417bcb Merge "Allow ImageDecoder to read SkFILEStream directly" into pi-dev am: b9790fd184
am: 2648615308

Change-Id: I3b31e298517327f2400d5e060fb09e79f393fc0f
2018-05-09 16:10:22 -07:00
Leon Scroggins
f7a1403f36 Merge "Allow AssetStreamAdaptor to be seekable" into pi-dev am: b69f7c9e0b
am: 341ade0d5a

Change-Id: I79e724492884ff9f993d07da3f36cd84b4aaa2eb
2018-05-09 10:16:01 -07:00
Leon Scroggins III
0c699add01 Allow ImageDecoder to read SkFILEStream directly
Bug: 78866720
Test: Manual

If the input stream is seekable, SkGifCodec will read from it directly.
If not, it has to copy (parts of) the input in order re-decode when it
loops. Directly use the seekable SkFILEStream so that SkGifCodec skips
the copy, saving memory proportional to the size of the file.

Depends on a change in upstream Skia which allows SkFILEStream to treat
the initial offset as the beginning of the file:
https://skia-review.googlesource.com/c/skia/+/126511

Change-Id: Iefb58785157ba684ad3603778175b3dba97567b2
2018-05-07 16:28:16 -04:00
Leon Scroggins III
0492eefece Allow AssetStreamAdaptor to be seekable
Bug: 78866720
Test: Manual

It already supports rewinding, and the underlying Asset supports
seeking. Allow it to be seeked so that SkGifCodec can read directly from
it rather than copying data it needs for internal use.

Change-Id: I0765dcf4a507724878a5a700a770d35802c4b7be
2018-05-07 11:02:17 -04:00
android-build-team Robot
404632bcf2 Merge "Pass full context to Minikin" 2018-05-04 19:34:57 +00:00
Mike Reed
8cafcc628f remove (dead) caches from hwui
Test: make

Change-Id: I18bfe51896672272ce7d471eaead69b651399368
2018-05-03 13:23:40 -04:00
Seigo Nonaka
3a4217fb74 Pass full context to Minikin
Bug: 72461923
Test: atest CtsWidgetTestCases:EditTextTest
    CtsWidgetTestCases:TextViewFadingEdgeTest
    FrameworksCoreTests:TextViewFallbackLineSpacingTest
    FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
    CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
    CtsTextTestCases FrameworksCoreTests:android.text
    CtsWidgetTestCases:TextViewPrecomputedTextTest
Test: minikin_tests
Test: hwui_unit_tests

Change-Id: Ic0827a85dbf1ab2b38d44514e400f524686748d2
2018-05-02 16:43:58 -07:00
Mike Reed
441e02e91b don't reference (dead) DevKern
This field is not respected in Android, so we want to remove it from Skia.

Test: make

Change-Id: If410265a31c04f283098ac55727c4a12bf717ac1
2018-05-01 20:03:13 +00:00
Nader Jawad
e7b5129c1e Updated Bitmap mutablity documentation and removed Bitmap#mIsMutable
flag

Updated Bitmap java and native implementation to redirect queries of
mutability to the native implementation provided by Skia. Updated
documentation of Bitmap.createBitmap method to accurately describe
mutability of the Bitmap result based on various inputs.
Removed flag from Bitmap class in favor of querying jni API directly.
Updated Bitmap constructor to no longer utilize mutable parameter
provided by jni call. Created hidden setImmutable method that invokes
corresponding native method to flip the Bitmap's mutability flag.

Fixes: 65560449
Test: Re-ran CTS tests and updated Bitmap tests to verify mutability of
all creation methods

Change-Id: I1b0b9de2fc15369b4e3f83512b866915387ac926
2018-04-22 22:12:48 -07:00
Leon Scroggins III
366e1e716d Merge "Never scale nine-patches in ImageDecoder" into pi-dev am: 9cb6759072
am: c13c945b19

Change-Id: I437c33c878db8c6bc4cbd3cd3d6989908bc6ff89
2018-04-05 16:19:52 -07:00
Leon Scroggins III
7d940ba43d Never scale nine-patches in ImageDecoder
Bug: 76448902
Bug: 70889348
Test: Manual + CtsThemeHostTestCases
(Ica5e7e81848c3880accee922ee6f1cc9e26262ca)

Scaling a nine-patch requires scaling its divs. When the scale factor is
not an integer, we have to round. This gets out of sync with the way the
decoder scaled the image, resulting in stretching or keeping fixed the
wrong portions of the image. Making this worse, when we scale down, we
end up with divs colliding with each other, and we have to arbitrarily
adjust them further so they do not collide.

NinePatchDrawable and the drawing code already know how to handle
drawing from the originally-sized image and do a better job stretching
appropriately, so allow them to do their job.

We already do something similar for Bitmaps created by ImageDecoder on
apps targeting P and above - instead of scaling them up, we allow the
BitmapDrawable's scaling code to handle density differences. We
preserved the old behavior (scale up) on apps targeting pre-P because
those apps may rely on the size of the Bitmap contained in a
BitmapDrawable without accounting for its density (see Bug: 74061412).
But that is not an issue for NinePatchDrawables, which do not allow
peeking at their internal Bitmaps.

Rewrite ImageDecoder.computeDensity. There is no need for it to be
static, since it takes an ImageDecoder as a parameter and reads its
fields, including the new field mIsNinePatch. Set mIsNinePatch in the
constructor to avoid another down call into native. Split up the
conditions that result in returning srcDensity without calling
setTargetSize for clarity.

Remove ImageDecoder constructor from the graylist. It was accidentally
added due to the fact that it is called transitively from public APIs.

Change-Id: I3c5ddd67f3352c991515f30ce1c477c9a608833f
2018-04-05 12:50:32 -04:00
Leon Scroggins
2542ce4f2b Merge "Add in/out ColorSpace to ImageDecoder" into pi-dev am: bf1fe9aecd
am: 8f935b0fbb

Change-Id: I1a0d03fb9ca51276dc1907fd4cd2d2685fc46a46
2018-03-29 21:55:38 +00:00
Leon Scroggins
bf1fe9aecd Merge "Add in/out ColorSpace to ImageDecoder" into pi-dev 2018-03-29 20:27:43 +00:00
Leon Scroggins III
1a69f4598f Add in/out ColorSpace to ImageDecoder
Bug: 76448408
Test: I851173b771668f0e6712bebfe06bfb8559801199

Add ImageInfo.getColorSpace() for retrieving the default ColorSpace.
This matches BitmapFactory.Options.outColorSpace.

Add ImageDecoder.setTargetColorSpace() for choosing a new ColorSpace.
This matches BitmapFactory.Options.inPreferredColorSpace.

Rename setSampleSize to setTargetSampleSize to match setTargetSize and
setTargetColorSpace.

Change-Id: If2f4e755dfc163f754849f896de24659198973db
2018-03-29 13:44:22 -04:00
John Reck
98d1b8b2d1 Merge "Move Path to NAR" into pi-dev am: 9434b66bf7
am: 6541c42146

Change-Id: I6cf9880e75ade2430af26eda7d9777ce81250168
2018-03-29 17:34:00 +00:00
John Reck
205d83e108 Move Path to NAR
Bug: 74686528
Test: PathTest#testUseAfterFinalize
Change-Id: Ic1c9df6f1b63ea5795a6c3a54b8fc50fdaf0a5f4
2018-03-28 14:36:58 -07:00
Leon Scroggins
547a528421 Merge changes from topics "DecodeException_ERROR", "AID_autoStart", "onPartialImage" into pi-dev am: ceb14e015b
am: fbe597e850

Change-Id: I2a70864001a9e6cf21692bcbcb5c2cc81361f0bf
2018-03-23 00:57:54 +00:00
Leon Scroggins III
1564d3070f Re-write onPartialImage API am: 1d2bf2b846
am: 1a82348834

Change-Id: Icd8be0239571f543ae815f51d162eb1485567eec
2018-03-23 00:51:26 +00:00
Leon Scroggins III
1a82348834 Re-write onPartialImage API
am: 1d2bf2b846

Change-Id: I7436bbe89b9efd9a406958b14f79294e982c5b3a
2018-03-22 23:34:41 +00:00
Leon Scroggins
ceb14e015b Merge changes from topics "DecodeException_ERROR", "AID_autoStart", "onPartialImage" into pi-dev
* changes:
  Rename ImageDecoder.ERRORs
  Add the ability to autoStart AID from xml
  Re-write onPartialImage API
2018-03-22 21:53:05 +00:00
Leon Scroggins III
cf7294fda6 Rename ImageDecoder.ERRORs
Bug: 73788969
Test: I501e8b76aacd785cb994165ab01dc1b39fea3a1c

Move them into ImageDecoder.DecodeException, which is where they are
actually used. This also provides some more context, so that the prefix
"ERROR_" is no longer necessary, fixing the redundancy/awkwardness in
ERROR_SOURCE_ERROR. Further rename that to SOURCE_MALFORMED_DATA, which
is more descriptive, and does not imply a Java Error.

Change-Id: Ied17ad343650f9c33d9a35b0f9d00ccc22264bd6
2018-03-22 13:09:02 -04:00
John Reck
1257885131 Merge "Merge "Fix wrong SafeUnref type" into pi-dev am: b09f2b5926" into pi-dev-plus-aosp
am: 9eecfb03fd

Change-Id: I7c08e82c93d169cb097c73d60b617ed7bd20b01e
2018-03-21 23:56:02 +00:00
TreeHugger Robot
b09f2b5926 Merge "Fix wrong SafeUnref type" into pi-dev 2018-03-21 21:34:10 +00:00
John Reck
97c7f4b84b Fix wrong SafeUnref type
Test: builds
Change-Id: I5a03551c408736722802ba0e8692c3d85e375112
Fixes: 76029886
2018-03-21 10:50:47 -07:00
Leon Scroggins
442522d112 Merge "Report native allocation size of AnimatedImageDrawable" into pi-dev am: d848f75f99
am: 6413aebc02

Change-Id: Id1a101b08f8f9b9b53875bd9c784dea04a5b4110
2018-03-21 17:46:16 +00:00