chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Peiyong Lin | efefaac | 2018-08-17 12:27:51 -0700 | [diff] [blame] | 3 | #include <gui/ISurfaceComposer.h> |
Peiyong Lin | fd997e0 | 2018-03-28 15:29:00 -0700 | [diff] [blame] | 4 | #include <ui/GraphicTypes.h> |
Peiyong Lin | efefaac | 2018-08-17 12:27:51 -0700 | [diff] [blame] | 5 | #include <ui/Transform.h> |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 6 | |
Robert Carr | 578038f | 2018-03-09 12:25:24 -0800 | [diff] [blame] | 7 | #include <functional> |
| 8 | |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 9 | namespace android { |
| 10 | |
Chia-I Wu | b68fac7 | 2018-08-23 12:05:27 -0700 | [diff] [blame^] | 11 | // RenderArea describes a rectangular area that layers can be rendered to. |
| 12 | // |
| 13 | // There is a logical render area and a physical render area. When a layer is |
| 14 | // rendered to the render area, it is first transformed and clipped to the logical |
| 15 | // render area. The transformed and clipped layer is then projected onto the |
| 16 | // physical render area. |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 17 | class RenderArea { |
| 18 | public: |
chaviw | 50da504 | 2018-04-09 13:49:37 -0700 | [diff] [blame] | 19 | enum class CaptureFill {CLEAR, OPAQUE}; |
| 20 | |
| 21 | static float getCaptureFillValue(CaptureFill captureFill); |
| 22 | |
| 23 | RenderArea(uint32_t reqHeight, uint32_t reqWidth, CaptureFill captureFill, |
Peiyong Lin | efefaac | 2018-08-17 12:27:51 -0700 | [diff] [blame] | 24 | ISurfaceComposer::Rotation rotation = ISurfaceComposer::eRotateNone); |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 25 | |
| 26 | virtual ~RenderArea() = default; |
| 27 | |
Chia-I Wu | b68fac7 | 2018-08-23 12:05:27 -0700 | [diff] [blame^] | 28 | // Invoke drawLayers to render layers into the render area. |
Robert Carr | 578038f | 2018-03-09 12:25:24 -0800 | [diff] [blame] | 29 | virtual void render(std::function<void()> drawLayers) { drawLayers(); } |
| 30 | |
Chia-I Wu | b68fac7 | 2018-08-23 12:05:27 -0700 | [diff] [blame^] | 31 | // Returns true if the render area is secure. A secure layer should be |
| 32 | // blacked out / skipped when rendered to an insecure render area. |
| 33 | virtual bool isSecure() const = 0; |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 34 | |
Chia-I Wu | b68fac7 | 2018-08-23 12:05:27 -0700 | [diff] [blame^] | 35 | // Returns true if the otherwise disabled layer filtering should be |
| 36 | // enabled when rendering to this render area. |
| 37 | virtual bool needsFiltering() const = 0; |
| 38 | |
| 39 | // Returns the transform to be applied on layers to transform them into |
| 40 | // the logical render area. |
| 41 | virtual const ui::Transform& getTransform() const = 0; |
| 42 | |
| 43 | // Returns the size of the logical render area. Layers are clipped to the |
| 44 | // logical render area. |
| 45 | virtual int getWidth() const = 0; |
| 46 | virtual int getHeight() const = 0; |
| 47 | virtual Rect getBounds() const = 0; |
| 48 | |
| 49 | // Returns the source crop of the render area. The source crop defines |
| 50 | // how layers are projected from the logical render area onto the physical |
| 51 | // render area. It can be larger than the logical render area. It can |
| 52 | // also be optionally rotated. |
| 53 | // |
| 54 | // Layers are first clipped to the source crop (in addition to being |
| 55 | // clipped to the logical render area already). The source crop and the |
| 56 | // layers are then rotated around the center of the source crop, and |
| 57 | // scaled to the physical render area linearly. |
| 58 | virtual Rect getSourceCrop() const = 0; |
| 59 | |
| 60 | // Returns the rotation of the source crop and the layers. |
| 61 | ui::Transform::orientation_flags getRotationFlags() const { return mRotationFlags; }; |
| 62 | |
| 63 | // Returns the size of the physical render area. |
| 64 | int getReqWidth() const { return mReqWidth; }; |
| 65 | int getReqHeight() const { return mReqHeight; }; |
| 66 | |
| 67 | // Returns the fill color of the physical render area. Regions not |
| 68 | // covered by any rendered layer should be filled with this color. |
chaviw | 50da504 | 2018-04-09 13:49:37 -0700 | [diff] [blame] | 69 | CaptureFill getCaptureFill() const { return mCaptureFill; }; |
| 70 | |
Chia-I Wu | b68fac7 | 2018-08-23 12:05:27 -0700 | [diff] [blame^] | 71 | status_t updateDimensions(int displayRotation); |
| 72 | |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 73 | private: |
| 74 | uint32_t mReqHeight; |
| 75 | uint32_t mReqWidth; |
Peiyong Lin | efefaac | 2018-08-17 12:27:51 -0700 | [diff] [blame] | 76 | ui::Transform::orientation_flags mRotationFlags; |
chaviw | 50da504 | 2018-04-09 13:49:37 -0700 | [diff] [blame] | 77 | CaptureFill mCaptureFill; |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 78 | }; |
| 79 | |
Chia-I Wu | 83ce7c1 | 2017-10-19 15:18:55 -0700 | [diff] [blame] | 80 | } // namespace android |