[SurfaceFlinger] Move Transform to libs/ui
A bunch of code in SurfaceFlinger uses Transform, so does RenderEngine. In
order to move RenderEngine to its own library, we need to lift Transform to
another place where it's part of VNDK. Since Transform depends on libs/ui, we
move Transform to libs/ui as well.
BUG: 112585051
Test: Build, flash, boot and check transformation.
Change-Id: Ie4d13ee135ba3f71fcbd9f86994a0b048e2c6878
diff --git a/services/surfaceflinger/RenderArea.cpp b/services/surfaceflinger/RenderArea.cpp
index 1a8edf3..7f69ce4 100644
--- a/services/surfaceflinger/RenderArea.cpp
+++ b/services/surfaceflinger/RenderArea.cpp
@@ -4,6 +4,27 @@
namespace android {
+ui::Transform::orientation_flags fromRotation(ISurfaceComposer::Rotation rotation) {
+ switch (rotation) {
+ case ISurfaceComposer::eRotateNone:
+ return ui::Transform::ROT_0;
+ case ISurfaceComposer::eRotate90:
+ return ui::Transform::ROT_90;
+ case ISurfaceComposer::eRotate180:
+ return ui::Transform::ROT_180;
+ case ISurfaceComposer::eRotate270:
+ return ui::Transform::ROT_270;
+ }
+ ALOGE("Invalid rotation passed to captureScreen(): %d\n", rotation);
+ return ui::Transform::ROT_0;
+}
+
+RenderArea::RenderArea(uint32_t reqHeight, uint32_t reqWidth, CaptureFill captureFill,
+ ISurfaceComposer::Rotation rotation)
+ : mReqHeight(reqHeight), mReqWidth(reqWidth), mCaptureFill(captureFill) {
+ mRotationFlags = fromRotation(rotation);
+}
+
float RenderArea::getCaptureFillValue(CaptureFill captureFill) {
switch(captureFill) {
case CaptureFill::CLEAR:
@@ -23,7 +44,7 @@
uint32_t width = getWidth();
uint32_t height = getHeight();
- if (mRotationFlags & Transform::ROT_90) {
+ if (mRotationFlags & ui::Transform::ROT_90) {
std::swap(width, height);
}