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 17 #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 25 #include <gui/Surface.h> 26 #include <gui/SurfaceComposerClient.h> 27 28 using namespace android; 29 30 namespace android { 31 32 int main(int argc, char** argv) 33 { 34 // set up the thread-pool 35 sp<ProcessState> proc(ProcessState::self()); 36 ProcessState::self()->startThreadPool(); 37 38 // create a client to surfaceflinger 39 sp<SurfaceComposerClient> client = new SurfaceComposerClient(); 40 41 sp<Surface> surface = client->createSurface(0, 160, 240, 42 PIXEL_FORMAT_RGB_565); 43 44 45 SurfaceComposerClient::openGlobalTransaction(); 46 surface->setLayer(100000); 47 SurfaceComposerClient::closeGlobalTransaction(); 48 49 Surface::SurfaceInfo info; 50 surface->lock(&info); 51 ssize_t bpr = info.s * bytesPerPixel(info.format); 52 android_memset16((uint16_t*)info.bits, 0xF800, bpr*info.h); 53 surface->unlockAndPost(); 54 55 surface->lock(&info); 56 android_memset16((uint16_t*)info.bits, 0x07E0, bpr*info.h); 57 surface->unlockAndPost(); 58 59 SurfaceComposerClient::openGlobalTransaction(); 60 surface->setSize(320, 240); 61 SurfaceComposerClient::closeGlobalTransaction(); 62 63 64 IPCThreadState::self()->joinThreadPool(); 65 66 return 0; 67 } 68