diff options
Diffstat (limited to 'cmds')
-rw-r--r-- | cmds/bootanimation/BootAnimation.cpp | 9 | ||||
-rw-r--r-- | cmds/screencap/screencap.cpp | 17 |
2 files changed, 19 insertions, 7 deletions
diff --git a/cmds/bootanimation/BootAnimation.cpp b/cmds/bootanimation/BootAnimation.cpp index 2471a2e..8511735 100644 --- a/cmds/bootanimation/BootAnimation.cpp +++ b/cmds/bootanimation/BootAnimation.cpp @@ -38,6 +38,7 @@ #include <ui/DisplayInfo.h> #include <ui/FramebufferNativeWindow.h> +#include <gui/ISurfaceComposer.h> #include <gui/Surface.h> #include <gui/SurfaceComposerClient.h> @@ -216,14 +217,16 @@ status_t BootAnimation::initTexture(void* buffer, size_t len) status_t BootAnimation::readyToRun() { mAssets.addDefaultAssets(); + sp<IBinder> dtoken(SurfaceComposerClient::getBuiltInDisplay( + ISurfaceComposer::eDisplayIdMain)); DisplayInfo dinfo; - status_t status = SurfaceComposerClient::getDisplayInfo(0, &dinfo); + status_t status = SurfaceComposerClient::getDisplayInfo(dtoken, &dinfo); if (status) return -1; // create the native surface - sp<SurfaceControl> control = session()->createSurface( - 0, dinfo.w, dinfo.h, PIXEL_FORMAT_RGB_565); + sp<SurfaceControl> control = session()->createSurface(String8("BootAnimation"), + dinfo.w, dinfo.h, PIXEL_FORMAT_RGB_565); SurfaceComposerClient::openGlobalTransaction(); control->setLayer(0x40000000); 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(); |