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