HWComposer.cpp revision 3eb38cb33e41ce40dd1094bdec850f0fca9f8a53
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
17a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian#include <stdint.h>
18f1352df47fe20aed23c216a78923c7d248f2bb91Mathias Agopian#include <stdio.h>
19f1352df47fe20aed23c216a78923c7d248f2bb91Mathias Agopian#include <stdlib.h>
20f1352df47fe20aed23c216a78923c7d248f2bb91Mathias Agopian#include <string.h>
21a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian#include <sys/types.h>
22a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
23a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian#include <utils/Errors.h>
248372785879d329f592f6883620b5a32d80d74691Mathias Agopian#include <utils/String8.h>
253eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian#include <utils/Thread.h>
2622da60c3e64cd57535cbba063c07127814a2b52fMathias Agopian#include <utils/Vector.h>
27a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
28a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian#include <hardware/hardware.h>
293eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian#include <hardware/hwcomposer.h>
30a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
31a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian#include <cutils/log.h>
32a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
33a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian#include <EGL/egl.h>
34a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
3522da60c3e64cd57535cbba063c07127814a2b52fMathias Agopian#include "LayerBase.h"
36a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian#include "HWComposer.h"
37c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian#include "SurfaceFlinger.h"
38a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
39a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopiannamespace android {
40a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian// ---------------------------------------------------------------------------
41a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
423eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias AgopianHWComposer::HWComposer(
433eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian        const sp<SurfaceFlinger>& flinger,
443eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian        EventHandler& handler,
453eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian        nsecs_t refreshPeriod)
46c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian    : mFlinger(flinger),
47c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian      mModule(0), mHwc(0), mList(0), mCapacity(0),
489c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian      mNumOVLayers(0), mNumFBLayers(0),
493eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian      mDpy(EGL_NO_DISPLAY), mSur(EGL_NO_SURFACE),
503eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian      mEventHandler(handler),
513eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian      mRefreshPeriod(refreshPeriod)
52a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian{
53a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    int err = hw_get_module(HWC_HARDWARE_MODULE_ID, &mModule);
5432397c1cd3327905173b36baa6fd1c579bc328ffSteve Block    ALOGW_IF(err, "%s module not found", HWC_HARDWARE_MODULE_ID);
55a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    if (err == 0) {
56a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian        err = hwc_open(mModule, &mHwc);
57e6f43ddce78d6846af12550ff9193c5c6fe5844bSteve Block        ALOGE_IF(err, "%s device failed to initialize (%s)",
58a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian                HWC_HARDWARE_COMPOSER, strerror(-err));
59c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian        if (err == 0) {
60c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian            if (mHwc->registerProcs) {
61c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian                mCBContext.hwc = this;
62c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian                mCBContext.procs.invalidate = &hook_invalidate;
6331d2843b45ebdb69ec3355111b7567363fd2a6b7Mathias Agopian                mCBContext.procs.vsync = &hook_vsync;
64c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian                mHwc->registerProcs(mHwc, &mCBContext.procs);
6531d2843b45ebdb69ec3355111b7567363fd2a6b7Mathias Agopian                memset(mCBContext.procs.zero, 0, sizeof(mCBContext.procs.zero));
66c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian            }
673eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian
683eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian            if (mHwc->common.version < HWC_DEVICE_API_VERSION_0_3) {
693eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian                // we don't have VSYNC support, we need to fake it
703eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian                mVSyncThread = new VSyncThread(*this);
713eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian            }
72c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian        }
73a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    }
74a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian}
75a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
76a350ff98692b3a50cad5cc93f9f83221242ca86aMathias AgopianHWComposer::~HWComposer() {
77a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    free(mList);
783eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian    if (mVSyncThread != NULL) {
793eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian        mVSyncThread->requestExitAndWait();
803eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian    }
81a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    if (mHwc) {
82a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian        hwc_close(mHwc);
83a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    }
84a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian}
85a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
86a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopianstatus_t HWComposer::initCheck() const {
87a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    return mHwc ? NO_ERROR : NO_INIT;
88a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian}
89a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
90c7d14e247117392fbd44aa454622778a25c076aeMathias Agopianvoid HWComposer::hook_invalidate(struct hwc_procs* procs) {
91c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian    reinterpret_cast<cb_context *>(procs)->hwc->invalidate();
92c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian}
93c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian
9431d2843b45ebdb69ec3355111b7567363fd2a6b7Mathias Agopianvoid HWComposer::hook_vsync(struct hwc_procs* procs, int dpy, int64_t timestamp) {
9531d2843b45ebdb69ec3355111b7567363fd2a6b7Mathias Agopian    reinterpret_cast<cb_context *>(procs)->hwc->vsync(dpy, timestamp);
9631d2843b45ebdb69ec3355111b7567363fd2a6b7Mathias Agopian}
9731d2843b45ebdb69ec3355111b7567363fd2a6b7Mathias Agopian
98c7d14e247117392fbd44aa454622778a25c076aeMathias Agopianvoid HWComposer::invalidate() {
99e2c2f9213f936f98db604dc9c126ff22f725a824Mathias Agopian    mFlinger->repaintEverything();
100c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian}
101c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian
10231d2843b45ebdb69ec3355111b7567363fd2a6b7Mathias Agopianvoid HWComposer::vsync(int dpy, int64_t timestamp) {
1033eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian    mEventHandler.onVSyncReceived(dpy, timestamp);
1043eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian}
1053eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian
1063eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopianstatus_t HWComposer::eventControl(int event, int enabled) {
1073eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian    status_t err = NO_ERROR;
1083eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian    if (mHwc->common.version >= HWC_DEVICE_API_VERSION_0_3) {
1093eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian        err = mHwc->methods->eventControl(mHwc, event, enabled);
1103eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian    } else {
1113eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian        if (mVSyncThread != NULL) {
1123eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian            mVSyncThread->setEnabled(enabled);
1133eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian        } else {
1143eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian            err = BAD_VALUE;
1153eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian        }
1163eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian    }
1173eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian    return err;
11831d2843b45ebdb69ec3355111b7567363fd2a6b7Mathias Agopian}
11931d2843b45ebdb69ec3355111b7567363fd2a6b7Mathias Agopian
120a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopianvoid HWComposer::setFrameBuffer(EGLDisplay dpy, EGLSurface sur) {
121a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    mDpy = (hwc_display_t)dpy;
122a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    mSur = (hwc_surface_t)sur;
123a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian}
124a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
125a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopianstatus_t HWComposer::createWorkList(size_t numLayers) {
12645721773e1a68e96da4b6cc04cef276bae7ca3e9Mathias Agopian    if (mHwc) {
12745721773e1a68e96da4b6cc04cef276bae7ca3e9Mathias Agopian        if (!mList || mCapacity < numLayers) {
12845721773e1a68e96da4b6cc04cef276bae7ca3e9Mathias Agopian            free(mList);
12945721773e1a68e96da4b6cc04cef276bae7ca3e9Mathias Agopian            size_t size = sizeof(hwc_layer_list) + numLayers*sizeof(hwc_layer_t);
13045721773e1a68e96da4b6cc04cef276bae7ca3e9Mathias Agopian            mList = (hwc_layer_list_t*)malloc(size);
13145721773e1a68e96da4b6cc04cef276bae7ca3e9Mathias Agopian            mCapacity = numLayers;
13245721773e1a68e96da4b6cc04cef276bae7ca3e9Mathias Agopian        }
133a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian        mList->flags = HWC_GEOMETRY_CHANGED;
134a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian        mList->numHwLayers = numLayers;
135a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    }
136a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    return NO_ERROR;
137a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian}
138a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
139a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopianstatus_t HWComposer::prepare() const {
140a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    int err = mHwc->prepare(mHwc, mList);
1419c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian    if (err == NO_ERROR) {
1429c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian        size_t numOVLayers = 0;
1439c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian        size_t numFBLayers = 0;
1449c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian        size_t count = mList->numHwLayers;
1459c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian        for (size_t i=0 ; i<count ; i++) {
1469c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian            hwc_layer& l(mList->hwLayers[i]);
1479c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian            if (l.flags & HWC_SKIP_LAYER) {
1489c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian                l.compositionType = HWC_FRAMEBUFFER;
1499c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian            }
1509c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian            switch (l.compositionType) {
1519c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian                case HWC_OVERLAY:
1529c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian                    numOVLayers++;
1539c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian                    break;
1549c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian                case HWC_FRAMEBUFFER:
1559c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian                    numFBLayers++;
1569c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian                    break;
1579c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian            }
1589c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian        }
1599c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian        mNumOVLayers = numOVLayers;
1609c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian        mNumFBLayers = numFBLayers;
1619c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian    }
162a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    return (status_t)err;
163a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian}
164a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
1659c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopiansize_t HWComposer::getLayerCount(int type) const {
1669c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian    switch (type) {
1679c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian        case HWC_OVERLAY:
1689c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian            return mNumOVLayers;
1699c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian        case HWC_FRAMEBUFFER:
1709c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian            return mNumFBLayers;
1719c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian    }
1729c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian    return 0;
1739c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian}
1749c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian
175a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopianstatus_t HWComposer::commit() const {
176a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    int err = mHwc->set(mHwc, mDpy, mSur, mList);
17758959343dbdb6157fa5f5463262d4842b8954353Mathias Agopian    if (mList) {
17858959343dbdb6157fa5f5463262d4842b8954353Mathias Agopian        mList->flags &= ~HWC_GEOMETRY_CHANGED;
17958959343dbdb6157fa5f5463262d4842b8954353Mathias Agopian    }
180a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    return (status_t)err;
181a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian}
182a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
183f5f2712854599b4970643c6000fe6ae950a08ba9Antti Hatalastatus_t HWComposer::release() const {
1847ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopian    if (mHwc) {
1857ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopian        int err = mHwc->set(mHwc, NULL, NULL, NULL);
1867ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopian        return (status_t)err;
1877ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopian    }
1887ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopian    return NO_ERROR;
1897ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopian}
1907ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopian
1917ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopianstatus_t HWComposer::disable() {
1927ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopian    if (mHwc) {
1937ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopian        free(mList);
1947ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopian        mList = NULL;
1957ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopian        int err = mHwc->prepare(mHwc, NULL);
1967ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopian        return (status_t)err;
1977ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopian    }
1987ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopian    return NO_ERROR;
199f5f2712854599b4970643c6000fe6ae950a08ba9Antti Hatala}
200f5f2712854599b4970643c6000fe6ae950a08ba9Antti Hatala
20145721773e1a68e96da4b6cc04cef276bae7ca3e9Mathias Agopiansize_t HWComposer::getNumLayers() const {
20245721773e1a68e96da4b6cc04cef276bae7ca3e9Mathias Agopian    return mList ? mList->numHwLayers : 0;
203a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian}
204a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
20545721773e1a68e96da4b6cc04cef276bae7ca3e9Mathias Agopianhwc_layer_t* HWComposer::getLayers() const {
20645721773e1a68e96da4b6cc04cef276bae7ca3e9Mathias Agopian    return mList ? mList->hwLayers : 0;
207a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian}
208a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
20922da60c3e64cd57535cbba063c07127814a2b52fMathias Agopianvoid HWComposer::dump(String8& result, char* buffer, size_t SIZE,
21022da60c3e64cd57535cbba063c07127814a2b52fMathias Agopian        const Vector< sp<LayerBase> >& visibleLayersSortedByZ) const {
2118372785879d329f592f6883620b5a32d80d74691Mathias Agopian    if (mHwc && mList) {
2128372785879d329f592f6883620b5a32d80d74691Mathias Agopian        result.append("Hardware Composer state:\n");
2138372785879d329f592f6883620b5a32d80d74691Mathias Agopian
2148372785879d329f592f6883620b5a32d80d74691Mathias Agopian        snprintf(buffer, SIZE, "  numHwLayers=%u, flags=%08x\n",
2158372785879d329f592f6883620b5a32d80d74691Mathias Agopian                mList->numHwLayers, mList->flags);
2168372785879d329f592f6883620b5a32d80d74691Mathias Agopian        result.append(buffer);
217fb4d5d5726c172adbe62341d99a2148685a98379Mathias Agopian        result.append(
218aebac5f34a098f733f887c993bd617a393e10db8Mathias Agopian                "   type   |  handle  |   hints  |   flags  | tr | blend |  format  |       source crop         |           frame           name \n"
219aebac5f34a098f733f887c993bd617a393e10db8Mathias Agopian                "----------+----------+----------+----------+----+-------+----------+---------------------------+--------------------------------\n");
220aebac5f34a098f733f887c993bd617a393e10db8Mathias Agopian        //      " ________ | ________ | ________ | ________ | __ | _____ | ________ | [_____,_____,_____,_____] | [_____,_____,_____,_____]
2218372785879d329f592f6883620b5a32d80d74691Mathias Agopian        for (size_t i=0 ; i<mList->numHwLayers ; i++) {
2228372785879d329f592f6883620b5a32d80d74691Mathias Agopian            const hwc_layer_t& l(mList->hwLayers[i]);
223fb4d5d5726c172adbe62341d99a2148685a98379Mathias Agopian            const sp<LayerBase> layer(visibleLayersSortedByZ[i]);
224fb4d5d5726c172adbe62341d99a2148685a98379Mathias Agopian            int32_t format = -1;
225fb4d5d5726c172adbe62341d99a2148685a98379Mathias Agopian            if (layer->getLayer() != NULL) {
226fb4d5d5726c172adbe62341d99a2148685a98379Mathias Agopian                const sp<GraphicBuffer>& buffer(layer->getLayer()->getActiveBuffer());
227fb4d5d5726c172adbe62341d99a2148685a98379Mathias Agopian                if (buffer != NULL) {
228fb4d5d5726c172adbe62341d99a2148685a98379Mathias Agopian                    format = buffer->getPixelFormat();
229fb4d5d5726c172adbe62341d99a2148685a98379Mathias Agopian                }
230fb4d5d5726c172adbe62341d99a2148685a98379Mathias Agopian            }
231fb4d5d5726c172adbe62341d99a2148685a98379Mathias Agopian            snprintf(buffer, SIZE,
232aebac5f34a098f733f887c993bd617a393e10db8Mathias Agopian                    " %8s | %08x | %08x | %08x | %02x | %05x | %08x | [%5d,%5d,%5d,%5d] | [%5d,%5d,%5d,%5d] %s\n",
2338372785879d329f592f6883620b5a32d80d74691Mathias Agopian                    l.compositionType ? "OVERLAY" : "FB",
234aebac5f34a098f733f887c993bd617a393e10db8Mathias Agopian                    intptr_t(l.handle), l.hints, l.flags, l.transform, l.blending, format,
2358372785879d329f592f6883620b5a32d80d74691Mathias Agopian                    l.sourceCrop.left, l.sourceCrop.top, l.sourceCrop.right, l.sourceCrop.bottom,
23622da60c3e64cd57535cbba063c07127814a2b52fMathias Agopian                    l.displayFrame.left, l.displayFrame.top, l.displayFrame.right, l.displayFrame.bottom,
237fb4d5d5726c172adbe62341d99a2148685a98379Mathias Agopian                    layer->getName().string());
2388372785879d329f592f6883620b5a32d80d74691Mathias Agopian            result.append(buffer);
2398372785879d329f592f6883620b5a32d80d74691Mathias Agopian        }
2401d21a9cafc534c34a2f28c985c4c7aa176d0e67bErik Gilling    }
2411d21a9cafc534c34a2f28c985c4c7aa176d0e67bErik Gilling    if (mHwc && mHwc->common.version >= 1 && mHwc->dump) {
2421d21a9cafc534c34a2f28c985c4c7aa176d0e67bErik Gilling        mHwc->dump(mHwc, buffer, SIZE);
2431d21a9cafc534c34a2f28c985c4c7aa176d0e67bErik Gilling        result.append(buffer);
2448372785879d329f592f6883620b5a32d80d74691Mathias Agopian    }
2458372785879d329f592f6883620b5a32d80d74691Mathias Agopian}
2468372785879d329f592f6883620b5a32d80d74691Mathias Agopian
247a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian// ---------------------------------------------------------------------------
248a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian}; // namespace android
249