• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <binder/IPCThreadState.h>
2 #include <binder/ProcessState.h>
3 #include <binder/IServiceManager.h>
4 #include <utils/Log.h>
5 
6 #include <ui/Surface.h>
7 #include <ui/ISurface.h>
8 #include <ui/Overlay.h>
9 #include <ui/SurfaceComposerClient.h>
10 
11 using namespace android;
12 
13 namespace android {
14 class Test {
15 public:
getISurface(const sp<Surface> & s)16     static const sp<ISurface>& getISurface(const sp<Surface>& s) {
17         return s->getISurface();
18     }
19 };
20 };
21 
main(int argc,char ** argv)22 int main(int argc, char** argv)
23 {
24     // set up the thread-pool
25     sp<ProcessState> proc(ProcessState::self());
26     ProcessState::self()->startThreadPool();
27 
28     // create a client to surfaceflinger
29     sp<SurfaceComposerClient> client = new SurfaceComposerClient();
30 
31     // create pushbuffer surface
32     sp<Surface> surface = client->createSurface(getpid(), 0, 320, 240,
33             PIXEL_FORMAT_UNKNOWN, ISurfaceComposer::ePushBuffers);
34 
35     // get to the isurface
36     sp<ISurface> isurface = Test::getISurface(surface);
37     printf("isurface = %p\n", isurface.get());
38 
39     // now request an overlay
40     sp<OverlayRef> ref = isurface->createOverlay(320, 240, PIXEL_FORMAT_RGB_565);
41     sp<Overlay> overlay = new Overlay(ref);
42 
43 
44     /*
45      * here we can use the overlay API
46      */
47 
48     overlay_buffer_t buffer;
49     overlay->dequeueBuffer(&buffer);
50     printf("buffer = %p\n", buffer);
51 
52     void* address = overlay->getBufferAddress(buffer);
53     printf("address = %p\n", address);
54 
55     overlay->queueBuffer(buffer);
56 
57     return 0;
58 }
59