diff options
author | 2018-08-24 15:34:02 -0700 | |
---|---|---|
committer | 2018-08-27 11:20:19 -0700 | |
commit | c80dcbb574106f3ff126d6b77cbcd12463089301 (patch) | |
tree | 7ed849fd2953b83115f23a32491f4f39f5078e5d | |
parent | 9d1abea931aaacf2354cc49b3d9a484de2693e93 (diff) |
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
-rw-r--r-- | services/surfaceflinger/DisplayDevice.h | 5 | ||||
-rw-r--r-- | services/surfaceflinger/RenderArea.cpp | 21 | ||||
-rw-r--r-- | services/surfaceflinger/RenderArea.h | 12 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 19 |
4 files changed, 27 insertions, 30 deletions
diff --git a/services/surfaceflinger/DisplayDevice.h b/services/surfaceflinger/DisplayDevice.h index 928f1cee76..42909880c7 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 @@ private: 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 918bbd3a47..0a7a546f66 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 61abaec3a2..c12ff45e41 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 @@ public: 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 @@ public: 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 d4f384f934..2dc55c637f 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -143,6 +143,21 @@ bool isWideColorMode(const ColorMode colorMode) { 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 @@ status_t SurfaceFlinger::captureScreen(const sp<IBinder>& displayToken, if (!displayToken) return BAD_VALUE; + auto renderAreaRotation = fromSurfaceComposerRotation(rotation); + const auto display = getDisplayDeviceLocked(displayToken); if (!display) return BAD_VALUE; @@ -4915,7 +4932,7 @@ status_t SurfaceFlinger::captureScreen(const sp<IBinder>& displayToken, } } - 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); |