blob: 194fbb6dc56f4bdbf8a1fde1e95e97576cec5ce1 [file] [log] [blame]
Mathias Agopian208cb072010-07-27 20:11:35 -07001#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
Mathias Agopian208cb072010-07-27 20:11:35 -070013using namespace android;
14
15int main(int argc, char** argv)
16{
17 // set up the thread-pool
18 sp<ProcessState> proc(ProcessState::self());
19 ProcessState::self()->startThreadPool();
20
21 // create a client to surfaceflinger
22 sp<SurfaceComposerClient> client = new SurfaceComposerClient();
23
Mathias Agopian208cb072010-07-27 20:11:35 -070024 sp<SurfaceControl> surfaceControl = client->createSurface(
25 getpid(), 0, 160, 240, PIXEL_FORMAT_RGB_565);
26 client->openTransaction();
27 surfaceControl->setLayer(100000);
28 client->closeTransaction();
29
30 // pretend it went cross-process
31 Parcel parcel;
32 SurfaceControl::writeSurfaceToParcel(surfaceControl, &parcel);
33 parcel.setDataPosition(0);
34 sp<Surface> surface = Surface::readFromParcel(parcel);
35 ANativeWindow* window = surface.get();
36
37 printf("window=%p\n", window);
38
39 int err = native_window_set_buffer_count(window, 8);
40 android_native_buffer_t* buffer;
41
42 for (int i=0 ; i<8 ; i++) {
43 window->dequeueBuffer(window, &buffer);
44 printf("buffer %d: %p\n", i, buffer);
45 }
46
47 printf("test complete. CTRL+C to finish.\n");
48
49 IPCThreadState::self()->joinThreadPool();
50 return 0;
51}