blob: c248a615a919d67ff7c597ee55f9f0803cf06cd1 [file] [log] [blame]
Mathias Agopianc5b2c0b2009-05-19 19:08:10 -07001#include <binder/IPCThreadState.h>
2#include <binder/ProcessState.h>
3#include <binder/IServiceManager.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08004#include <utils/Log.h>
5
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08006#include <ui/Overlay.h>
Mathias Agopian9cce3252010-02-09 17:46:37 -08007
8#include <surfaceflinger/Surface.h>
9#include <surfaceflinger/ISurface.h>
10#include <surfaceflinger/SurfaceComposerClient.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080011
12using namespace android;
13
14namespace android {
15class Test {
16public:
17 static const sp<ISurface>& getISurface(const sp<Surface>& s) {
18 return s->getISurface();
19 }
20};
21};
22
23int 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}