summaryrefslogtreecommitdiff
path: root/services/surfaceflinger/ScreenCaptureOutput.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'services/surfaceflinger/ScreenCaptureOutput.cpp')
-rw-r--r--services/surfaceflinger/ScreenCaptureOutput.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/services/surfaceflinger/ScreenCaptureOutput.cpp b/services/surfaceflinger/ScreenCaptureOutput.cpp
index 09dac23410..b3459134cc 100644
--- a/services/surfaceflinger/ScreenCaptureOutput.cpp
+++ b/services/surfaceflinger/ScreenCaptureOutput.cpp
@@ -24,6 +24,24 @@
namespace android {
+namespace {
+
+ui::Size getDisplaySize(ui::Rotation orientation, const Rect& sourceCrop) {
+ if (orientation == ui::Rotation::Rotation90 || orientation == ui::Rotation::Rotation270) {
+ return {sourceCrop.getHeight(), sourceCrop.getWidth()};
+ }
+ return {sourceCrop.getWidth(), sourceCrop.getHeight()};
+}
+
+Rect getOrientedDisplaySpaceRect(ui::Rotation orientation, int reqWidth, int reqHeight) {
+ if (orientation == ui::Rotation::Rotation90 || orientation == ui::Rotation::Rotation270) {
+ return {reqHeight, reqWidth};
+ }
+ return {reqWidth, reqHeight};
+}
+
+} // namespace
+
std::shared_ptr<ScreenCaptureOutput> createScreenCaptureOutput(ScreenCaptureOutputArgs args) {
std::shared_ptr<ScreenCaptureOutput> output = compositionengine::impl::createOutputTemplated<
ScreenCaptureOutput, compositionengine::CompositionEngine, const RenderArea&,
@@ -45,10 +63,10 @@ std::shared_ptr<ScreenCaptureOutput> createScreenCaptureOutput(ScreenCaptureOutp
const Rect& sourceCrop = args.renderArea.getSourceCrop();
const ui::Rotation orientation = ui::Transform::toRotation(args.renderArea.getRotationFlags());
- const Rect orientedDisplaySpaceRect{args.renderArea.getReqWidth(),
- args.renderArea.getReqHeight()};
- output->setProjection(orientation, sourceCrop, orientedDisplaySpaceRect);
- output->setDisplaySize({sourceCrop.getWidth(), sourceCrop.getHeight()});
+ output->setDisplaySize(getDisplaySize(orientation, sourceCrop));
+ output->setProjection(orientation, sourceCrop,
+ getOrientedDisplaySpaceRect(orientation, args.renderArea.getReqWidth(),
+ args.renderArea.getReqHeight()));
{
std::string name = args.regionSampling ? "RegionSampling" : "ScreenCaptureOutput";