[Embedded Emulator] Foldable Support
When the screen is folded, getScreenshot() method will return an resized
image based on the requested width and height while keeping the aspect
ratio of the folded screen instead of the unfolded screen.
The idea is the same as snipping a rectangle within the unfolded screen
but we need to also consider rotation and reszing. There are 4 steps:
1, Calculate the scaling factor. Get new width, height for the entire
screen and compute the rectangle to snip.
2, Apply rotation to image and transform xOffset and yOffset in the
rectangle if necessary.
3, Resize based on new width and height.
4, Clip a rectangle from the resized screen.
Test: Manual. "adb emu fold" and "adb emu rotate" must work properly.
Bug: 171515275
Signed-off-by: Weilun Du <[email protected]>
Change-Id: I08bd318976e5060678eb184b93268f0297baaa02
diff --git a/stream-servers/RendererImpl.cpp b/stream-servers/RendererImpl.cpp
index cecdada..4ffb018 100644
--- a/stream-servers/RendererImpl.cpp
+++ b/stream-servers/RendererImpl.cpp
@@ -380,21 +380,21 @@
if (fb) fb->fillGLESUsages(usages);
}
-int RendererImpl::getScreenshot(
- unsigned int nChannels,
- unsigned int* width,
- unsigned int* height,
- uint8_t* pixels,
- size_t* cPixels,
- int displayId = 0,
- int desiredWidth = 0,
- int desiredHeight = 0,
- int desiredRotation = 0) {
+int RendererImpl::getScreenshot(unsigned int nChannels,
+ unsigned int* width,
+ unsigned int* height,
+ uint8_t* pixels,
+ size_t* cPixels,
+ int displayId = 0,
+ int desiredWidth = 0,
+ int desiredHeight = 0,
+ int desiredRotation = SKIN_ROTATION_0,
+ SkinRect rect = {{0, 0}, {0, 0}}) {
auto fb = FrameBuffer::getFB();
if (fb) {
return fb->getScreenshot(nChannels, width, height, pixels, cPixels,
displayId, desiredWidth, desiredHeight,
- desiredRotation);
+ desiredRotation, rect);
}
*cPixels = 0;
return -1;