summaryrefslogtreecommitdiff
path: root/cmds/screencap/screencap.cpp
diff options
context:
space:
mode:
author Mathias Agopian <mathias@google.com> 2010-10-01 12:15:12 -0700
committer Android (Google) Code Review <android-gerrit@google.com> 2010-10-01 12:15:12 -0700
commit2a471bb690c20533ccf20246be968f77c867c467 (patch)
treec5ea338d412566c0013aa7d3f0c7e7b3695caaae /cmds/screencap/screencap.cpp
parente15119fee611997e71dd711cd476c9fd572d9853 (diff)
parent38ed2e39c54a42dda8f00620f960788f569a3698 (diff)
Merge "refactored screenshot code"
Diffstat (limited to 'cmds/screencap/screencap.cpp')
-rw-r--r--cmds/screencap/screencap.cpp25
1 files changed, 7 insertions, 18 deletions
diff --git a/cmds/screencap/screencap.cpp b/cmds/screencap/screencap.cpp
index 6ce5b86482a1..bc5e10de3f84 100644
--- a/cmds/screencap/screencap.cpp
+++ b/cmds/screencap/screencap.cpp
@@ -17,32 +17,21 @@
#include <unistd.h>
#include <fcntl.h>
-#include <utils/Log.h>
-
-#include <binder/IPCThreadState.h>
-#include <binder/ProcessState.h>
-#include <binder/IServiceManager.h>
-
#include <binder/IMemory.h>
-#include <surfaceflinger/ISurfaceComposer.h>
+#include <surfaceflinger/SurfaceComposerClient.h>
using namespace android;
int main(int argc, char** argv)
{
- const String16 name("SurfaceFlinger");
- sp<ISurfaceComposer> composer;
- if (getService(name, &composer) != NO_ERROR)
- return 0;
-
- sp<IMemoryHeap> heap;
- uint32_t w, h;
- PixelFormat f;
- status_t err = composer->captureScreen(0, &heap, &w, &h, &f);
- if (err != NO_ERROR)
+ ScreenshotClient screenshot;
+ if (screenshot.update() != NO_ERROR)
return 0;
- uint8_t* base = (uint8_t*)heap->getBase();
+ void const* base = screenshot.getPixels();
+ uint32_t w = screenshot.getWidth();
+ uint32_t h = screenshot.getHeight();
+ uint32_t f = screenshot.getFormat();
int fd = dup(STDOUT_FILENO);
write(fd, &w, 4);
write(fd, &h, 4);