James Dong | 199d1c1 | 2011-03-17 11:48:13 -0700 | [diff] [blame] | 1 | /* |
| 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 Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 17 | #include <cutils/memory.h> |
| 18 | |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 19 | #include <utils/Log.h> |
| 20 | |
Mathias Agopian | 000479f | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 21 | #include <binder/IPCThreadState.h> |
| 22 | #include <binder/ProcessState.h> |
| 23 | #include <binder/IServiceManager.h> |
| 24 | |
| 25 | #include <surfaceflinger/Surface.h> |
| 26 | #include <surfaceflinger/ISurface.h> |
| 27 | #include <surfaceflinger/SurfaceComposerClient.h> |
| 28 | |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 29 | using namespace android; |
| 30 | |
| 31 | namespace android { |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 32 | |
| 33 | int main(int argc, char** argv) |
| 34 | { |
| 35 | // set up the thread-pool |
| 36 | sp<ProcessState> proc(ProcessState::self()); |
| 37 | ProcessState::self()->startThreadPool(); |
| 38 | |
| 39 | // create a client to surfaceflinger |
| 40 | sp<SurfaceComposerClient> client = new SurfaceComposerClient(); |
| 41 | |
Mathias Agopian | 1473f46 | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 42 | sp<Surface> surface = client->createSurface(getpid(), 0, 160, 240, |
| 43 | PIXEL_FORMAT_RGB_565); |
| 44 | |
| 45 | |
| 46 | client->openTransaction(); |
| 47 | surface->setLayer(100000); |
| 48 | client->closeTransaction(); |
| 49 | |
| 50 | Surface::SurfaceInfo info; |
| 51 | surface->lock(&info); |
| 52 | ssize_t bpr = info.s * bytesPerPixel(info.format); |
| 53 | android_memset16((uint16_t*)info.bits, 0xF800, bpr*info.h); |
| 54 | surface->unlockAndPost(); |
| 55 | |
| 56 | surface->lock(&info); |
| 57 | android_memset16((uint16_t*)info.bits, 0x07E0, bpr*info.h); |
| 58 | surface->unlockAndPost(); |
| 59 | |
| 60 | client->openTransaction(); |
| 61 | surface->setSize(320, 240); |
| 62 | client->closeTransaction(); |
| 63 | |
| 64 | |
| 65 | IPCThreadState::self()->joinThreadPool(); |
| 66 | |
| 67 | return 0; |
| 68 | } |