From 0b722fe9ce98d97dbcb6fefd170b85ab7037e528 Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Fri, 24 Aug 2012 22:40:14 -0700 Subject: Use new surface flinger API. Change-Id: Ic888577408a59a36481a48010e19c5e77c24e211 --- cmds/screencap/screencap.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'cmds/screencap') diff --git a/cmds/screencap/screencap.cpp b/cmds/screencap/screencap.cpp index 46e41e3..a1ea81a 100644 --- a/cmds/screencap/screencap.cpp +++ b/cmds/screencap/screencap.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -33,15 +34,18 @@ using namespace android; +static uint32_t DEFAULT_DISPLAY_ID = ISurfaceComposer::eDisplayIdMain; + static void usage(const char* pname) { fprintf(stderr, - "usage: %s [-hp] [FILENAME]\n" + "usage: %s [-hp] [-d display-id] [FILENAME]\n" " -h: this message\n" " -p: save the file as a png.\n" + " -d: specify the display id to capture, default %d.\n" "If FILENAME ends with .png it will be saved as a png.\n" "If FILENAME is not given, the results will be printed to stdout.\n", - pname + pname, DEFAULT_DISPLAY_ID ); } @@ -87,12 +91,16 @@ int main(int argc, char** argv) { const char* pname = argv[0]; bool png = false; + int32_t displayId = DEFAULT_DISPLAY_ID; int c; - while ((c = getopt(argc, argv, "ph")) != -1) { + while ((c = getopt(argc, argv, "phd:")) != -1) { switch (c) { case 'p': png = true; break; + case 'd': + displayId = atoi(optarg); + break; case '?': case 'h': usage(pname); @@ -131,7 +139,8 @@ int main(int argc, char** argv) size_t size = 0; ScreenshotClient screenshot; - if (screenshot.update() == NO_ERROR) { + sp display = SurfaceComposerClient::getBuiltInDisplay(displayId); + if (display != NULL && screenshot.update(display) == NO_ERROR) { base = screenshot.getPixels(); w = screenshot.getWidth(); h = screenshot.getHeight(); -- cgit v1.1