Commit Graph

170 Commits

Author SHA1 Message Date
Leon Scroggins III
4c4259b339 Add Bitmap#eraseColor(@ColorLong) + helpers
Bug: 120904891
Test: I162451ebf807f3a8a44679e5c10406468c922500

- Add Bitmap#eraseColor(@ColorLong). This allows erasing in ColorSpaces
  besides SRGB. New API is hidden pending API-council approval. It is
  @TestApi so it can be used by the new tests.
- Rewrite Bitmap#erase(@ColorInt)'s internals. The ColorInt should be
  treated as an SRGB color. The old code (deep in SkPixmap::erase)
  treated the color as being in the SkColorSpace of the SkBitmap.
- Update getNativeColorSpace to return immediately when it throws.
  Existing callers should never throw anyway, since they do their own
  checks (and throws) in Java before reaching this method. But relying
  on this method to properly return simplifies the new callers.

Change-Id: I1b736934ce1b8294c827bb61c2a363207569da4f
2019-01-15 12:16:19 -05:00
TreeHugger Robot
815aa66d3c Merge "Update some docs & tweak some method names" 2018-10-27 00:24:59 +00:00
John Reck
c7ddcf390f Update some docs & tweak some method names
Test: builds
Change-Id: Id0e5cf6fdb3a391136a1d314498f75e0b954ceeb
2018-10-26 13:57:12 -07:00
John Reck
c59e7dd6ad Merge "Clarify createScaledBitmap's 'filter' docs" am: e0f6d84ba1 am: 324cb8c075
am: c2eaf48e42

Change-Id: Id0a228f273f83b238ba1df92a78b7a0da66c4209
2018-10-25 18:17:28 -07:00
John Reck
a2d20b447a Add theme & View API to control force-dark
Bug: 102591313
Test: CTS android.uirendering.cts.testclasses.ForceDarkTests

Change-Id: I6ba129681aed8e2f3f1b1ac60d458bb5f5393e9b
2018-10-24 10:17:20 -07:00
John Reck
8884cfc13e Merge "Rename & package shuffle" 2018-10-23 20:02:00 +00:00
John Reck
7ba6f430f6 Clarify createScaledBitmap's 'filter' docs
Reddit complained the docs were bad, so make the docs less bad.

Test: none
Change-Id: I61928ea859af4ce0a63a9b545ea1b6dd965cc3df
2018-10-22 13:24:48 -07:00
John Reck
32f140aa67 Rename & package shuffle
Rename DisplayListCanvas -> RecordingCanvas
Move RecordingCanvas to android.graphics
Move RenderNode to android.graphics

Bug: 112709971
Test: make & boot
Change-Id: Iddeb6a89f8923ea81a1f37bbee4e9b1db8ede238
2018-10-04 16:18:12 -07:00
renn
b2e9f5244b Add HardwareBuffer support to Bitmaps
This adds a new public constructor to Bitmap to allow passing in
a HardwareBuffer to back the Bitmap. Currently, the format of the
HardwareBuffer must be RGBA_8888.

One-Pager: https://docs.google.com/document/d/1n72X-gJZhjeajp4FIQwsGPKFiHBSeWYjC6fkXYe_bS0/edit?usp=sharing
Bug: 116713113
Test: manual - ran CTS tests
Change-Id: Ic437825138eafea526326e6cf300f116867ba29e
2018-10-04 17:15:10 +00:00
John Reck
1423e1331f Create plumbing for disabling force-dark
Test: sysui's rounded corners are no longer white
Bug: 102591313

Change-Id: Id99ae38c354cef06b94a5fb79b5b1a9a216a514c
2018-09-24 09:34:18 -07:00
Mathew Inwood
1ddeb9e01f resolve merge conflicts of 95f8ca9f74 to stage-aosp-master
Bug: None
Test: I solemnly swear I tested this conflict resolution.
Merged-In: I7fc1162d2c63df8751a4660607e8ce72070efed8
Change-Id: I0e5a5d8fda273644e8c592ce7d059e508870085e
2018-08-02 14:24:12 +00:00
Mathew Inwood
9ebe36c305 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
Merged-In: I7fc1162d2c63df8751a4660607e8ce72070efed8
Change-Id: I5d7739d2d1fc7bb12ee059bcc2a9ac9017ca35fb
2018-07-31 14:36:52 +01: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
John Reck
93e87cf197 Merge "Ensure picture isn't recording in createBitmap" into pi-dev am: c4f520ddb6
am: 39636318ca

Change-Id: If964e798cf39c03cb6d2232d103dbd7bf4941d5a
2018-06-01 16:02:30 -07:00
John Reck
44fc6317f1 Ensure picture isn't recording in createBitmap
Picture#draw() will silently due an #endRecording() if it
wasn't called. Bitmap.createBitmap doesn't do this until
after it's too late.

So do an up-front #endRecording() to ensure state is
good to go

Bug: 80539264
Test: HardwareBitmapTests#testReadbackThroughPictureNoEndRecording
Change-Id: Ic66c41462e88880b73c5093d7541c4ce3d71adeb
2018-06-01 12:55:13 -07: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
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
TreeHugger Robot
c45c2d65a5 Merge "Work around incorrect Skia gamma" into pi-dev 2018-03-19 22:10:31 +00:00
Derek Sollenberger
186ea1218e Document the byte packing order of the current Bitmap.Configs
This CL documents the byte order for 585, 8888, and fp16 buffers.

Test: documenting existing behavior
Bug: 71518511
Change-Id: I128344db318eb4597b6eb00f0ae317e369145152
2018-03-14 13:29:22 -04:00
Leon Scroggins III
ce89a6e656 Work around incorrect Skia gamma
Bug: 74408046
Test: Ic6acdc4a1a16840ec6ad9b13b4926c643d0f81ae

Skia incorrectly sets the gamma for LINEAR_EXTENDED_SRGB to 0 as a
misguided optimization attempt. As a result, a HARDWARE Bitmap which
natively has this color space does not match it properly. (Note that we
already catch an F16 Bitmap, above.) Add a workaround in
Bitmap.getColorSpace() to check for the color space explicitly.

Change-Id: Id595e365d1c8d572cfcea214d230a8ce1decdc01
2018-03-13 15:39:39 -04:00
Chris Craik
716f38177e Support recording HW Bitmaps in Picture
Bug: 34881007
Test: bit CtsGraphicsTestCases:*
Test: bit CtsUiRenderingTestCases:.testclasses.HardwareBitmapTests

Change-Id: Ic751c356682ea3db17a1b031ec46106a1a2ab918
2018-02-01 10:35:42 -08:00
John Reck
5d3501172c Add missing annotations
Bug: 67608144
Test: make offline-sdk-docs verified docstring shows up
Change-Id: I22bcfcc58888fa2d4c479e4687afb2fabd5b2f71
2017-10-11 10:47:12 -07:00
Makoto Onuki
1480b67635 Better preload drawable logging
Bug 63136392
Test: Manual test

Change-Id: I8753b36f632cf2ff57a5ef28df29f3fc5657f607
2017-07-14 11:40:29 -07:00
Chris Craik
b1d2f0a1d0 Update Bitmap#prepareToDraw doc
Fixes: 38132750
Test: none

Change-Id: I95d4617c08c1aab23c322ec40ae15462766db3ba
2017-05-10 16:38:50 -07:00
sergeyv
e1fc36d197 Fix npe due to strict mode in Bitmap.sameAs
bug:38164234
Test: none
Change-Id: Ib267d1b06f86980202693fc1c330f73ed06411b0
2017-05-09 16:36:09 -07:00
sergeyv
9fd259c9b0 Add StrictMode.noteSlowCall to calls that result in hw bitmap readback
bug:37748500
Test: BitmapTest:*inStrictMode
Change-Id: Ifea1c6f0c50ba2f409c96b7ccf7eb31c89ef81c8
2017-05-03 17:41:33 -07:00
Romain Guy
08587d45b1 Set the color space as nullptr on native bitmaps when sRGB is requested
This regression is a fallout from the recent API council feedback
fallout. The default color space used to be always set to null but
it's now the named SRGB instance. This change passes null to native
when the specified color space is known to be sRGB.

Bug: 37496760
Test: runtest managed-provisioning
Change-Id: Ie933c84e429a682a58ee253b57b77bd61b88ee5e
2017-04-19 11:58:05 -07:00
Romain Guy
1fa9d86ea4 Change nullability of colorspace parameter
Bug: 37323693
Test: android.graphics.cts.BitmapColorSpaceTest
Change-Id: I705ac18e5c64c028c2e8366a18ec4ef20f44a630
2017-04-18 14:06:49 -07:00
Romain Guy
7c42e16eb0 Clarify doc for Bitmap.createBitmap()
Bug: 37323693
Test: compiles
Change-Id: I8cf316cf4c67b69c47c67848c576af6399a0111f
2017-04-13 20:48:29 -07:00
Romain Guy
8242656f49 Color management, the missing pieces
Implement missing color management pieces for bitmaps:

- Bitmap.createBitmap(Bitmap src, ...) now creates a bitmap
  in the same color space as the source bitmap
- Bitmap.createScaledBitmap() now creates a bitmap in the
  same color space as the source bitmap
- Bitmap.createBitmap(..., ColorSpace colorSpace) to create
  bitmaps in a specific color space
- Fix copy from A8 to F16
- Copying bitmaps in F16 or with a color space does not work,
  it's currently a limitation in Skia

Bug: 36905374
Test: BitmapColorSpaceTest
Change-Id: I0092fe4432511db50daa3a9393389a9db05e0c2a
2017-04-07 07:56:14 -07:00
Derek Sollenberger
29cd3e9226 Modify createBitmap w/ crop and matrix to not rely on Canvas.setBitmap
Test: CtsGraphicsTestCases BitmapTest
Bug: 36218535
Change-Id: I972f3ed6d037f6cae7a36fd2e612df9ab40a8b2d
2017-03-15 11:28:50 -04:00
Romain Guy
ce217faddb Make Bitmap.get/setPixel[s] color space aware
Bug: 32984164
Test: cts-tradefed run singleCommand cts-dev --module CtsGraphicsTestCases --test android.graphics.cts.BitmapColorSpaceTest
Change-Id: Iee8c4abb264f0d2a44bae59788fbf4dcb2d0fdf7
2017-03-08 16:45:20 -08:00
Romain Guy
5acc476878 Write Bitmap's color space in parcel
This change also resets the cached color space field in Bitmap.java
when reconfigure() is called or when a bitmap is reused by the
bitmap factory.

Bug: 32072280
Test: CtsGraphicsTestCases.BitmapColorSpaceTest
Change-Id: I232b729b7a29e65bfff21dc749570c3c80adf855
2017-03-07 15:41:07 -08:00
Romain Guy
efb4b06493 Add ColorSpace information on Bitmap
This is the first step toward interpreting color spaces at render time.

Bug: 32984164
Test: BitmapColorSpaceTest in CtsGraphicsTestCases

Change-Id: I0164a18f1ed74a745874fe5229168042afe27a04
2017-03-06 19:33:25 -08:00
sergeyv
6e3658a638 Hidden method to get a graphic buffer from a hardware bitmap
Test: locally tested Bitmap.getGraphicBuffer()
bug:30999911
Change-Id: I68d56d769045bada6a5db90ed884a570c49be4fd
2017-01-05 17:03:48 -08:00
sergeyv
0a0f23163a Move GraphicBuffer to graphics package
Test: locally tested Bitmap.createHardwareBitmap method
bug: 30999911
Change-Id: Iad432577f26f2362ede9e77cd8a5425c010692e5
2017-01-04 14:01:52 -08:00
sergeyv
980bead518 Prohibit copyPixelsToBuffer & copyPixelsFromBuffer
Test: BitmapTest#testHardwareCopyPixels(From|To)Buffer
bug:30999911
Change-Id: I3bfa2846bff574bc0bfd54674eac794d1a6a0ff9
2017-01-03 15:54:57 -08:00
sergeyv
81f97ee47c HardwareBitmaps: support createBitmap methods that return immutable bitmap
Test: testCreateScaledBitmap, testCreateTransformedBitmap, testCreateSubsetBitmap in HardwareBitmapTests
bug:30999911
Change-Id: Ic128dfed78b18ad6f12dad50023ee7c2f5bfa4ad
2017-01-03 15:53:03 -08:00
Sergei Vasilinetc
99418fb205 Merge "Throw exception if getPixel(s) is called on a hardware bitmap" 2016-12-20 18:56:31 +00:00
Sergei Vasilinetc
3029730399 Merge "Add docs about Config.HARDWARE in Bitmap.writeToParcel method" 2016-12-20 18:55:21 +00:00
sergeyv
57eafc6f90 Throw exception if getPixel(s) is called on a hardware bitmap
Test: android.graphics.cts.BitmapTest#testHardwareGetPixel
bug:30999911
Change-Id: Ifa5a80d048c44c91122e9e7c79ca3ef9ecab963e
2016-12-19 11:52:06 -08:00
sergeyv
f161dce70e Add docs about Config.HARDWARE in Bitmap.writeToParcel method
Test: android.graphics.cts.BitmapTest#testWriteHwBitmapToParcel
bug:30999911
Change-Id: I5282df7d881d76f3e78979a2e5d3777f78673a5d
2016-12-19 10:56:27 -08:00
Sergei Vasilinetc
8b6fe1d894 Merge "Support Bitmap.copy for hardware bitmaps" 2016-12-19 18:41:21 +00:00
sergeyv
05126d151e Support Bitmap.copy for hardware bitmaps
Test: android.uirendering.cts.testclasses.HardwareBitmapTests#testBitmapConfig*
bug:30999911
Change-Id: I2e80dff914bfa0666290701072ac93d30d218e8d
2016-12-16 17:46:10 -08:00
Romain Guy
9505a65527 Add new RGBA_F16 bitmap config
This configuration uses 64 bits per pixel. Heach component is stored as a
half precision float value (16 bits). Half floats can be decoded/encoded
using android.util.Half.

RGBA_F16 bitmaps are used to decode wide-gamut images stored in 16 bit
formats (PNG 16 bit for instance). aapt is currently not aware of PNG
16 bits so such files must be placed in raw/ resource directories.

This first pass provides only partial drawing support with hardware
acceleration. RGBA_F16 bitmaps are stored in linear space and need
to be encoded to gamma space with the appropriate OETF to be rendered
properly on Android's current surfaces. They are however suitable for
linear blending. Full rendering support will be provided in a future
CL (BitmapShaders might be a bit tricky to handle properly during
shader generation).

Bug: 32984164
Test: bit CtsGraphicsTestCases:android.graphics.cts.BitmapRGBAF16Test

Change-Id: I328e6b567441a1b9d152a3e7be944a2cf63193bd
2016-12-16 09:15:07 -08:00
sergeyv
9fbb0b5ab3 Prohibit Config.HARDWARE in factory methods, that create mutable bitmaps
Test: android.cts.graphics.BitmapTest#testCreateMutableBitmapWithHardwareConfig
bug:30999911
Change-Id: I7cd4e2625563b6659613ccd180a57c56dcf7c2b1
2016-12-12 17:46:59 -08:00
sergeyv
da6c8ffcc5 Introduce Bitmap.Config.Hardware with @hide annotation
Test: HardwareBitmapTests
bug:30999911
Change-Id: Iaa0e18842704cb6bcd483c63a095dcb22baaf5e0
2016-11-22 18:28:54 -08:00
John Reck
3bdecbf0fd return 0 for allocation size if recycled
Change-Id: Ic471701faf026411938ebe87131533a8ef09bbd7
Fixes: 19804653
Test: none
2016-11-14 11:28:17 -08:00
John Reck
9192d5e8d7 Remove unused method
Test: builds

Change-Id: I8ad660f083a57f30db5ed0e2fe777286720033ca
2016-10-31 10:44:12 -07:00
John Reck
caa08ff5e9 The bigger update to Canvas
All draw* calls in Canvas are regular JNI
All draw* calls in DisplayListCanvas are FastNative
Unifies Canvas JNI on nMethodName naming

CanvasPerf results before:
INSTRUMENTATION_STATUS: basicViewGroupDraw_min=12492
INSTRUMENTATION_STATUS: recordSimpleBitmapView_min=13912

and after:
INSTRUMENTATION_STATUS: basicViewGroupDraw_min=11945
INSTRUMENTATION_STATUS: recordSimpleBitmapView_min=13318

Test: refactor, makes & boots
Change-Id: I06000df1d125e17d60c6498865be7a7638a4a13e
2016-10-17 11:33:28 -07:00