[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/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 0e88fa0..69dfc92 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1821,7 +1821,7 @@
Region dirtyRegion;
Vector<sp<Layer>> layersSortedByZ;
Vector<sp<Layer>> layersNeedingFences;
- const Transform& tr = display->getTransform();
+ const ui::Transform& tr = display->getTransform();
const Rect bounds = display->getBounds();
if (display->isPoweredOn()) {
computeVisibleRegions(display, dirtyRegion, opaqueRegion);
@@ -2639,7 +2639,7 @@
const bool translucent = !layer->isOpaque(s);
Rect bounds(layer->computeScreenBounds());
visibleRegion.set(bounds);
- Transform tr = layer->getTransform();
+ ui::Transform tr = layer->getTransform();
if (!visibleRegion.isEmpty()) {
// Remove the transparent area from the visible region
if (translucent) {
@@ -2656,7 +2656,7 @@
// compute the opaque region
const int32_t layerOrientation = tr.getOrientation();
if (layer->getAlpha() == 1.0f && !translucent &&
- ((layerOrientation & Transform::ROT_INVALID) == false)) {
+ ((layerOrientation & ui::Transform::ROT_INVALID) == false)) {
// the opaque region is the layer's footprint
opaqueRegion = visibleRegion;
}
@@ -2919,7 +2919,7 @@
*/
ALOGV("Rendering client layers");
- const Transform& displayTransform = display->getTransform();
+ const ui::Transform& displayTransform = display->getTransform();
bool firstLayer = true;
for (auto& layer : display->getVisibleLayersSortedByZ()) {
const Region clip(bounds.intersect(
@@ -4845,7 +4845,7 @@
mCrop(crop),
mFlinger(flinger),
mChildrenOnly(childrenOnly) {}
- const Transform& getTransform() const override { return mTransform; }
+ const ui::Transform& getTransform() const override { return mTransform; }
Rect getBounds() const override {
const Layer::State& layerState(mLayer->getDrawingState());
return Rect(mLayer->getActiveWidth(layerState), mLayer->getActiveHeight(layerState));
@@ -4897,7 +4897,7 @@
// In the "childrenOnly" case we reparent the children to a screenshot
// layer which has no properties set and which does not draw.
sp<ContainerLayer> screenshotParentLayer;
- Transform mTransform;
+ ui::Transform mTransform;
SurfaceFlinger* mFlinger;
const bool mChildrenOnly;
@@ -5051,17 +5051,17 @@
sourceCrop.setLeftTop(Point(0, 0));
sourceCrop.setRightBottom(Point(raWidth, raHeight));
} else if (mPrimaryDisplayOrientation != DisplayState::eOrientationDefault) {
- Transform tr;
+ ui::Transform tr;
uint32_t flags = 0x00;
switch (mPrimaryDisplayOrientation) {
case DisplayState::eOrientation90:
- flags = Transform::ROT_90;
+ flags = ui::Transform::ROT_90;
break;
case DisplayState::eOrientation180:
- flags = Transform::ROT_180;
+ flags = ui::Transform::ROT_180;
break;
case DisplayState::eOrientation270:
- flags = Transform::ROT_270;
+ flags = ui::Transform::ROT_270;
break;
}
tr.set(flags, raWidth, raHeight);
@@ -5089,7 +5089,7 @@
// make sure to clear all GL error flags
engine.checkErrors();
- Transform::orientation_flags rotation = renderArea.getRotationFlags();
+ ui::Transform::orientation_flags rotation = renderArea.getRotationFlags();
if (mPrimaryDisplayOrientation != DisplayState::eOrientationDefault) {
// convert hw orientation into flag presentation
// here inverse transform needed
@@ -5097,26 +5097,26 @@
uint8_t hw_flip_hv = 0x00;
switch (mPrimaryDisplayOrientation) {
case DisplayState::eOrientation90:
- hw_rot_90 = Transform::ROT_90;
- hw_flip_hv = Transform::ROT_180;
+ hw_rot_90 = ui::Transform::ROT_90;
+ hw_flip_hv = ui::Transform::ROT_180;
break;
case DisplayState::eOrientation180:
- hw_flip_hv = Transform::ROT_180;
+ hw_flip_hv = ui::Transform::ROT_180;
break;
case DisplayState::eOrientation270:
- hw_rot_90 = Transform::ROT_90;
+ hw_rot_90 = ui::Transform::ROT_90;
break;
}
// transform flags operation
// 1) flip H V if both have ROT_90 flag
// 2) XOR these flags
- uint8_t rotation_rot_90 = rotation & Transform::ROT_90;
- uint8_t rotation_flip_hv = rotation & Transform::ROT_180;
+ uint8_t rotation_rot_90 = rotation & ui::Transform::ROT_90;
+ uint8_t rotation_flip_hv = rotation & ui::Transform::ROT_180;
if (rotation_rot_90 & hw_rot_90) {
- rotation_flip_hv = (~rotation_flip_hv) & Transform::ROT_180;
+ rotation_flip_hv = (~rotation_flip_hv) & ui::Transform::ROT_180;
}
- rotation = static_cast<Transform::orientation_flags>
+ rotation = static_cast<ui::Transform::orientation_flags>
((rotation_rot_90 ^ hw_rot_90) | (rotation_flip_hv ^ hw_flip_hv));
}