blob: 0b9322e249fb9e518215913a068ca3ac955cf11d [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
6#include <ui/Surface.h>
7#include <ui/ISurface.h>
8#include <ui/Overlay.h>
9#include <ui/SurfaceComposerClient.h>
10
11using namespace android;
12
13namespace android {
14class Test {
15public:
16 static const sp<ISurface>& getISurface(const sp<Surface>& s) {
17 return s->getISurface();
18 }
19};
20};
21
22int 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}