blob: 9c41cc3447f2ba51737c5e85fcbb2c67dbb4b192 [file] [log] [blame]
James Dong5f7204c2011-03-17 11:48:13 -07001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Mathias Agopian208cb072010-07-27 20:11:35 -070017#include <cutils/memory.h>
18
19#include <utils/Log.h>
20
21#include <binder/IPCThreadState.h>
22#include <binder/ProcessState.h>
23#include <binder/IServiceManager.h>
24
Mathias Agopian90ac7992012-02-25 18:48:35 -080025#include <gui/Surface.h>
26#include <gui/SurfaceComposerClient.h>
Mathias Agopian208cb072010-07-27 20:11:35 -070027
Mathias Agopian208cb072010-07-27 20:11:35 -070028using namespace android;
29
30int main(int argc, char** argv)
31{
32 // set up the thread-pool
33 sp<ProcessState> proc(ProcessState::self());
34 ProcessState::self()->startThreadPool();
35
36 // create a client to surfaceflinger
37 sp<SurfaceComposerClient> client = new SurfaceComposerClient();
38
Mathias Agopian208cb072010-07-27 20:11:35 -070039 sp<SurfaceControl> surfaceControl = client->createSurface(
Jeff Brown9d4e3d22012-08-24 20:00:51 -070040 String8("surface"), 160, 240, PIXEL_FORMAT_RGB_565, 0);
Mathias Agopian698c0872011-06-28 19:09:31 -070041 SurfaceComposerClient::openGlobalTransaction();
Mathias Agopian208cb072010-07-27 20:11:35 -070042 surfaceControl->setLayer(100000);
Mathias Agopian698c0872011-06-28 19:09:31 -070043 SurfaceComposerClient::closeGlobalTransaction();
Mathias Agopian208cb072010-07-27 20:11:35 -070044
45 // pretend it went cross-process
46 Parcel parcel;
47 SurfaceControl::writeSurfaceToParcel(surfaceControl, &parcel);
48 parcel.setDataPosition(0);
49 sp<Surface> surface = Surface::readFromParcel(parcel);
50 ANativeWindow* window = surface.get();
51
52 printf("window=%p\n", window);
53
54 int err = native_window_set_buffer_count(window, 8);
Iliyan Malchev697526b2011-05-01 11:33:26 -070055 ANativeWindowBuffer* buffer;
Mathias Agopian208cb072010-07-27 20:11:35 -070056
57 for (int i=0 ; i<8 ; i++) {
58 window->dequeueBuffer(window, &buffer);
59 printf("buffer %d: %p\n", i, buffer);
60 }
61
62 printf("test complete. CTRL+C to finish.\n");
63
64 IPCThreadState::self()->joinThreadPool();
65 return 0;
66}