blob: 9920f0ad47e033da93b567a7ffb3ad42e88574e2 [file] [log] [blame]
chaviwa76b2712017-09-20 12:02:26 -07001#pragma once
2
Peiyong Linefefaac2018-08-17 12:27:51 -07003#include <gui/ISurfaceComposer.h>
Peiyong Linfd997e02018-03-28 15:29:00 -07004#include <ui/GraphicTypes.h>
Peiyong Linefefaac2018-08-17 12:27:51 -07005#include <ui/Transform.h>
chaviwa76b2712017-09-20 12:02:26 -07006
Robert Carr578038f2018-03-09 12:25:24 -08007#include <functional>
8
chaviwa76b2712017-09-20 12:02:26 -07009namespace android {
10
Chia-I Wub68fac72018-08-23 12:05:27 -070011// 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.
chaviwa76b2712017-09-20 12:02:26 -070017class RenderArea {
18public:
chaviw50da5042018-04-09 13:49:37 -070019 enum class CaptureFill {CLEAR, OPAQUE};
20
21 static float getCaptureFillValue(CaptureFill captureFill);
22
23 RenderArea(uint32_t reqHeight, uint32_t reqWidth, CaptureFill captureFill,
Peiyong Linefefaac2018-08-17 12:27:51 -070024 ISurfaceComposer::Rotation rotation = ISurfaceComposer::eRotateNone);
chaviwa76b2712017-09-20 12:02:26 -070025
26 virtual ~RenderArea() = default;
27
Chia-I Wub68fac72018-08-23 12:05:27 -070028 // Invoke drawLayers to render layers into the render area.
Robert Carr578038f2018-03-09 12:25:24 -080029 virtual void render(std::function<void()> drawLayers) { drawLayers(); }
30
Chia-I Wub68fac72018-08-23 12:05:27 -070031 // 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;
chaviwa76b2712017-09-20 12:02:26 -070034
Chia-I Wub68fac72018-08-23 12:05:27 -070035 // 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.
chaviw50da5042018-04-09 13:49:37 -070069 CaptureFill getCaptureFill() const { return mCaptureFill; };
70
Chia-I Wub68fac72018-08-23 12:05:27 -070071 status_t updateDimensions(int displayRotation);
72
chaviwa76b2712017-09-20 12:02:26 -070073private:
74 uint32_t mReqHeight;
75 uint32_t mReqWidth;
Peiyong Linefefaac2018-08-17 12:27:51 -070076 ui::Transform::orientation_flags mRotationFlags;
chaviw50da5042018-04-09 13:49:37 -070077 CaptureFill mCaptureFill;
chaviwa76b2712017-09-20 12:02:26 -070078};
79
Chia-I Wu83ce7c12017-10-19 15:18:55 -070080} // namespace android