Home | History | Annotate | Download | only in surface
      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 int main(int argc, char** argv)
     18 {
     19     // set up the thread-pool
     20     sp<ProcessState> proc(ProcessState::self());
     21     ProcessState::self()->startThreadPool();
     22 
     23     // create a client to surfaceflinger
     24     sp<SurfaceComposerClient> client = new SurfaceComposerClient();
     25 
     26     // create pushbuffer surface
     27     sp<SurfaceControl> surfaceControl = client->createSurface(
     28             getpid(), 0, 160, 240, PIXEL_FORMAT_RGB_565);
     29     client->openTransaction();
     30     surfaceControl->setLayer(100000);
     31     client->closeTransaction();
     32 
     33     // pretend it went cross-process
     34     Parcel parcel;
     35     SurfaceControl::writeSurfaceToParcel(surfaceControl, &parcel);
     36     parcel.setDataPosition(0);
     37     sp<Surface> surface = Surface::readFromParcel(parcel);
     38     ANativeWindow* window = surface.get();
     39 
     40     printf("window=%p\n", window);
     41 
     42     int err = native_window_set_buffer_count(window, 8);
     43     android_native_buffer_t* buffer;
     44 
     45     for (int i=0 ; i<8 ; i++) {
     46         window->dequeueBuffer(window, &buffer);
     47         printf("buffer %d: %p\n", i, buffer);
     48     }
     49 
     50     printf("test complete. CTRL+C to finish.\n");
     51 
     52     IPCThreadState::self()->joinThreadPool();
     53     return 0;
     54 }
     55