diff options
| author | 2020-07-27 16:44:35 -0700 | |
|---|---|---|
| committer | 2020-07-31 10:56:04 -0700 | |
| commit | bc27bc7189eb424c66d4529d5c750ebde1dba265 (patch) | |
| tree | d05db5e253f7006668379f286545e4c8602dac19 /cmds | |
| parent | e9bb6aa4ba807e59b00a6f7e0798fa38540aebf0 (diff) | |
Updated display capture and screencap to match native functions
Modified Java and JNI display capture functions to match the new
function in SurfaceComposerClient. The Java method will send an args
object instead of individual arguments to SurfaceComposerClient
Test: display screenshots working
Test: adb shell screencap
Bug: 162367424
Change-Id: Ic8d9cbc626e9ef73300304ce155a50f76f017dfc
Diffstat (limited to 'cmds')
| -rw-r--r-- | cmds/screencap/screencap.cpp | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/cmds/screencap/screencap.cpp b/cmds/screencap/screencap.cpp index c1d8399d91a5..a46a54cc2063 100644 --- a/cmds/screencap/screencap.cpp +++ b/cmds/screencap/screencap.cpp @@ -182,16 +182,17 @@ int main(int argc, char** argv) ProcessState::self()->setThreadPoolMaxThreadCount(0); ProcessState::self()->startThreadPool(); - ui::Dataspace outDataspace; - sp<GraphicBuffer> outBuffer; - - status_t result = ScreenshotClient::capture(*displayId, &outDataspace, &outBuffer); + ScreenCaptureResults captureResults; + status_t result = ScreenshotClient::captureDisplay(*displayId, captureResults); if (result != NO_ERROR) { close(fd); return 1; } - result = outBuffer->lock(GraphicBuffer::USAGE_SW_READ_OFTEN, &base); + ui::Dataspace dataspace = captureResults.capturedDataspace; + sp<GraphicBuffer> buffer = captureResults.buffer; + + result = buffer->lock(GraphicBuffer::USAGE_SW_READ_OFTEN, &base); if (base == nullptr || result != NO_ERROR) { String8 reason; @@ -207,13 +208,13 @@ int main(int argc, char** argv) if (png) { AndroidBitmapInfo info; - info.format = flinger2bitmapFormat(outBuffer->getPixelFormat()); + info.format = flinger2bitmapFormat(buffer->getPixelFormat()); info.flags = ANDROID_BITMAP_FLAGS_ALPHA_PREMUL; - info.width = outBuffer->getWidth(); - info.height = outBuffer->getHeight(); - info.stride = outBuffer->getStride() * bytesPerPixel(outBuffer->getPixelFormat()); + info.width = buffer->getWidth(); + info.height = buffer->getHeight(); + info.stride = buffer->getStride() * bytesPerPixel(buffer->getPixelFormat()); - int result = AndroidBitmap_compress(&info, static_cast<int32_t>(outDataspace), base, + int result = AndroidBitmap_compress(&info, static_cast<int32_t>(dataspace), base, ANDROID_BITMAP_COMPRESS_FORMAT_PNG, 100, &fd, [](void* fdPtr, const void* data, size_t size) -> bool { int bytesWritten = write(*static_cast<int*>(fdPtr), @@ -229,11 +230,11 @@ int main(int argc, char** argv) notifyMediaScanner(fn); } } else { - uint32_t w = outBuffer->getWidth(); - uint32_t h = outBuffer->getHeight(); - uint32_t s = outBuffer->getStride(); - uint32_t f = outBuffer->getPixelFormat(); - uint32_t c = dataSpaceToInt(outDataspace); + uint32_t w = buffer->getWidth(); + uint32_t h = buffer->getHeight(); + uint32_t s = buffer->getStride(); + uint32_t f = buffer->getPixelFormat(); + uint32_t c = dataSpaceToInt(dataspace); write(fd, &w, 4); write(fd, &h, 4); |