surfaceflinger: remove ISurfaceComposer.h from RenderArea
RenderArea can be made more generic by removing ISurfaceComposer.h
dependency. The caller also prefers to work with
ui::Transform::orientation_flags than ISurfaceComposer::Rotation (we
want to move updateDimensions to the caller).
Bug: 113041375
Test: take screenshot, rotate screen, screencap
Change-Id: I16e1392d5c92c2f423f98307e867918415404d26
diff --git a/services/surfaceflinger/DisplayDevice.h b/services/surfaceflinger/DisplayDevice.h
index 928f1ce..4290988 100644
--- a/services/surfaceflinger/DisplayDevice.h
+++ b/services/surfaceflinger/DisplayDevice.h
@@ -25,7 +25,6 @@
#include <binder/IBinder.h>
#include <hardware/hwcomposer_defs.h>
-#include <gui/ISurfaceComposer.h>
#include <math/mat4.h>
#include <renderengine/Surface.h>
#include <ui/GraphicTypes.h>
@@ -334,11 +333,11 @@
class DisplayRenderArea : public RenderArea {
public:
DisplayRenderArea(const sp<const DisplayDevice> device,
- ISurfaceComposer::Rotation rotation = ISurfaceComposer::eRotateNone)
+ ui::Transform::orientation_flags rotation = ui::Transform::ROT_0)
: DisplayRenderArea(device, device->getBounds(), device->getWidth(), device->getHeight(),
rotation) {}
DisplayRenderArea(const sp<const DisplayDevice> device, Rect sourceCrop, uint32_t reqWidth,
- uint32_t reqHeight, ISurfaceComposer::Rotation rotation)
+ uint32_t reqHeight, ui::Transform::orientation_flags rotation)
: RenderArea(reqWidth, reqHeight, CaptureFill::OPAQUE, rotation), mDevice(device),
mSourceCrop(sourceCrop) {}
diff --git a/services/surfaceflinger/RenderArea.cpp b/services/surfaceflinger/RenderArea.cpp
index 918bbd3..0a7a546 100644
--- a/services/surfaceflinger/RenderArea.cpp
+++ b/services/surfaceflinger/RenderArea.cpp
@@ -4,27 +4,6 @@
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 reqWidth, uint32_t reqHeight, CaptureFill captureFill,
- ISurfaceComposer::Rotation rotation)
- : mReqWidth(reqWidth), mReqHeight(reqHeight), mCaptureFill(captureFill) {
- mRotationFlags = fromRotation(rotation);
-}
-
float RenderArea::getCaptureFillValue(CaptureFill captureFill) {
switch(captureFill) {
case CaptureFill::CLEAR:
diff --git a/services/surfaceflinger/RenderArea.h b/services/surfaceflinger/RenderArea.h
index 61abaec..c12ff45 100644
--- a/services/surfaceflinger/RenderArea.h
+++ b/services/surfaceflinger/RenderArea.h
@@ -1,7 +1,5 @@
#pragma once
-#include <gui/ISurfaceComposer.h>
-#include <ui/GraphicTypes.h>
#include <ui/Transform.h>
#include <functional>
@@ -21,7 +19,11 @@
static float getCaptureFillValue(CaptureFill captureFill);
RenderArea(uint32_t reqWidth, uint32_t reqHeight, CaptureFill captureFill,
- ISurfaceComposer::Rotation rotation = ISurfaceComposer::eRotateNone);
+ ui::Transform::orientation_flags rotation = ui::Transform::ROT_0)
+ : mReqWidth(reqWidth),
+ mReqHeight(reqHeight),
+ mCaptureFill(captureFill),
+ mRotationFlags(rotation) {}
virtual ~RenderArea() = default;
@@ -73,8 +75,8 @@
private:
uint32_t mReqWidth;
uint32_t mReqHeight;
- ui::Transform::orientation_flags mRotationFlags;
- CaptureFill mCaptureFill;
+ const CaptureFill mCaptureFill;
+ const ui::Transform::orientation_flags mRotationFlags;
};
} // namespace android
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index d4f384f..2dc55c6 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -143,6 +143,21 @@
return false;
}
+ui::Transform::orientation_flags fromSurfaceComposerRotation(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;
+}
+
#pragma clang diagnostic pop
class ConditionalLock {
@@ -4902,6 +4917,8 @@
if (!displayToken) return BAD_VALUE;
+ auto renderAreaRotation = fromSurfaceComposerRotation(rotation);
+
const auto display = getDisplayDeviceLocked(displayToken);
if (!display) return BAD_VALUE;
@@ -4915,7 +4932,7 @@
}
}
- DisplayRenderArea renderArea(display, sourceCrop, reqWidth, reqHeight, rotation);
+ DisplayRenderArea renderArea(display, sourceCrop, reqWidth, reqHeight, renderAreaRotation);
auto traverseLayers = std::bind(std::mem_fn(&SurfaceFlinger::traverseLayersInDisplay), this,
display, minLayerZ, maxLayerZ, std::placeholders::_1);