chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 3 | #include <ui/GraphicTypes.h> |
Peiyong Lin | efefaac | 2018-08-17 12:27:51 -0700 | [diff] [blame] | 4 | #include <ui/Transform.h> |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 5 | |
Robert Carr | 578038f | 2018-03-09 12:25:24 -0800 | [diff] [blame] | 6 | #include <functional> |
Melody Hsu | 50c151a | 2024-05-14 06:11:12 +0000 | [diff] [blame] | 7 | |
| 8 | #include "FrontEnd/LayerSnapshot.h" |
Robert Carr | 12a3b9b | 2022-03-10 09:55:29 -0800 | [diff] [blame] | 9 | #include "Layer.h" |
Robert Carr | 578038f | 2018-03-09 12:25:24 -0800 | [diff] [blame] | 10 | |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 11 | namespace android { |
| 12 | |
Lloyd Pique | 37c2c9b | 2018-12-04 17:25:10 -0800 | [diff] [blame] | 13 | class DisplayDevice; |
| 14 | |
Chia-I Wu | b68fac7 | 2018-08-23 12:05:27 -0700 | [diff] [blame] | 15 | // RenderArea describes a rectangular area that layers can be rendered to. |
| 16 | // |
| 17 | // There is a logical render area and a physical render area. When a layer is |
| 18 | // rendered to the render area, it is first transformed and clipped to the logical |
| 19 | // render area. The transformed and clipped layer is then projected onto the |
| 20 | // physical render area. |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 21 | class RenderArea { |
| 22 | public: |
chaviw | 50da504 | 2018-04-09 13:49:37 -0700 | [diff] [blame] | 23 | enum class CaptureFill {CLEAR, OPAQUE}; |
Vishnu Nair | 871886e | 2024-06-26 17:17:51 -0700 | [diff] [blame] | 24 | enum class Options { |
| 25 | // If not set, the secure layer would be blacked out or skipped |
| 26 | // when rendered to an insecure render area |
| 27 | CAPTURE_SECURE_LAYERS = 1 << 0, |
chaviw | 50da504 | 2018-04-09 13:49:37 -0700 | [diff] [blame] | 28 | |
Vishnu Nair | 871886e | 2024-06-26 17:17:51 -0700 | [diff] [blame] | 29 | // If set, the render result may be used for system animations |
| 30 | // that must preserve the exact colors of the display |
| 31 | HINT_FOR_SEAMLESS_TRANSITION = 1 << 1, |
| 32 | }; |
chaviw | 50da504 | 2018-04-09 13:49:37 -0700 | [diff] [blame] | 33 | static float getCaptureFillValue(CaptureFill captureFill); |
| 34 | |
Marin Shalamanov | 1c43429 | 2020-06-12 01:47:29 +0200 | [diff] [blame] | 35 | RenderArea(ui::Size reqSize, CaptureFill captureFill, ui::Dataspace reqDataSpace, |
Vishnu Nair | 871886e | 2024-06-26 17:17:51 -0700 | [diff] [blame] | 36 | ftl::Flags<Options> options) |
| 37 | : mOptions(options), |
chaviw | 70cb6a4 | 2020-07-30 13:57:36 -0700 | [diff] [blame] | 38 | mReqSize(reqSize), |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 39 | mReqDataSpace(reqDataSpace), |
Vishnu Nair | 871886e | 2024-06-26 17:17:51 -0700 | [diff] [blame] | 40 | mCaptureFill(captureFill) {} |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 41 | |
| 42 | virtual ~RenderArea() = default; |
| 43 | |
Chia-I Wu | b68fac7 | 2018-08-23 12:05:27 -0700 | [diff] [blame] | 44 | // Returns true if the render area is secure. A secure layer should be |
| 45 | // blacked out / skipped when rendered to an insecure render area. |
| 46 | virtual bool isSecure() const = 0; |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 47 | |
Chia-I Wu | b68fac7 | 2018-08-23 12:05:27 -0700 | [diff] [blame] | 48 | // Returns the transform to be applied on layers to transform them into |
| 49 | // the logical render area. |
| 50 | virtual const ui::Transform& getTransform() const = 0; |
| 51 | |
Chia-I Wu | b68fac7 | 2018-08-23 12:05:27 -0700 | [diff] [blame] | 52 | // Returns the source crop of the render area. The source crop defines |
| 53 | // how layers are projected from the logical render area onto the physical |
| 54 | // render area. It can be larger than the logical render area. It can |
| 55 | // also be optionally rotated. |
| 56 | // |
Alec Mouri | 5a6d857 | 2020-03-23 23:56:15 -0700 | [diff] [blame] | 57 | // The source crop is specified in layer space (when rendering a layer and |
| 58 | // its children), or in layer-stack space (when rendering all layers visible |
| 59 | // on the display). |
Chia-I Wu | b68fac7 | 2018-08-23 12:05:27 -0700 | [diff] [blame] | 60 | virtual Rect getSourceCrop() const = 0; |
| 61 | |
Chia-I Wu | b68fac7 | 2018-08-23 12:05:27 -0700 | [diff] [blame] | 62 | // Returns the size of the physical render area. |
Marin Shalamanov | 1c43429 | 2020-06-12 01:47:29 +0200 | [diff] [blame] | 63 | int getReqWidth() const { return mReqSize.width; } |
| 64 | int getReqHeight() const { return mReqSize.height; } |
Chia-I Wu | b68fac7 | 2018-08-23 12:05:27 -0700 | [diff] [blame] | 65 | |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 66 | // Returns the composition data space of the render area. |
| 67 | ui::Dataspace getReqDataSpace() const { return mReqDataSpace; } |
| 68 | |
Chia-I Wu | b68fac7 | 2018-08-23 12:05:27 -0700 | [diff] [blame] | 69 | // Returns the fill color of the physical render area. Regions not |
| 70 | // covered by any rendered layer should be filled with this color. |
Dominik Laskowski | 718f960 | 2019-11-09 20:01:35 -0800 | [diff] [blame] | 71 | CaptureFill getCaptureFill() const { return mCaptureFill; } |
chaviw | 50da504 | 2018-04-09 13:49:37 -0700 | [diff] [blame] | 72 | |
Dominik Laskowski | 718f960 | 2019-11-09 20:01:35 -0800 | [diff] [blame] | 73 | virtual sp<const DisplayDevice> getDisplayDevice() const = 0; |
Lloyd Pique | 37c2c9b | 2018-12-04 17:25:10 -0800 | [diff] [blame] | 74 | |
Robert Carr | 12a3b9b | 2022-03-10 09:55:29 -0800 | [diff] [blame] | 75 | // If this is a LayerRenderArea, return the root layer of the |
| 76 | // capture operation. |
| 77 | virtual sp<Layer> getParentLayer() const { return nullptr; } |
| 78 | |
Melody Hsu | 50c151a | 2024-05-14 06:11:12 +0000 | [diff] [blame] | 79 | // If this is a LayerRenderArea, return the layer snapshot |
| 80 | // of the root layer of the capture operation |
| 81 | virtual const frontend::LayerSnapshot* getLayerSnapshot() const { return nullptr; } |
| 82 | |
Alec Mouri | 3e5965f | 2023-04-07 18:00:58 +0000 | [diff] [blame] | 83 | // Returns whether the render result may be used for system animations that |
| 84 | // must preserve the exact colors of the display. |
Vishnu Nair | 871886e | 2024-06-26 17:17:51 -0700 | [diff] [blame] | 85 | bool getHintForSeamlessTransition() const { |
| 86 | return mOptions.test(Options::HINT_FOR_SEAMLESS_TRANSITION); |
| 87 | } |
Alec Mouri | 3e5965f | 2023-04-07 18:00:58 +0000 | [diff] [blame] | 88 | |
chaviw | 70cb6a4 | 2020-07-30 13:57:36 -0700 | [diff] [blame] | 89 | protected: |
Vishnu Nair | 871886e | 2024-06-26 17:17:51 -0700 | [diff] [blame] | 90 | ftl::Flags<Options> mOptions; |
chaviw | 70cb6a4 | 2020-07-30 13:57:36 -0700 | [diff] [blame] | 91 | |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 92 | private: |
Marin Shalamanov | 1c43429 | 2020-06-12 01:47:29 +0200 | [diff] [blame] | 93 | const ui::Size mReqSize; |
Peiyong Lin | 0e003c9 | 2018-09-17 11:09:51 -0700 | [diff] [blame] | 94 | const ui::Dataspace mReqDataSpace; |
Chia-I Wu | c80dcbb | 2018-08-24 15:34:02 -0700 | [diff] [blame] | 95 | const CaptureFill mCaptureFill; |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 96 | }; |
| 97 | |
Chia-I Wu | 83ce7c1 | 2017-10-19 15:18:55 -0700 | [diff] [blame] | 98 | } // namespace android |