summaryrefslogtreecommitdiff
path: root/libs/hwui/Readback.cpp
AgeCommit message (Collapse)Author
2024-07-29Use ro.hw_timeout_multiplier in Readback deadline Jason Macnak
... to give SwiftShader some more time to complete. Bug: b/354222246 Test: CtsUiRenderingTestCases x100 Change-Id: I943249a84daa873508bddcfc532048ef71eb4129
2023-05-18[base] Migrate SkSurface creation to SkSurfaces factories Kevin Lubick
Follow-up to http://review.skia.org/687639 Change-Id: I37ed05e68fa8d8edcad55e7700aca67e371f512d
2023-03-27Migrate SkImage static methods to SkImages namespace Kevin Lubick
Will need to land after https://skia-review.googlesource.com/c/skia/+/648297 lands and rolls Change-Id: Ie2ecb8f74dd52fcdd35e7cf9c311e8ed94781a07 Bug: skbug.com/13983
2023-01-11[base] SkBudgeted -> skgpu::Budgeted Kevin Lubick
Follow-up from https://skia-review.googlesource.com/c/skia/+/621977 Change-Id: I2a381a325c5c0c50f0d27e9d06210bb6be878919 Bug: skbug.com/13983
2022-12-01Tonemap everywhere in PixelCopy Alec Mouri
* Hookup tonemap support for PixelCopying a SurfaceView * Fix issue in PixelCopying a SurfaceView where the wrong dataspace was retrieved from the last queued buffer, since the bufferqueue dataspace may drift due to another process like camera setting the dataspace without being propagated to the app process * Cleanup LayerDrawable to share code Bug: 238395777 Test: Switching HDR cameras doesn't color shift Test: TextureView playback in Photos Change-Id: I0fd1bd86410630acfbb7de72339874a3d0ecac58
2022-08-04Allow PixelCopy for a window from any View John Reck
Also make it actually async, and allow the bitmap to be auto-allocated Bug: 195673633 Test: PixelCopyTest CTS suite Change-Id: Ie872f20c809eaaeb8dc32f3ec6347f21a9a7bc1a
2022-07-06Merge "PixelCopy: align with legacy GLConsumer::computeTransformMatrix" am: ↵ Treehugger Robot
178f91656b am: 031b2963f1 am: ab99d914c5 am: 4ee48e14af am: 79f7066a46 Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2144501 Change-Id: I4ea6a13d0205b8c6d9f46ea74c7776584bcd5dcd Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-06Merge "PixelCopy: align with legacy GLConsumer::computeTransformMatrix" am: ↵ Treehugger Robot
178f91656b Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2144501 Change-Id: I3c69c59a9124d407562b7e9fddb78a9d4b1300ec Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-03PixelCopy: align with legacy GLConsumer::computeTransformMatrix Yiwei Zhang
Chroma channels of YUV420 images are subsampled we may need to shrink the crop region by a whole texel on each side. Since skia still adds its own 0.5 inset, we apply an additional 0.5 inset. See GLConsumer::computeTransformMatrix for details. Bug: 204725913 Test: android.media.cts.DecodeAccuracyTest Test: android.view.cts.PixelCopyTest Change-Id: I38bd3d1e5f4c62fff3dd0374c3f2500f1a2d90b9
2022-03-04Fix transitive dependencies on SkImageEncoder Kevin Lubick
In https://skia-review.googlesource.com/c/skia/+/512416, we would like to decouple SkImage and SkImageEncoder. This CL was created by searching for use of these objects: - SkEncodedImageFormat - SkStream - SkData - SkBitmap - SkPixmap and making sure those files followed the Include What You Use (IWYU) guidelines. Signed-off-by: Kevin Lubick <kjlubick@google.com> Change-Id: I8edbcd1c9a526b8084d7e2c023895d1ad2f8c9b1
2022-01-27Merge "Revert "CTS of CtsMediaTestCases#android.media.cts.DecodeAccuracyTest ↵ Treehugger Robot
may fail when video is cropped."" am: fbc849e9d8 am: 423a67e7aa am: 611cfb5d99 am: c736d8d0d5 Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1959133 Change-Id: I31e6dcc0f08c151de7ee6df1ce914e22db5cf682
2022-01-27Merge "Revert "CTS of CtsMediaTestCases#android.media.cts.DecodeAccuracyTest ↵ Treehugger Robot
may fail when video is cropped.""
2022-01-25Revert "CTS of CtsMediaTestCases#android.media.cts.DecodeAccuracyTest may ↵ Hung-ying Tyan
fail when video is cropped." This reverts commit b48d4d10abfd1af41d8226939f12b6af5e243dff. Reason for revert: the original CL caused regression on many devices. Bug: 206079174 Bug: 207083066 Bug: 192912975 Bug: 208373431 Bug: 209522191 Bug: 208140353 Bug: 208741105 Bug: 211528580 Bug: 211837929 Bug: 211566842 Change-Id: I65206c683f1f067365a4993fa8d2dbd3cffc17cb
2021-10-04Merge "CTS of CtsMediaTestCases#android.media.cts.DecodeAccuracyTest may ↵ John Reck
fail when video is cropped. When we use GPU to copy the data, rendering would choose filter. But we need add shrink in border to ensure the sampler not reach border like what GUI does." am: 06e16941d5 am: 44bfae1759 am: b0838b910c am: ab55cd0ae8 am: 9a38d4f4d4 Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1801770 Change-Id: I598a9da169a6157bf6bb69a546a445cd9f6de626
2021-10-04Merge "CTS of CtsMediaTestCases#android.media.cts.DecodeAccuracyTest may ↵ John Reck
fail when video is cropped. When we use GPU to copy the data, rendering would choose filter. But we need add shrink in border to ensure the sampler not reach border like what GUI does." am: 06e16941d5 Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1801770 Change-Id: I1e34d4b25af83a4761e7a2fc81bf5b79d7b2aa08
2021-10-01CTS of CtsMediaTestCases#android.media.cts.DecodeAccuracyTest may fail when ↵ John Reck
video is cropped. When we use GPU to copy the data, rendering would choose filter. But we need add shrink in border to ensure the sampler not reach border like what GUI does. Change-Id: I2c59956f3d7a7052d8e4bee587360f252a6c5549 Signed-off-by: Chun Jiang <chun.jiang@mediatek.com> Bug: 197180327 Test: CTS PixelCopyTests & DecodeAccuracyTest
2021-08-17Added crop rect and removed inverse of the texture matrix. ramindani
BUG=152621633 Test: Verified manually and with atest TextureViewCameraTest atest TextureViewTest atest TextureViewSnapshotTest atest TextureViewStressTest atest PixelCopyTest atest BitmapTest atest HardwareBitmapTests Change-Id: Ie993a18fd3511576617a1eb859bf228c33d12f78
2021-08-06Revert "Added crop rect to LayerDrawable to not crop TextureView..." bsears
Revert "Adds out parameters for crop rectangle and transform" Revert "Add test to crop TextureView and verify if outer edge ha..." Revert submission 15339442-1texelcrop Reason for revert: Bisection identified these CLs as the likely cause of Droidfood blocking bugs b/195620803 and b/195637414 Bug: 195637414 Bug: 195620803 Reverted Changes: If1f448a94:Added crop rect to LayerDrawable to not crop Textu... Iefde6bdf7:Add test to crop TextureView and verify if outer e... Icf0ee20e8:Adds out parameters for crop rectangle and transfo... Change-Id: I3448ebe193f25de79d186ae705911d99da2cef2b
2021-08-03Added crop rect to LayerDrawable to not crop TextureView. ramindani
Verified manually with ExoPlayer that TextureView isn't cropping. Test: Did the manual test and atest TextureViewCameraTest atest TextureViewSnapshotTest atest TextureViewStressTest atest TextureViewTest atest PixelCopyTest atest BitmapTest atest HardwareBitmapTests and with HwAccelerationTest Added crop test at ag/15430851 BUG=152621633 Change-Id: If1f448a94908cbf51272bc0d1bbbe1e113fd15f3
2021-07-15Avoid sampling outside BQ crop rect John Reck
The region outside of the BQ crop rect is potentially garbage. Avoid sampling from it. Fixes: 189656466 Bug: 193378020 Test: CTS PixelCopyTests & DecodeAccuracyTest Change-Id: I2910d93471f08aaf807ac9f87fdf84cf29cf4143 Merged-In: I2910d93471f08aaf807ac9f87fdf84cf29cf4143
2021-07-14Avoid sampling outside BQ crop rect John Reck
The region outside of the BQ crop rect is potentially garbage. Avoid sampling from it. Fixes: 189656466 Test: CTS PixelCopyTests & DecodeAccuracyTest Change-Id: I2910d93471f08aaf807ac9f87fdf84cf29cf4143
2021-06-11Improve picture capture debug path John Reck
* Fixes hardware bitmap capture * Fixes mutable bitmap capture (no flickering) * Adds basic single-frame LRU cache to avoid repeated readbacks of GPU resources * Does up-front readback of GPU resources * Moves serialization off RenderThread again thanks to up-front readback avoiding needing GPU access off-thread * Reduces RAM usage & improves performance by serializing directly to output stream instead of first copying to a byte[] Bug: 174223722 Test: PictureCaptureDemo mirrors the content Change-Id: If7ec208b61d5b917e82087cc312880fc5a38c943
2021-06-09Fix PixelCopy & BQ crop John Reck
Change Surface to return the original crop rect + transform int instead of a matrix in GL's bottom-left origin in 0..1 space. This avoids doing an extreme amount of matrix pulling apart to try and guess at the inputs and map rects around to make it maybe work sometimes along with avoiding the need to convert that matrix into skia's top-left non-unit space. This also opens the door to avoiding the 1 texel crop problem if ASurfaceTexture is similarly adjusted to return the crop+transform instead of a float[16] matrix as we are using a proper srcRect to sample from instead of purely done via matrix manipulation. This CL continues to pass kFast_SrcRectConstraint so we don't actually benefit but it at least COULD. Fixes: 183553027 Test: atest android.view.cts.PixelCopyTest (+new testBufferQueueCrop) Change-Id: I5f638153baed7f67dc43fe9ecb4587f579222b5d Merged-In: I5f638153baed7f67dc43fe9ecb4587f579222b5d
2021-05-22Use TraceUtils.h from gui shared library. rnlee
Test: It makes Bug: 183120308 Change-Id: I331262dd2da59817031f0c708f4c102041dcb5e0
2021-05-18Fix PixelCopy & BQ crop John Reck
Change Surface to return the original crop rect + transform int instead of a matrix in GL's bottom-left origin in 0..1 space. This avoids doing an extreme amount of matrix pulling apart to try and guess at the inputs and map rects around to make it maybe work sometimes along with avoiding the need to convert that matrix into skia's top-left non-unit space. This also opens the door to avoiding the 1 texel crop problem if ASurfaceTexture is similarly adjusted to return the crop+transform instead of a float[16] matrix as we are using a proper srcRect to sample from instead of purely done via matrix manipulation. This CL continues to pass kFast_SrcRectConstraint so we don't actually benefit but it at least COULD. Fixes: 183553027 Test: atest android.view.cts.PixelCopyTest (+new testBufferQueueCrop) Change-Id: I5f638153baed7f67dc43fe9ecb4587f579222b5d
2021-03-19Remove and update code that was addressing old SwiftShader workarounds. Derek Sollenberger
Bug: 183203135 Test: CtsUiRenderingTestCases w/ SwiftShader Change-Id: Ib61902d0e6cea691367bf1d9a4a0877ca0e60a91
2020-07-28Migrate from GrContext to GrDirectContext Adlai Holler
This is part of an effort to distinguish between different types of contexts in GPU Skia. When using a DeferredDisplayList (DDL) recorder, the context you get is not a direct context and cannot be used for operations like uploading or reading textures. Since Android does not use DDLs, it is not directly affected by this change but other APIs, such as SkImage::MakeFromTexture are being migrated to require a GrDirectContext to increase sanity. Change-Id: I9afbdf3c026a9f9cb6ad2aad904915e189e584d6
2020-03-10Merge "Let LayerDrawable choose the best scaling filter for readback." into ↵ Automerger Merge Worker
rvc-dev am: ee45de3115 am: 59f97c80a7 am: 2aca970fe9 am: ae8a59f7fc Change-Id: I90e1f657ef52870299f57005a0165b488a71be6f
2020-03-11Let LayerDrawable choose the best scaling filter for readback. Kazuhiro Inaba
The check used in Readback.cpp did not take the transformation matrix into account for judging whether the copy was scaling. libs/hwui/pipeline/skia/LayerDrawable.cpp already incorporates the logic to detect non-scaling copy, so we can just let it check the condition. This version regards 90-degree rotation without size change as non-scaling and disables filters. Bug: 151126720 Bug: 150839078 Test: atest android.view.cts.PixelCopyTest Change-Id: I69e987e6a2e48299c5e579f8c218c42a724dc606
2020-03-01[HWUI] remove libui from HWUI's dependencies Alec Mouri
Bug: 136263238 Test: builds Test: interact with device Change-Id: I18540f78a4ee5ffcc30c96ff7862480e1d8fe50a
2020-02-13[HWUI] use ANativeWindow_getLastQueuedBuffer api Alec Mouri
Bug: 137012798 Test: builds Change-Id: Ic33a21a73b0579726f47c53cc102fb91b5ead0d6
2019-03-29Add missing trace points John Reck
Test: traced opening recents Change-Id: I51675f1c49f27f1bfa5b18e3d3dd7162e58b1cb8
2019-03-18Merge "Remove old TaskManager system" John Reck
2019-03-18Remove old TaskManager system John Reck
Replace it with a newer, fancier, WorkQueue-inspired one that's just a global common thread pool. Test: hwuiunit passes Change-Id: Ib5d03104a08bbac9a4ec67a1bfc0db2b35d6700f
2019-03-11Remove unused include of SkToSRGBColorFilter.h Brian Osman
Change-Id: Ib4be68d9ab491fbb4eefc6103096823f9f72a7aa Test: Just deleting unused include. Code still builds.
2019-02-13Decouple VulkanManager from RenderThread Stan Iliev
This CL allows for more than one VulkanManager to exist. VulkanManager ctor are public allowing for classes other than RenderThread to instantiate it. Secondary VulkanManager can be used to render on a thread other than RT. Test: Ran HWUI unit tests and several apps Change-Id: Ibfd76c86ff67e01617a500902bba7431b928f5c0
2019-02-06Use kTopLeft_GrSurfaceOrigin when generating a GPU buffer for CPU readback. Derek Sollenberger
When attempting to read back a buffer from the GPU, Skia will perform a y-flip of the buffer in CPU memory if the buffer does not have a top-left origin. Test: CtsUiRenderingTestCases Bug: 119366261 Change-Id: I93ec93cc31209cbdd9b886b0d1020fda3aac646e
2018-11-07Set the color space to sRGB on the Surface and remove colorFilter. Derek Sollenberger
Also for a canvas wrapping a bitmap the colorspace of the bitmap will be used to correctly blend content. Test: CtsUiRenderingTestCases Bug: 111436479 Change-Id: I63ad7a30605a7f725cc0ef4716d42ea978fb03e3
2018-09-10Refactor HWUI readback code to be backend independent Stan Iliev
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
2016-11-16Support Surface and Layer Readback in the SkiaPipelines. Derek Sollenberger
Test: CTS TextureViewTests and UIRendering Change-Id: I2969c8f5a975bfd9aebcbb585c64d1fcbb2487c2
2016-10-26Add target to texture sergeyv
Test: refactoring cl. bug:32413624 Change-Id: I94b1c31cd4e0712dfcfd7777a0012424c1bf0dca
2016-10-11Linear blending, step 1 Romain Guy
NOTE: Linear blending is currently disabled in this CL as the feature is still a work in progress Android currently performs all blending (any kind of linear math on colors really) on gamma-encoded colors. Since Android assumes that the default color space is sRGB, all bitmaps and colors are encoded with the sRGB Opto-Electronic Conversion Function (OECF, which can be approximated with a power function). Since the power curve is not linear, our linear math is incorrect. The result is that we generate colors that tend to be too dark; this affects blending but also anti-aliasing, gradients, blurs, etc. The solution is to convert gamma-encoded colors back to linear space before doing any math on them, using the sRGB Electo-Optical Conversion Function (EOCF). This is achieved in different ways in different parts of the pipeline: - Using hardware conversions when sampling from OpenGL textures or writing into OpenGL frame buffers - Using software conversion functions, to translate app-supplied colors to and from sRGB - Using Skia's color spaces Any type of processing on colors must roughly ollow these steps: [sRGB input]->EOCF->[linear data]->[processing]->OECF->[sRGB output] For the sRGB color space, the conversion functions are defined as follows: OECF(linear) := linear <= 0.0031308 ? linear * 12.92 : (pow(linear, 1/2.4) * 1.055) - 0.055 EOCF(srgb) := srgb <= 0.04045 ? srgb / 12.92 : pow((srgb + 0.055) / 1.055, 2.4) The EOCF is simply the reciprocal of the OECF. While it is highly recommended to use the exact sRGB conversion functions everywhere possible, it is sometimes useful or beneficial to rely on approximations: - pow(x,2.2) and pow(x,1/2.2) - x^2 and sqrt(x) The latter is particularly useful in fragment shaders (for instance to apply dithering in sRGB space), especially if the sqrt() can be replaced with an inversesqrt(). Here is a fairly exhaustive list of modifications implemented in this CL: - Set TARGET_ENABLE_LINEAR_BLENDING := false in BoardConfig.mk to disable linear blending. This is only for GLES 2.0 GPUs with no hardware sRGB support. This flag is currently assumed to be false (see note above) - sRGB writes are disabled when entering a functor (WebView). This will need to be fixed at some point - Skia bitmaps are created with the sRGB color space - Bitmaps using a 565 config are expanded to 888 - Linear blending is disabled when entering a functor - External textures are not properly sampled (see below) - Gradients are interpolated in linear space - Texture-based dithering was replaced with analytical dithering - Dithering is done in the quantization color space, which is why we must do EOCF(OECF(color)+dither) - Text is now gamma corrected differently depending on the luminance of the source pixel. The asumption is that a bright pixel will be blended on a dark background and the other way around. The source alpha is gamma corrected to thicken dark on bright and thin bright on dark to match the intended design of fonts. This also matches the behavior of popular design/drawing applications - Removed the asset atlas. It did not contain anything useful and could not be sampled in sRGB without a yet-to-be-defined GL extension - The last column of color matrices is converted to linear space because its value are added to linear colors Missing features: - Resource qualifier? - Regeneration of goldeng images for automated tests - Handle alpha8/grey8 properly - Disable sRGB write for layers with external textures Test: Manual testing while work in progress Bug: 29940137 Change-Id: I6a07b15ab49b554377cd33a36b6d9971a15e9a0b
2016-09-07Add API to copy a window John Reck
Change-Id: I9bb5209010db6665be4b6f8db81a6fc1b7debc45
2016-09-01Fix EGLImage memory leak John Reck
bug: 31247709 Change-Id: Ifb3087a6e76d0d1304f55d13e468bafbd78418da
2016-07-07Unify readback Surface/TextureView copy mechanism Chris Craik
Removes last usage of old rendering pipeline. Change-Id: Ia920dec9cd726ca221e11e888562c7df39a9761e
2016-04-28Support transform'd GraphicBuffers John Reck
Bug: 28428955 Change-Id: I23e2fc9b96a67c7cfda42d9d7319e478194a7fa7
2016-04-26API tweaks to PixelCopy and make it public John Reck
Bug: 27708453 Change-Id: I81667ce42f9ca1c1a13e1e61299927900845fc84
2016-04-22PixelCopy fixes John Reck
Bug: 27708453 Fixes some issues with camera sources. Previously it was using GL_TEXTURE_2D target which doesn't work properly if the source is YUV. It is critical to ensure GL_TEXTURE_EXTERNAL_OES is used throughout so the right sampler is used. Change-Id: I0dcd8941ba08331f24809467b0e828663a38e93b
2016-04-11Framework-side of SurfaceView#getBitmap John Reck
Bug: 27708453 Change-Id: Ie6fd7eca522d3e6549d8af587c975fd7e6053649