HWComposer.cpp revision 8630320433bd15aca239522e54e711ef6372ab07
1a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian/* 2a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian * Copyright (C) 2010 The Android Open Source Project 3a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian * 4a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian * Licensed under the Apache License, Version 2.0 (the "License"); 5a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian * you may not use this file except in compliance with the License. 6a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian * You may obtain a copy of the License at 7a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian * 8a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian * http://www.apache.org/licenses/LICENSE-2.0 9a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian * 10a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian * Unless required by applicable law or agreed to in writing, software 11a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian * distributed under the License is distributed on an "AS IS" BASIS, 12a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian * See the License for the specific language governing permissions and 14a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian * limitations under the License. 15a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian */ 16a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian 172965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian#define ATRACE_TAG ATRACE_TAG_GRAPHICS 182965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian 195880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall// Uncomment this to remove support for HWC_DEVICE_API_VERSION_0_3 and older 205880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall// #define HWC_REMOVE_DEPRECATED_VERSIONS 1 215880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall 22a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian#include <stdint.h> 23f1352df47fe20aed23c216a78923c7d248f2bb91Mathias Agopian#include <stdio.h> 24f1352df47fe20aed23c216a78923c7d248f2bb91Mathias Agopian#include <stdlib.h> 25f1352df47fe20aed23c216a78923c7d248f2bb91Mathias Agopian#include <string.h> 26a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian#include <sys/types.h> 27a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian 28a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian#include <utils/Errors.h> 298372785879d329f592f6883620b5a32d80d74691Mathias Agopian#include <utils/String8.h> 303eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian#include <utils/Thread.h> 312965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian#include <utils/Trace.h> 3222da60c3e64cd57535cbba063c07127814a2b52fMathias Agopian#include <utils/Vector.h> 33a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian 34921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian#include <ui/GraphicBuffer.h> 35921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian 36a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian#include <hardware/hardware.h> 373eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian#include <hardware/hwcomposer.h> 38a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian 39a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian#include <cutils/log.h> 40e2c4f4ec23b735dd2a03f4ea8b08b288a1bb04e8Mathias Agopian#include <cutils/properties.h> 41a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian 42a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian#include <EGL/egl.h> 43a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian 44921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian#include "Layer.h" // needed only for debugging 4522da60c3e64cd57535cbba063c07127814a2b52fMathias Agopian#include "LayerBase.h" 46a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian#include "HWComposer.h" 47c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian#include "SurfaceFlinger.h" 48a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian 49a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopiannamespace android { 505880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall 515880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall// --------------------------------------------------------------------------- 525880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall// Support for HWC_DEVICE_API_VERSION_0_3 and older: 535880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall// Since v0.3 is deprecated and support will be dropped soon, as much as 545880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall// possible the code is written to target v1.0. When using a v0.3 HWC, we 555880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall// allocate v0.3 structures, but assign them to v1.0 pointers. Fields that 565880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall// exist in both versions are located at the same offset, so in most cases we 575880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall// can just use the v1.0 pointer without branches or casts. 585880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall 595880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall#if HWC_REMOVE_DEPRECATED_VERSIONS 605880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall// We need complete types with to satisfy semantic checks, even though the 615880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall// code paths that use these won't get executed at runtime (and will likely be 625880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall// dead-code-eliminated). When we remove the code to support v0.3 we can remove 635880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall// these as well. 645880cc573823148237eac9ab7bc586b8e4eb7160Jesse Halltypedef hwc_layer_1_t hwc_layer_t; 655880cc573823148237eac9ab7bc586b8e4eb7160Jesse Halltypedef hwc_layer_list_1_t hwc_layer_list_t; 665880cc573823148237eac9ab7bc586b8e4eb7160Jesse Halltypedef hwc_composer_device_1_t hwc_composer_device_t; 675880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall#endif 685880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall 695880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall// This function assumes we've already rejected HWC's with lower-than-required 705880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall// versions. Don't use it for the initial "does HWC meet requirements" check! 715880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hallstatic bool hwcHasVersion(const hwc_composer_device_1_t* hwc, uint32_t version) { 725880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall if (HWC_REMOVE_DEPRECATED_VERSIONS && 735880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall version <= HWC_DEVICE_API_VERSION_1_0) { 745880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall return true; 755880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall } else { 765880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall return hwc->common.version >= version; 775880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall } 785880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall} 795880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall 805880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hallstatic size_t sizeofHwcLayerList(const hwc_composer_device_1_t* hwc, 815880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall size_t numLayers) { 825880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall if (hwcHasVersion(hwc, HWC_DEVICE_API_VERSION_1_0)) { 835880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall return sizeof(hwc_layer_list_1_t) + numLayers*sizeof(hwc_layer_1_t); 845880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall } else { 855880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall return sizeof(hwc_layer_list_t) + numLayers*sizeof(hwc_layer_t); 865880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall } 875880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall} 885880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall 89a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian// --------------------------------------------------------------------------- 90a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian 913e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopianstruct HWComposer::cb_context { 923e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian struct callbacks : public hwc_procs_t { 933e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian // these are here to facilitate the transition when adding 943e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian // new callbacks (an implementation can check for NULL before 953e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian // calling a new callback). 963e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian void (*zero[4])(void); 973e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian }; 983e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian callbacks procs; 993e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian HWComposer* hwc; 1003e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian}; 1013e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian 1023e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian// --------------------------------------------------------------------------- 1033e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian 1043eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias AgopianHWComposer::HWComposer( 1053eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian const sp<SurfaceFlinger>& flinger, 1063eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian EventHandler& handler, 1073eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian nsecs_t refreshPeriod) 108c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian : mFlinger(flinger), 109c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian mModule(0), mHwc(0), mList(0), mCapacity(0), 1109c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian mNumOVLayers(0), mNumFBLayers(0), 1113eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian mDpy(EGL_NO_DISPLAY), mSur(EGL_NO_SURFACE), 1123e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian mCBContext(new cb_context), 1133eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian mEventHandler(handler), 114e2c4f4ec23b735dd2a03f4ea8b08b288a1bb04e8Mathias Agopian mRefreshPeriod(refreshPeriod), 115e2c4f4ec23b735dd2a03f4ea8b08b288a1bb04e8Mathias Agopian mVSyncCount(0), mDebugForceFakeVSync(false) 116a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian{ 117e2c4f4ec23b735dd2a03f4ea8b08b288a1bb04e8Mathias Agopian char value[PROPERTY_VALUE_MAX]; 118e2c4f4ec23b735dd2a03f4ea8b08b288a1bb04e8Mathias Agopian property_get("debug.sf.no_hw_vsync", value, "0"); 119e2c4f4ec23b735dd2a03f4ea8b08b288a1bb04e8Mathias Agopian mDebugForceFakeVSync = atoi(value); 120e2c4f4ec23b735dd2a03f4ea8b08b288a1bb04e8Mathias Agopian 1213a77871383bc1a03cc866686d81628493d14de7cMathias Agopian bool needVSyncThread = false; 122a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian int err = hw_get_module(HWC_HARDWARE_MODULE_ID, &mModule); 12332397c1cd3327905173b36baa6fd1c579bc328ffSteve Block ALOGW_IF(err, "%s module not found", HWC_HARDWARE_MODULE_ID); 124a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian if (err == 0) { 1255880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall err = hwc_open_1(mModule, &mHwc); 126e6f43ddce78d6846af12550ff9193c5c6fe5844bSteve Block ALOGE_IF(err, "%s device failed to initialize (%s)", 127a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian HWC_HARDWARE_COMPOSER, strerror(-err)); 128c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian if (err == 0) { 1295880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall if (HWC_REMOVE_DEPRECATED_VERSIONS && 1305880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall mHwc->common.version < HWC_DEVICE_API_VERSION_1_0) { 1315880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall ALOGE("%s device version %#x too old, will not be used", 1325880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall HWC_HARDWARE_COMPOSER, mHwc->common.version); 1335880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall hwc_close_1(mHwc); 1345880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall mHwc = NULL; 1355880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall } 1365880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall } 1375880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall 1385880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall if (mHwc) { 139c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian if (mHwc->registerProcs) { 1403e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian mCBContext->hwc = this; 1413e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian mCBContext->procs.invalidate = &hook_invalidate; 1423e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian mCBContext->procs.vsync = &hook_vsync; 1433e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian mHwc->registerProcs(mHwc, &mCBContext->procs); 1443e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian memset(mCBContext->procs.zero, 0, sizeof(mCBContext->procs.zero)); 145c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian } 1465880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall if (hwcHasVersion(mHwc, HWC_DEVICE_API_VERSION_0_3)) { 147e2c4f4ec23b735dd2a03f4ea8b08b288a1bb04e8Mathias Agopian if (mDebugForceFakeVSync) { 148e2c4f4ec23b735dd2a03f4ea8b08b288a1bb04e8Mathias Agopian // make sure to turn h/w vsync off in "fake vsync" mode 149e2c4f4ec23b735dd2a03f4ea8b08b288a1bb04e8Mathias Agopian mHwc->methods->eventControl(mHwc, HWC_EVENT_VSYNC, 0); 150e2c4f4ec23b735dd2a03f4ea8b08b288a1bb04e8Mathias Agopian } 151e2c4f4ec23b735dd2a03f4ea8b08b288a1bb04e8Mathias Agopian } else { 1523a77871383bc1a03cc866686d81628493d14de7cMathias Agopian needVSyncThread = true; 1533eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian } 154c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian } 1553a77871383bc1a03cc866686d81628493d14de7cMathias Agopian } else { 1563a77871383bc1a03cc866686d81628493d14de7cMathias Agopian needVSyncThread = true; 1573a77871383bc1a03cc866686d81628493d14de7cMathias Agopian } 1583a77871383bc1a03cc866686d81628493d14de7cMathias Agopian 1593a77871383bc1a03cc866686d81628493d14de7cMathias Agopian if (needVSyncThread) { 1603a77871383bc1a03cc866686d81628493d14de7cMathias Agopian // we don't have VSYNC support, we need to fake it 1613a77871383bc1a03cc866686d81628493d14de7cMathias Agopian mVSyncThread = new VSyncThread(*this); 162a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian } 163a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian} 164a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian 165a350ff98692b3a50cad5cc93f9f83221242ca86aMathias AgopianHWComposer::~HWComposer() { 166e2c4f4ec23b735dd2a03f4ea8b08b288a1bb04e8Mathias Agopian eventControl(EVENT_VSYNC, 0); 167a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian free(mList); 1683eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian if (mVSyncThread != NULL) { 1693eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian mVSyncThread->requestExitAndWait(); 1703eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian } 171a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian if (mHwc) { 1725880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall hwc_close_1(mHwc); 173a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian } 1743e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian delete mCBContext; 175a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian} 176a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian 177a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopianstatus_t HWComposer::initCheck() const { 178a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian return mHwc ? NO_ERROR : NO_INIT; 179a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian} 180a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian 181c7d14e247117392fbd44aa454622778a25c076aeMathias Agopianvoid HWComposer::hook_invalidate(struct hwc_procs* procs) { 182c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian reinterpret_cast<cb_context *>(procs)->hwc->invalidate(); 183c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian} 184c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian 18531d2843b45ebdb69ec3355111b7567363fd2a6b7Mathias Agopianvoid HWComposer::hook_vsync(struct hwc_procs* procs, int dpy, int64_t timestamp) { 18631d2843b45ebdb69ec3355111b7567363fd2a6b7Mathias Agopian reinterpret_cast<cb_context *>(procs)->hwc->vsync(dpy, timestamp); 18731d2843b45ebdb69ec3355111b7567363fd2a6b7Mathias Agopian} 18831d2843b45ebdb69ec3355111b7567363fd2a6b7Mathias Agopian 189c7d14e247117392fbd44aa454622778a25c076aeMathias Agopianvoid HWComposer::invalidate() { 190e2c2f9213f936f98db604dc9c126ff22f725a824Mathias Agopian mFlinger->repaintEverything(); 191c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian} 192c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian 19331d2843b45ebdb69ec3355111b7567363fd2a6b7Mathias Agopianvoid HWComposer::vsync(int dpy, int64_t timestamp) { 1942965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian ATRACE_INT("VSYNC", ++mVSyncCount&1); 1953eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian mEventHandler.onVSyncReceived(dpy, timestamp); 1963eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian} 1973eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian 19803e407270c7ad76632f982c886d0776bed9e9b4cMathias Agopianvoid HWComposer::eventControl(int event, int enabled) { 1993eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian status_t err = NO_ERROR; 2001a3bf41b7165ba294af46bc32483eaad61e707eaErik Gilling if (mHwc && mHwc->common.version >= HWC_DEVICE_API_VERSION_0_3) { 201e2c4f4ec23b735dd2a03f4ea8b08b288a1bb04e8Mathias Agopian if (!mDebugForceFakeVSync) { 202e2c4f4ec23b735dd2a03f4ea8b08b288a1bb04e8Mathias Agopian err = mHwc->methods->eventControl(mHwc, event, enabled); 20303e407270c7ad76632f982c886d0776bed9e9b4cMathias Agopian // error here should not happen -- not sure what we should 20403e407270c7ad76632f982c886d0776bed9e9b4cMathias Agopian // do if it does. 20503e407270c7ad76632f982c886d0776bed9e9b4cMathias Agopian ALOGE_IF(err, "eventControl(%d, %d) failed %s", 20603e407270c7ad76632f982c886d0776bed9e9b4cMathias Agopian event, enabled, strerror(-err)); 207e2c4f4ec23b735dd2a03f4ea8b08b288a1bb04e8Mathias Agopian } 2083eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian } 2093a77871383bc1a03cc866686d81628493d14de7cMathias Agopian 2103a77871383bc1a03cc866686d81628493d14de7cMathias Agopian if (err == NO_ERROR && mVSyncThread != NULL) { 2113a77871383bc1a03cc866686d81628493d14de7cMathias Agopian mVSyncThread->setEnabled(enabled); 2123a77871383bc1a03cc866686d81628493d14de7cMathias Agopian } 21331d2843b45ebdb69ec3355111b7567363fd2a6b7Mathias Agopian} 21431d2843b45ebdb69ec3355111b7567363fd2a6b7Mathias Agopian 215a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopianvoid HWComposer::setFrameBuffer(EGLDisplay dpy, EGLSurface sur) { 216a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian mDpy = (hwc_display_t)dpy; 217a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian mSur = (hwc_surface_t)sur; 218a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian} 219a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian 220a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopianstatus_t HWComposer::createWorkList(size_t numLayers) { 22145721773e1a68e96da4b6cc04cef276bae7ca3e9Mathias Agopian if (mHwc) { 22245721773e1a68e96da4b6cc04cef276bae7ca3e9Mathias Agopian if (!mList || mCapacity < numLayers) { 22345721773e1a68e96da4b6cc04cef276bae7ca3e9Mathias Agopian free(mList); 2245880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall size_t size = sizeofHwcLayerList(mHwc, numLayers); 2255880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall mList = (hwc_layer_list_1_t*)malloc(size); 22645721773e1a68e96da4b6cc04cef276bae7ca3e9Mathias Agopian mCapacity = numLayers; 22745721773e1a68e96da4b6cc04cef276bae7ca3e9Mathias Agopian } 228a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian mList->flags = HWC_GEOMETRY_CHANGED; 229a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian mList->numHwLayers = numLayers; 230a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian } 231a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian return NO_ERROR; 232a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian} 233a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian 234a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopianstatus_t HWComposer::prepare() const { 235a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian int err = mHwc->prepare(mHwc, mList); 2369c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian if (err == NO_ERROR) { 2379c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian size_t numOVLayers = 0; 2389c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian size_t numFBLayers = 0; 2399c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian size_t count = mList->numHwLayers; 2409c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian for (size_t i=0 ; i<count ; i++) { 2415880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall hwc_layer_1_t* l = NULL; 2425880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall if (hwcHasVersion(mHwc, HWC_DEVICE_API_VERSION_1_0)) { 2435880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall l = &mList->hwLayers[i]; 2445880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall } else { 2455880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall // mList really has hwc_layer_list_t memory layout 2465880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall hwc_layer_list_t* list = (hwc_layer_list_t*)mList; 2475880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall hwc_layer_t* layer = &list->hwLayers[i]; 2485880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall l = (hwc_layer_1_t*)layer; 2499c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian } 2505880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall if (l->flags & HWC_SKIP_LAYER) { 2515880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall l->compositionType = HWC_FRAMEBUFFER; 2525880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall } 2535880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall switch (l->compositionType) { 2549c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian case HWC_OVERLAY: 2559c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian numOVLayers++; 2569c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian break; 2579c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian case HWC_FRAMEBUFFER: 2589c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian numFBLayers++; 2599c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian break; 2609c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian } 2619c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian } 2629c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian mNumOVLayers = numOVLayers; 2639c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian mNumFBLayers = numFBLayers; 2649c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian } 265a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian return (status_t)err; 266a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian} 267a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian 2689c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopiansize_t HWComposer::getLayerCount(int type) const { 2699c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian switch (type) { 2709c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian case HWC_OVERLAY: 2719c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian return mNumOVLayers; 2729c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian case HWC_FRAMEBUFFER: 2739c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian return mNumFBLayers; 2749c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian } 2759c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian return 0; 2769c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian} 2779c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian 278a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopianstatus_t HWComposer::commit() const { 2798630320433bd15aca239522e54e711ef6372ab07Mathias Agopian int err = NO_ERROR; 2808630320433bd15aca239522e54e711ef6372ab07Mathias Agopian if (mHwc) { 2818630320433bd15aca239522e54e711ef6372ab07Mathias Agopian err = mHwc->set(mHwc, mDpy, mSur, mList); 2828630320433bd15aca239522e54e711ef6372ab07Mathias Agopian if (mList) { 2838630320433bd15aca239522e54e711ef6372ab07Mathias Agopian mList->flags &= ~HWC_GEOMETRY_CHANGED; 2848630320433bd15aca239522e54e711ef6372ab07Mathias Agopian } 2858630320433bd15aca239522e54e711ef6372ab07Mathias Agopian } else { 2868630320433bd15aca239522e54e711ef6372ab07Mathias Agopian eglSwapBuffers(mDpy, mSur); 28758959343dbdb6157fa5f5463262d4842b8954353Mathias Agopian } 288a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian return (status_t)err; 289a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian} 290a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian 291f5f2712854599b4970643c6000fe6ae950a08ba9Antti Hatalastatus_t HWComposer::release() const { 2927ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopian if (mHwc) { 2935880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall if (hwcHasVersion(mHwc, HWC_DEVICE_API_VERSION_0_3)) { 29422ffb117b0c2a906bd04aef9738a52223cdd1dceMathias Agopian mHwc->methods->eventControl(mHwc, HWC_EVENT_VSYNC, 0); 29522ffb117b0c2a906bd04aef9738a52223cdd1dceMathias Agopian } 2967ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopian int err = mHwc->set(mHwc, NULL, NULL, NULL); 29710fbdb6059755f009e02f0ccc2b9d289beb6b086Colin Cross if (err < 0) { 29810fbdb6059755f009e02f0ccc2b9d289beb6b086Colin Cross return (status_t)err; 29910fbdb6059755f009e02f0ccc2b9d289beb6b086Colin Cross } 30010fbdb6059755f009e02f0ccc2b9d289beb6b086Colin Cross 30110fbdb6059755f009e02f0ccc2b9d289beb6b086Colin Cross if (hwcHasVersion(mHwc, HWC_DEVICE_API_VERSION_1_0)) { 30210fbdb6059755f009e02f0ccc2b9d289beb6b086Colin Cross if (mHwc->methods && mHwc->methods->blank) { 30310fbdb6059755f009e02f0ccc2b9d289beb6b086Colin Cross err = mHwc->methods->blank(mHwc, 1); 30410fbdb6059755f009e02f0ccc2b9d289beb6b086Colin Cross } 30510fbdb6059755f009e02f0ccc2b9d289beb6b086Colin Cross } 3067ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopian return (status_t)err; 3077ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopian } 3087ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopian return NO_ERROR; 3097ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopian} 3107ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopian 31110fbdb6059755f009e02f0ccc2b9d289beb6b086Colin Crossstatus_t HWComposer::acquire() const { 31210fbdb6059755f009e02f0ccc2b9d289beb6b086Colin Cross if (mHwc) { 31310fbdb6059755f009e02f0ccc2b9d289beb6b086Colin Cross if (hwcHasVersion(mHwc, HWC_DEVICE_API_VERSION_1_0)) { 31410fbdb6059755f009e02f0ccc2b9d289beb6b086Colin Cross if (mHwc->methods && mHwc->methods->blank) { 31510fbdb6059755f009e02f0ccc2b9d289beb6b086Colin Cross int err = mHwc->methods->blank(mHwc, 0); 31610fbdb6059755f009e02f0ccc2b9d289beb6b086Colin Cross return (status_t)err; 31710fbdb6059755f009e02f0ccc2b9d289beb6b086Colin Cross } 31810fbdb6059755f009e02f0ccc2b9d289beb6b086Colin Cross } 31910fbdb6059755f009e02f0ccc2b9d289beb6b086Colin Cross } 32010fbdb6059755f009e02f0ccc2b9d289beb6b086Colin Cross 32110fbdb6059755f009e02f0ccc2b9d289beb6b086Colin Cross return NO_ERROR; 32210fbdb6059755f009e02f0ccc2b9d289beb6b086Colin Cross} 32310fbdb6059755f009e02f0ccc2b9d289beb6b086Colin Cross 3247ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopianstatus_t HWComposer::disable() { 3257ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopian if (mHwc) { 3267ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopian free(mList); 3277ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopian mList = NULL; 3287ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopian int err = mHwc->prepare(mHwc, NULL); 3297ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopian return (status_t)err; 3307ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopian } 3317ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopian return NO_ERROR; 332f5f2712854599b4970643c6000fe6ae950a08ba9Antti Hatala} 333f5f2712854599b4970643c6000fe6ae950a08ba9Antti Hatala 33445721773e1a68e96da4b6cc04cef276bae7ca3e9Mathias Agopiansize_t HWComposer::getNumLayers() const { 33545721773e1a68e96da4b6cc04cef276bae7ca3e9Mathias Agopian return mList ? mList->numHwLayers : 0; 336a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian} 337a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian 3383e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian/* 3393e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian * Helper template to implement a concrete HWCLayer 3403e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian * This holds the pointer to the concrete hwc layer type 3413e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian * and implements the "iterable" side of HWCLayer. 3423e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian */ 3433e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopiantemplate<typename CONCRETE, typename HWCTYPE> 3443e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopianclass Iterable : public HWComposer::HWCLayer { 3453e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopianprotected: 3463e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian HWCTYPE* const mLayerList; 3473e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian HWCTYPE* mCurrentLayer; 3483e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian Iterable(HWCTYPE* layer) : mLayerList(layer), mCurrentLayer(layer) { } 3493e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian inline HWCTYPE const * getLayer() const { return mCurrentLayer; } 3503e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian inline HWCTYPE* getLayer() { return mCurrentLayer; } 3513e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian virtual ~Iterable() { } 3523e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopianprivate: 3533e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian // returns a copy of ourselves 3543e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian virtual HWComposer::HWCLayer* dup() { 3553e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian return new CONCRETE( static_cast<const CONCRETE&>(*this) ); 3563e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian } 3573e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian virtual status_t setLayer(size_t index) { 3583e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian mCurrentLayer = &mLayerList[index]; 3593e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian return NO_ERROR; 3603e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian } 3613e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian}; 3623e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian 3635880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall// #if !HWC_REMOVE_DEPRECATED_VERSIONS 3643e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian/* 3653e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian * Concrete implementation of HWCLayer for HWC_DEVICE_API_VERSION_0_3 3663e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian * This implements the HWCLayer side of HWCIterableLayer. 3673e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian */ 3685880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hallclass HWCLayerVersion0 : public Iterable<HWCLayerVersion0, hwc_layer_t> { 3695880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hallpublic: 3705880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall HWCLayerVersion0(hwc_layer_t* layer) 3715880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall : Iterable<HWCLayerVersion0, hwc_layer_t>(layer) { } 3725880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall 3735880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall virtual int32_t getCompositionType() const { 3745880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall return getLayer()->compositionType; 3755880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall } 3765880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall virtual uint32_t getHints() const { 3775880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall return getLayer()->hints; 3785880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall } 379ef19414bd8b77a26f5751f3845be79025a8263feJesse Hall virtual int getAndResetReleaseFenceFd() { 380ef19414bd8b77a26f5751f3845be79025a8263feJesse Hall // not supported on VERSION_03 381ef19414bd8b77a26f5751f3845be79025a8263feJesse Hall return -1; 382ef19414bd8b77a26f5751f3845be79025a8263feJesse Hall } 383dc5b485f74edf2d2f31c62054eb6c180421a3adeJesse Hall virtual void setAcquireFenceFd(int fenceFd) { 384dc5b485f74edf2d2f31c62054eb6c180421a3adeJesse Hall if (fenceFd != -1) { 385dc5b485f74edf2d2f31c62054eb6c180421a3adeJesse Hall ALOGE("HWC 0.x can't handle acquire fences"); 386dc5b485f74edf2d2f31c62054eb6c180421a3adeJesse Hall close(fenceFd); 387dc5b485f74edf2d2f31c62054eb6c180421a3adeJesse Hall } 388dc5b485f74edf2d2f31c62054eb6c180421a3adeJesse Hall } 3895880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall 3905880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall virtual void setDefaultState() { 3915880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall getLayer()->compositionType = HWC_FRAMEBUFFER; 3925880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall getLayer()->hints = 0; 3935880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall getLayer()->flags = HWC_SKIP_LAYER; 3945880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall getLayer()->transform = 0; 3955880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall getLayer()->blending = HWC_BLENDING_NONE; 3965880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall getLayer()->visibleRegionScreen.numRects = 0; 3975880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall getLayer()->visibleRegionScreen.rects = NULL; 3985880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall } 3995880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall virtual void setSkip(bool skip) { 4005880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall if (skip) { 4015880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall getLayer()->flags |= HWC_SKIP_LAYER; 4025880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall } else { 4035880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall getLayer()->flags &= ~HWC_SKIP_LAYER; 4045880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall } 4055880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall } 4065880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall virtual void setBlending(uint32_t blending) { 4075880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall getLayer()->blending = blending; 4085880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall } 4095880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall virtual void setTransform(uint32_t transform) { 4105880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall getLayer()->transform = transform; 4115880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall } 4125880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall virtual void setFrame(const Rect& frame) { 4135880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall reinterpret_cast<Rect&>(getLayer()->displayFrame) = frame; 4145880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall } 4155880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall virtual void setCrop(const Rect& crop) { 4165880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall reinterpret_cast<Rect&>(getLayer()->sourceCrop) = crop; 4175880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall } 4185880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall virtual void setVisibleRegionScreen(const Region& reg) { 4195880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall getLayer()->visibleRegionScreen.rects = 4205880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall reinterpret_cast<hwc_rect_t const *>( 4215880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall reg.getArray(&getLayer()->visibleRegionScreen.numRects)); 4225880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall } 4235880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall virtual void setBuffer(const sp<GraphicBuffer>& buffer) { 4245880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall if (buffer == 0 || buffer->handle == 0) { 4255880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall getLayer()->compositionType = HWC_FRAMEBUFFER; 4265880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall getLayer()->flags |= HWC_SKIP_LAYER; 4275880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall getLayer()->handle = 0; 4285880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall } else { 4295880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall getLayer()->handle = buffer->handle; 4305880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall } 4315880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall } 4325880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall}; 4335880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall// #endif // !HWC_REMOVE_DEPRECATED_VERSIONS 4345880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall 4355880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall/* 4365880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall * Concrete implementation of HWCLayer for HWC_DEVICE_API_VERSION_1_0. 4375880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall * This implements the HWCLayer side of HWCIterableLayer. 4385880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall */ 4395880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hallclass HWCLayerVersion1 : public Iterable<HWCLayerVersion1, hwc_layer_1_t> { 4403e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopianpublic: 4415880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall HWCLayerVersion1(hwc_layer_1_t* layer) 4425880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall : Iterable<HWCLayerVersion1, hwc_layer_1_t>(layer) { } 4433e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian 4443e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian virtual int32_t getCompositionType() const { 4453e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian return getLayer()->compositionType; 4463e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian } 4473e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian virtual uint32_t getHints() const { 4483e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian return getLayer()->hints; 4493e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian } 450ef19414bd8b77a26f5751f3845be79025a8263feJesse Hall virtual int getAndResetReleaseFenceFd() { 451ef19414bd8b77a26f5751f3845be79025a8263feJesse Hall int fd = getLayer()->releaseFenceFd; 452ef19414bd8b77a26f5751f3845be79025a8263feJesse Hall getLayer()->releaseFenceFd = -1; 453ef19414bd8b77a26f5751f3845be79025a8263feJesse Hall return fd; 454ef19414bd8b77a26f5751f3845be79025a8263feJesse Hall } 455dc5b485f74edf2d2f31c62054eb6c180421a3adeJesse Hall virtual void setAcquireFenceFd(int fenceFd) { 456dc5b485f74edf2d2f31c62054eb6c180421a3adeJesse Hall getLayer()->acquireFenceFd = fenceFd; 457dc5b485f74edf2d2f31c62054eb6c180421a3adeJesse Hall } 4583e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian 4593e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian virtual void setDefaultState() { 4603e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian getLayer()->compositionType = HWC_FRAMEBUFFER; 4613e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian getLayer()->hints = 0; 4623e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian getLayer()->flags = HWC_SKIP_LAYER; 4633e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian getLayer()->transform = 0; 4643e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian getLayer()->blending = HWC_BLENDING_NONE; 4653e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian getLayer()->visibleRegionScreen.numRects = 0; 4663e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian getLayer()->visibleRegionScreen.rects = NULL; 4675880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall getLayer()->acquireFenceFd = -1; 4685880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall getLayer()->releaseFenceFd = -1; 4693e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian } 4703e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian virtual void setSkip(bool skip) { 4713e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian if (skip) { 4723e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian getLayer()->flags |= HWC_SKIP_LAYER; 4733e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian } else { 4743e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian getLayer()->flags &= ~HWC_SKIP_LAYER; 4753e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian } 4763e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian } 4773e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian virtual void setBlending(uint32_t blending) { 4783e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian getLayer()->blending = blending; 4793e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian } 4803e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian virtual void setTransform(uint32_t transform) { 4813e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian getLayer()->transform = transform; 4823e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian } 4833e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian virtual void setFrame(const Rect& frame) { 4843e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian reinterpret_cast<Rect&>(getLayer()->displayFrame) = frame; 4853e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian } 4863e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian virtual void setCrop(const Rect& crop) { 4873e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian reinterpret_cast<Rect&>(getLayer()->sourceCrop) = crop; 4883e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian } 4893e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian virtual void setVisibleRegionScreen(const Region& reg) { 4903e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian getLayer()->visibleRegionScreen.rects = 4913e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian reinterpret_cast<hwc_rect_t const *>( 4923e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian reg.getArray(&getLayer()->visibleRegionScreen.numRects)); 4933e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian } 4943e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian virtual void setBuffer(const sp<GraphicBuffer>& buffer) { 4953e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian if (buffer == 0 || buffer->handle == 0) { 4963e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian getLayer()->compositionType = HWC_FRAMEBUFFER; 4973e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian getLayer()->flags |= HWC_SKIP_LAYER; 4983e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian getLayer()->handle = 0; 4993e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian } else { 5003e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian getLayer()->handle = buffer->handle; 5013e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian } 5023e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian } 5033e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian}; 5043e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian 5053e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian/* 5063e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian * returns an iterator initialized at a given index in the layer list 5073e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian */ 5083e8b853d67c737abdb363f9c978e7d83eac4d888Mathias AgopianHWComposer::LayerListIterator HWComposer::getLayerIterator(size_t index) { 5093e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian if (!mList || index > mList->numHwLayers) { 5103e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian return LayerListIterator(); 5113e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian } 5125880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall if (hwcHasVersion(mHwc, HWC_DEVICE_API_VERSION_1_0)) { 5135880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall return LayerListIterator(new HWCLayerVersion1(mList->hwLayers), index); 5145880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall } else { 5155880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall hwc_layer_list_t* list0 = (hwc_layer_list_t*)mList; 5165880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall return LayerListIterator(new HWCLayerVersion0(list0->hwLayers), index); 5175880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall } 5183e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian} 5193e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian 5203e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian/* 5213e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian * returns an iterator on the beginning of the layer list 5223e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian */ 5233e8b853d67c737abdb363f9c978e7d83eac4d888Mathias AgopianHWComposer::LayerListIterator HWComposer::begin() { 5243e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian return getLayerIterator(0); 525a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian} 526a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian 5273e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian/* 5283e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian * returns an iterator on the end of the layer list 5293e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian */ 5303e8b853d67c737abdb363f9c978e7d83eac4d888Mathias AgopianHWComposer::LayerListIterator HWComposer::end() { 5313e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian return getLayerIterator(getNumLayers()); 5323e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian} 5333e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian 5343e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian 5353e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian 53622da60c3e64cd57535cbba063c07127814a2b52fMathias Agopianvoid HWComposer::dump(String8& result, char* buffer, size_t SIZE, 53722da60c3e64cd57535cbba063c07127814a2b52fMathias Agopian const Vector< sp<LayerBase> >& visibleLayersSortedByZ) const { 5388372785879d329f592f6883620b5a32d80d74691Mathias Agopian if (mHwc && mList) { 5398372785879d329f592f6883620b5a32d80d74691Mathias Agopian result.append("Hardware Composer state:\n"); 540e2c4f4ec23b735dd2a03f4ea8b08b288a1bb04e8Mathias Agopian result.appendFormat(" mDebugForceFakeVSync=%d\n", 541e2c4f4ec23b735dd2a03f4ea8b08b288a1bb04e8Mathias Agopian mDebugForceFakeVSync); 542e2c4f4ec23b735dd2a03f4ea8b08b288a1bb04e8Mathias Agopian result.appendFormat(" numHwLayers=%u, flags=%08x\n", 5438372785879d329f592f6883620b5a32d80d74691Mathias Agopian mList->numHwLayers, mList->flags); 544fb4d5d5726c172adbe62341d99a2148685a98379Mathias Agopian result.append( 545aebac5f34a098f733f887c993bd617a393e10db8Mathias Agopian " type | handle | hints | flags | tr | blend | format | source crop | frame name \n" 546aebac5f34a098f733f887c993bd617a393e10db8Mathias Agopian "----------+----------+----------+----------+----+-------+----------+---------------------------+--------------------------------\n"); 547aebac5f34a098f733f887c993bd617a393e10db8Mathias Agopian // " ________ | ________ | ________ | ________ | __ | _____ | ________ | [_____,_____,_____,_____] | [_____,_____,_____,_____] 5488372785879d329f592f6883620b5a32d80d74691Mathias Agopian for (size_t i=0 ; i<mList->numHwLayers ; i++) { 5495880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall hwc_layer_1_t l; 5505880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall if (hwcHasVersion(mHwc, HWC_DEVICE_API_VERSION_1_0)) { 5515880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall l = mList->hwLayers[i]; 5525880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall } else { 5535880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall hwc_layer_list_t* list0 = (hwc_layer_list_t*)mList; 5545880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall *(hwc_layer_t*)&l = list0->hwLayers[i]; 5555880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall l.acquireFenceFd = l.releaseFenceFd = -1; 5565880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall } 557fb4d5d5726c172adbe62341d99a2148685a98379Mathias Agopian const sp<LayerBase> layer(visibleLayersSortedByZ[i]); 558fb4d5d5726c172adbe62341d99a2148685a98379Mathias Agopian int32_t format = -1; 559fb4d5d5726c172adbe62341d99a2148685a98379Mathias Agopian if (layer->getLayer() != NULL) { 560fb4d5d5726c172adbe62341d99a2148685a98379Mathias Agopian const sp<GraphicBuffer>& buffer(layer->getLayer()->getActiveBuffer()); 561fb4d5d5726c172adbe62341d99a2148685a98379Mathias Agopian if (buffer != NULL) { 562fb4d5d5726c172adbe62341d99a2148685a98379Mathias Agopian format = buffer->getPixelFormat(); 563fb4d5d5726c172adbe62341d99a2148685a98379Mathias Agopian } 564fb4d5d5726c172adbe62341d99a2148685a98379Mathias Agopian } 565e2c4f4ec23b735dd2a03f4ea8b08b288a1bb04e8Mathias Agopian result.appendFormat( 566aebac5f34a098f733f887c993bd617a393e10db8Mathias Agopian " %8s | %08x | %08x | %08x | %02x | %05x | %08x | [%5d,%5d,%5d,%5d] | [%5d,%5d,%5d,%5d] %s\n", 5678372785879d329f592f6883620b5a32d80d74691Mathias Agopian l.compositionType ? "OVERLAY" : "FB", 568aebac5f34a098f733f887c993bd617a393e10db8Mathias Agopian intptr_t(l.handle), l.hints, l.flags, l.transform, l.blending, format, 5698372785879d329f592f6883620b5a32d80d74691Mathias Agopian l.sourceCrop.left, l.sourceCrop.top, l.sourceCrop.right, l.sourceCrop.bottom, 57022da60c3e64cd57535cbba063c07127814a2b52fMathias Agopian l.displayFrame.left, l.displayFrame.top, l.displayFrame.right, l.displayFrame.bottom, 571fb4d5d5726c172adbe62341d99a2148685a98379Mathias Agopian layer->getName().string()); 5728372785879d329f592f6883620b5a32d80d74691Mathias Agopian } 5731d21a9cafc534c34a2f28c985c4c7aa176d0e67bErik Gilling } 5745880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall if (mHwc && hwcHasVersion(mHwc, HWC_DEVICE_API_VERSION_0_1) && mHwc->dump) { 5751d21a9cafc534c34a2f28c985c4c7aa176d0e67bErik Gilling mHwc->dump(mHwc, buffer, SIZE); 5761d21a9cafc534c34a2f28c985c4c7aa176d0e67bErik Gilling result.append(buffer); 5778372785879d329f592f6883620b5a32d80d74691Mathias Agopian } 5788372785879d329f592f6883620b5a32d80d74691Mathias Agopian} 5798372785879d329f592f6883620b5a32d80d74691Mathias Agopian 580a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian// --------------------------------------------------------------------------- 5812965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian 5822965b26022f95051f65b09d7eac47cbe923855c9Mathias AgopianHWComposer::VSyncThread::VSyncThread(HWComposer& hwc) 5832965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian : mHwc(hwc), mEnabled(false), 5842965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian mNextFakeVSync(0), 5852965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian mRefreshPeriod(hwc.mRefreshPeriod) 5862965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian{ 5872965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian} 5882965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian 5892965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopianvoid HWComposer::VSyncThread::setEnabled(bool enabled) { 5902965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian Mutex::Autolock _l(mLock); 5912965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian mEnabled = enabled; 5922965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian mCondition.signal(); 5932965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian} 5942965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian 5952965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopianvoid HWComposer::VSyncThread::onFirstRef() { 5962965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian run("VSyncThread", PRIORITY_URGENT_DISPLAY + PRIORITY_MORE_FAVORABLE); 5972965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian} 5982965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian 5992965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopianbool HWComposer::VSyncThread::threadLoop() { 6002965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian { // scope for lock 6012965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian Mutex::Autolock _l(mLock); 6022965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian while (!mEnabled) { 6032965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian mCondition.wait(mLock); 6042965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian } 6052965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian } 6062965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian 6072965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian const nsecs_t period = mRefreshPeriod; 6082965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian const nsecs_t now = systemTime(CLOCK_MONOTONIC); 6092965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian nsecs_t next_vsync = mNextFakeVSync; 6102965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian nsecs_t sleep = next_vsync - now; 6112965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian if (sleep < 0) { 6122965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian // we missed, find where the next vsync should be 6132965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian sleep = (period - ((now - next_vsync) % period)); 6142965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian next_vsync = now + sleep; 6152965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian } 6162965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian mNextFakeVSync = next_vsync + period; 6172965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian 6182965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian struct timespec spec; 6192965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian spec.tv_sec = next_vsync / 1000000000; 6202965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian spec.tv_nsec = next_vsync % 1000000000; 6212965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian 6222965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian int err; 6232965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian do { 6242965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian err = clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &spec, NULL); 6252965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian } while (err<0 && errno == EINTR); 6262965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian 6272965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian if (err == 0) { 6282965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian mHwc.mEventHandler.onVSyncReceived(0, next_vsync); 6292965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian } 6302965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian 6312965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian return true; 6322965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian} 6332965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian 6342965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian// --------------------------------------------------------------------------- 635a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian}; // namespace android 636