summaryrefslogtreecommitdiffstats
path: root/cmds/screencap
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2012-08-24 22:40:14 -0700
committerJeff Brown <jeffbrown@google.com>2012-08-27 14:34:53 -0700
commit0b722fe9ce98d97dbcb6fefd170b85ab7037e528 (patch)
tree67b40b76ec957ba919dd9e7d9b450fa7d2b2bfd9 /cmds/screencap
parentd59db50ab0c3c7a232b2a564e763ca46c6f6ebfa (diff)
downloadframeworks_base-0b722fe9ce98d97dbcb6fefd170b85ab7037e528.zip
frameworks_base-0b722fe9ce98d97dbcb6fefd170b85ab7037e528.tar.gz
frameworks_base-0b722fe9ce98d97dbcb6fefd170b85ab7037e528.tar.bz2
Use new surface flinger API.
Change-Id: Ic888577408a59a36481a48010e19c5e77c24e211
Diffstat (limited to 'cmds/screencap')
-rw-r--r--cmds/screencap/screencap.cpp17
1 files changed, 13 insertions, 4 deletions
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 <binder/IMemory.h>
#include <gui/SurfaceComposerClient.h>
+#include <gui/ISurfaceComposer.h>
#include <SkImageEncoder.h>
#include <SkBitmap.h>
@@ -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<IBinder> display = SurfaceComposerClient::getBuiltInDisplay(displayId);
+ if (display != NULL && screenshot.update(display) == NO_ERROR) {
base = screenshot.getPixels();
w = screenshot.getWidth();
h = screenshot.getHeight();