The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | #include <utils/IPCThreadState.h> |
| 2 | #include <utils/ProcessState.h> |
| 3 | #include <utils/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: |
| 16 | static const sp<ISurface>& getISurface(const sp<Surface>& s) { |
| 17 | return s->getISurface(); |
| 18 | } |
| 19 | }; |
| 20 | }; |
| 21 | |
| 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 | } |