1/* 2 * Copyright (C) 2014 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 "TestContext.h" 18 19#include <gui/ISurfaceComposer.h> 20#include <gui/SurfaceComposerClient.h> 21 22using namespace android; 23 24DisplayInfo gDisplay; 25sp<SurfaceComposerClient> gSession; 26 27void createTestEnvironment() { 28 gSession = new SurfaceComposerClient(); 29 sp<IBinder> dtoken(SurfaceComposerClient::getBuiltInDisplay( 30 ISurfaceComposer::eDisplayIdMain)); 31 status_t status = SurfaceComposerClient::getDisplayInfo(dtoken, &gDisplay); 32 LOG_ALWAYS_FATAL_IF(status, "Failed to get display info\n"); 33} 34 35sp<SurfaceControl> createWindow(int width, int height) { 36 sp<SurfaceControl> control = gSession->createSurface(String8("HwuiTest"), 37 width, height, PIXEL_FORMAT_RGBX_8888); 38 39 SurfaceComposerClient::openGlobalTransaction(); 40 control->setLayer(0x7FFFFFF); 41 control->show(); 42 SurfaceComposerClient::closeGlobalTransaction(); 43 44 return control; 45} 46