resize.cpp revision a5529c8778c2f407f482fc12165aeb76c0f505c2
1#include <cutils/memory.h>
2
3#include <utils/Log.h>
4
5#include <binder/IPCThreadState.h>
6#include <binder/ProcessState.h>
7#include <binder/IServiceManager.h>
8
9#include <surfaceflinger/Surface.h>
10#include <surfaceflinger/ISurface.h>
11#include <surfaceflinger/SurfaceComposerClient.h>
12
13using namespace android;
14
15namespace android {
16class Test {
17public:
18    static const sp<ISurface>& getISurface(const sp<Surface>& s) {
19        return s->getISurface();
20    }
21};
22};
23
24int main(int argc, char** argv)
25{
26    // set up the thread-pool
27    sp<ProcessState> proc(ProcessState::self());
28    ProcessState::self()->startThreadPool();
29
30    // create a client to surfaceflinger
31    sp<SurfaceComposerClient> client = new SurfaceComposerClient();
32
33    sp<Surface> surface = client->createSurface(getpid(), 0, 160, 240,
34            PIXEL_FORMAT_RGB_565);
35
36
37    client->openTransaction();
38    surface->setLayer(100000);
39    client->closeTransaction();
40
41    Surface::SurfaceInfo info;
42    surface->lock(&info);
43    ssize_t bpr = info.s * bytesPerPixel(info.format);
44    android_memset16((uint16_t*)info.bits, 0xF800, bpr*info.h);
45    surface->unlockAndPost();
46
47    surface->lock(&info);
48    android_memset16((uint16_t*)info.bits, 0x07E0, bpr*info.h);
49    surface->unlockAndPost();
50
51    client->openTransaction();
52    surface->setSize(320, 240);
53    client->closeTransaction();
54
55
56    IPCThreadState::self()->joinThreadPool();
57
58    return 0;
59}
60