• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
13 #include <ui/Overlay.h>
14 
15 using namespace android;
16 
17 namespace android {
18 class Test {
19 public:
getISurface(const sp<Surface> & s)20     static const sp<ISurface>& getISurface(const sp<Surface>& s) {
21         return s->getISurface();
22     }
23 };
24 };
25 
main(int argc,char ** argv)26 int main(int argc, char** argv)
27 {
28     // set up the thread-pool
29     sp<ProcessState> proc(ProcessState::self());
30     ProcessState::self()->startThreadPool();
31 
32     // create a client to surfaceflinger
33     sp<SurfaceComposerClient> client = new SurfaceComposerClient();
34 
35     // create pushbuffer surface
36     sp<Surface> surface = client->createSurface(getpid(), 0, 160, 240,
37             PIXEL_FORMAT_RGB_565);
38 
39 
40     client->openTransaction();
41     surface->setLayer(100000);
42     client->closeTransaction();
43 
44     Surface::SurfaceInfo info;
45     surface->lock(&info);
46     ssize_t bpr = info.s * bytesPerPixel(info.format);
47     android_memset16((uint16_t*)info.bits, 0xF800, bpr*info.h);
48     surface->unlockAndPost();
49 
50     surface->lock(&info);
51     android_memset16((uint16_t*)info.bits, 0x07E0, bpr*info.h);
52     surface->unlockAndPost();
53 
54     client->openTransaction();
55     surface->setSize(320, 240);
56     client->closeTransaction();
57 
58 
59     IPCThreadState::self()->joinThreadPool();
60 
61     return 0;
62 }
63