HWComposer.h revision 8b736f138cfd9b239a2c7073347a13c489534ae1
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#ifndef ANDROID_SF_HWCOMPOSER_H
18a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian#define ANDROID_SF_HWCOMPOSER_H
19a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
20a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian#include <stdint.h>
21a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian#include <sys/types.h>
22a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
233e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian#include <hardware/hwcomposer_defs.h>
24a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
25921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian#include <utils/Condition.h>
26921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian#include <utils/Mutex.h>
27c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian#include <utils/StrongPointer.h>
28921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian#include <utils/Thread.h>
29921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopian#include <utils/Timers.h>
3022da60c3e64cd57535cbba063c07127814a2b52fMathias Agopian#include <utils/Vector.h>
31c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian
323eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopianextern "C" int clock_nanosleep(clockid_t clock_id, int flags,
333eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian                           const struct timespec *request,
343eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian                           struct timespec *remain);
353eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian
365880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hallstruct hwc_composer_device_1;
37b685c542836b93c99cd85053e07696406ea37adbJesse Hallstruct hwc_display_contents_1;
383e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopianstruct hwc_procs;
398b736f138cfd9b239a2c7073347a13c489534ae1Mathias Agopianstruct framebuffer_device_t;
403e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian
41a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopiannamespace android {
42a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian// ---------------------------------------------------------------------------
43a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
44921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopianclass GraphicBuffer;
45921e6ac4b7610a178285898d191eb0e3afe906c0Mathias Agopianclass LayerBase;
461a4d883dcc1725892bfb5c28dec255a233186524Jamie Gennisclass Region;
478372785879d329f592f6883620b5a32d80d74691Mathias Agopianclass String8;
48c7d14e247117392fbd44aa454622778a25c076aeMathias Agopianclass SurfaceFlinger;
498372785879d329f592f6883620b5a32d80d74691Mathias Agopian
50a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopianclass HWComposer
51a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian{
52a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopianpublic:
533eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian    class EventHandler {
543eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian        friend class HWComposer;
553eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian        virtual void onVSyncReceived(int dpy, nsecs_t timestamp) = 0;
563eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian    protected:
573eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian        virtual ~EventHandler() {}
583eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian    };
59a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
601e26087493ac0e7d7dc6dea8ad85cfef08b3271fMathias Agopian    enum {
611e26087493ac0e7d7dc6dea8ad85cfef08b3271fMathias Agopian        MAIN = 0,
621e26087493ac0e7d7dc6dea8ad85cfef08b3271fMathias Agopian        HDMI = 1,
631e26087493ac0e7d7dc6dea8ad85cfef08b3271fMathias Agopian        MAX_DISPLAYS
641e26087493ac0e7d7dc6dea8ad85cfef08b3271fMathias Agopian    };
651e26087493ac0e7d7dc6dea8ad85cfef08b3271fMathias Agopian
668b736f138cfd9b239a2c7073347a13c489534ae1Mathias Agopian    HWComposer(
678b736f138cfd9b239a2c7073347a13c489534ae1Mathias Agopian            const sp<SurfaceFlinger>& flinger,
688b736f138cfd9b239a2c7073347a13c489534ae1Mathias Agopian            EventHandler& handler,
698b736f138cfd9b239a2c7073347a13c489534ae1Mathias Agopian            framebuffer_device_t const* fbDev);
708b736f138cfd9b239a2c7073347a13c489534ae1Mathias Agopian
71a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    ~HWComposer();
72a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
73a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    status_t initCheck() const;
74a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
75a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    // Asks the HAL what it can do
76a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    status_t prepare() const;
77a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
787ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopian    // disable hwc until next createWorkList
797ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopian    status_t disable();
807ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopian
81a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    // commits the list
8234a09ba1efd706323a15633da5044b352988eb5fJesse Hall    status_t commit(void* fbDisplay, void* fbSurface) const;
83a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
8410fbdb6059755f009e02f0ccc2b9d289beb6b086Colin Cross    // release hardware resources and blank screen
85f5f2712854599b4970643c6000fe6ae950a08ba9Antti Hatala    status_t release() const;
86a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
8710fbdb6059755f009e02f0ccc2b9d289beb6b086Colin Cross    // acquire hardware resources and unblank screen
8810fbdb6059755f009e02f0ccc2b9d289beb6b086Colin Cross    status_t acquire() const;
8910fbdb6059755f009e02f0ccc2b9d289beb6b086Colin Cross
903e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian    // create a work list for numLayers layer. sets HWC_GEOMETRY_CHANGED.
911e26087493ac0e7d7dc6dea8ad85cfef08b3271fMathias Agopian    status_t createWorkList(int32_t id, size_t numLayers);
92a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
933eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian    // get number of layers of the given type as updated in prepare().
943eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian    // type is HWC_OVERLAY or HWC_FRAMEBUFFER
951e26087493ac0e7d7dc6dea8ad85cfef08b3271fMathias Agopian    size_t getLayerCount(int32_t id, int type) const;
969c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian
973e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian    // needed forward declarations
983e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian    class LayerListIterator;
993e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian
1003e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian    /*
1013e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian     * Interface to hardware composer's layers functionality.
1023e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian     * This abstracts the HAL interface to layers which can evolve in
1033e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian     * incompatible ways from one release to another.
1043e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian     * The idea is that we could extend this interface as we add
1053e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian     * features to h/w composer.
1063e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian     */
1073e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian    class HWCLayerInterface {
1083e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian    protected:
1093e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        virtual ~HWCLayerInterface() { }
1103e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian    public:
1113e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        virtual int32_t getCompositionType() const = 0;
1123e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        virtual uint32_t getHints() const = 0;
113ef19414bd8b77a26f5751f3845be79025a8263feJesse Hall        virtual int getAndResetReleaseFenceFd() = 0;
1143e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        virtual void setDefaultState() = 0;
1153e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        virtual void setSkip(bool skip) = 0;
1163e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        virtual void setBlending(uint32_t blending) = 0;
1173e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        virtual void setTransform(uint32_t transform) = 0;
1183e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        virtual void setFrame(const Rect& frame) = 0;
1193e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        virtual void setCrop(const Rect& crop) = 0;
1203e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        virtual void setVisibleRegionScreen(const Region& reg) = 0;
1213e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        virtual void setBuffer(const sp<GraphicBuffer>& buffer) = 0;
122dc5b485f74edf2d2f31c62054eb6c180421a3adeJesse Hall        virtual void setAcquireFenceFd(int fenceFd) = 0;
1233e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian    };
1243e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian
1253e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian    /*
1263e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian     * Interface used to implement an iterator to a list
1273e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian     * of HWCLayer.
1283e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian     */
1293e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian    class HWCLayer : public HWCLayerInterface {
1303e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        friend class LayerListIterator;
1313e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        // select the layer at the given index
1323e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        virtual status_t setLayer(size_t index) = 0;
1333e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        virtual HWCLayer* dup() = 0;
1343e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        static HWCLayer* copy(HWCLayer *rhs) {
1353e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian            return rhs ? rhs->dup() : NULL;
1363e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        }
1373e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian    protected:
1383e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        virtual ~HWCLayer() { }
1393e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian    };
1403e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian
1413e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian    /*
1423e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian     * Iterator through a HWCLayer list.
1433e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian     * This behaves more or less like a forward iterator.
1443e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian     */
1453e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian    class LayerListIterator {
1463e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        friend struct HWComposer;
1473e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        HWCLayer* const mLayerList;
1483e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        size_t mIndex;
1493e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian
1503e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        LayerListIterator() : mLayerList(NULL), mIndex(0) { }
1513e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian
1523e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        LayerListIterator(HWCLayer* layer, size_t index)
1533e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian            : mLayerList(layer), mIndex(index) { }
1543e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian
1553e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        // we don't allow assignment, because we don't need it for now
1563e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        LayerListIterator& operator = (const LayerListIterator& rhs);
1573e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian
1583e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian    public:
1593e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        // copy operators
1603e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        LayerListIterator(const LayerListIterator& rhs)
1613e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian            : mLayerList(HWCLayer::copy(rhs.mLayerList)), mIndex(rhs.mIndex) {
1623e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        }
1633e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian
1643e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        ~LayerListIterator() { delete mLayerList; }
1653e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian
1663e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        // pre-increment
1673e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        LayerListIterator& operator++() {
1683e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian            mLayerList->setLayer(++mIndex);
1693e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian            return *this;
1703e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        }
1713e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian
1723e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        // dereference
1733e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        HWCLayerInterface& operator * () { return *mLayerList; }
1743e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        HWCLayerInterface* operator -> () { return mLayerList; }
1753e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian
1763e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        // comparison
1773e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        bool operator == (const LayerListIterator& rhs) const {
1783e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian            return mIndex == rhs.mIndex;
1793e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        }
1803e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        bool operator != (const LayerListIterator& rhs) const {
1813e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian            return !operator==(rhs);
1823e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian        }
1833e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian    };
1843e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian
1853e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian    // Returns an iterator to the beginning of the layer list
1861e26087493ac0e7d7dc6dea8ad85cfef08b3271fMathias Agopian    LayerListIterator begin(int32_t id);
1873e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian
1883e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian    // Returns an iterator to the end of the layer list
1891e26087493ac0e7d7dc6dea8ad85cfef08b3271fMathias Agopian    LayerListIterator end(int32_t id);
1903e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian
1913e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian
1923eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian    // Events handling ---------------------------------------------------------
1933eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian
1943eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian    enum {
1953eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian        EVENT_VSYNC = HWC_EVENT_VSYNC
1963eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian    };
1973eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian
19803e407270c7ad76632f982c886d0776bed9e9b4cMathias Agopian    void eventControl(int event, int enabled);
1993eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian
200888c822c4cb6976aab9256c58bae9e17e3e55c5cMathias Agopian    nsecs_t getRefreshPeriod() const;
201d3ee231eddce0b69ec5e35188dbd0f4a2c3b9ac3Mathias Agopian    nsecs_t getRefreshTimestamp() const;
2028b736f138cfd9b239a2c7073347a13c489534ae1Mathias Agopian    float getDpiX() const;
2038b736f138cfd9b239a2c7073347a13c489534ae1Mathias Agopian    float getDpiY() const;
204d3ee231eddce0b69ec5e35188dbd0f4a2c3b9ac3Mathias Agopian
2053eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian    // this class is only used to fake the VSync event on systems that don't
2063eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian    // have it.
2073eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian    class VSyncThread : public Thread {
2083eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian        HWComposer& mHwc;
2093eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian        mutable Mutex mLock;
2103eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian        Condition mCondition;
2113eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian        bool mEnabled;
2123eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian        mutable nsecs_t mNextFakeVSync;
2133eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian        nsecs_t mRefreshPeriod;
2142965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian        virtual void onFirstRef();
2152965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian        virtual bool threadLoop();
2163eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian    public:
2172965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian        VSyncThread(HWComposer& hwc);
2182965b26022f95051f65b09d7eac47cbe923855c9Mathias Agopian        void setEnabled(bool enabled);
2193eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian    };
2203eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian
2213eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian    friend class VSyncThread;
2223eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian
2233eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian    // for debugging ----------------------------------------------------------
22422da60c3e64cd57535cbba063c07127814a2b52fMathias Agopian    void dump(String8& out, char* scratch, size_t SIZE,
22522da60c3e64cd57535cbba063c07127814a2b52fMathias Agopian            const Vector< sp<LayerBase> >& visibleLayersSortedByZ) const;
2268372785879d329f592f6883620b5a32d80d74691Mathias Agopian
227a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopianprivate:
228b685c542836b93c99cd85053e07696406ea37adbJesse Hall
2291e26087493ac0e7d7dc6dea8ad85cfef08b3271fMathias Agopian    LayerListIterator getLayerIterator(int32_t id, size_t index);
2301e26087493ac0e7d7dc6dea8ad85cfef08b3271fMathias Agopian    size_t getNumLayers(int32_t id) const;
23131d2843b45ebdb69ec3355111b7567363fd2a6b7Mathias Agopian
2323e8b853d67c737abdb363f9c978e7d83eac4d888Mathias Agopian    struct cb_context;
23331d2843b45ebdb69ec3355111b7567363fd2a6b7Mathias Agopian
234c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian    static void hook_invalidate(struct hwc_procs* procs);
23531d2843b45ebdb69ec3355111b7567363fd2a6b7Mathias Agopian    static void hook_vsync(struct hwc_procs* procs, int dpy, int64_t timestamp);
23631d2843b45ebdb69ec3355111b7567363fd2a6b7Mathias Agopian
2373eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian    inline void invalidate();
2383eb38cb33e41ce40dd1094bdec850f0fca9f8a53Mathias Agopian    inline void vsync(int dpy, int64_t timestamp);
239c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian
2401e26087493ac0e7d7dc6dea8ad85cfef08b3271fMathias Agopian
2415880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall    sp<SurfaceFlinger>              mFlinger;
2425880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall    hw_module_t const*              mModule;
2435880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall    struct hwc_composer_device_1*   mHwc;
244b685c542836b93c99cd85053e07696406ea37adbJesse Hall    // invariant: mLists[0] != NULL iff mHwc != NULL
245b685c542836b93c99cd85053e07696406ea37adbJesse Hall    // TODO: decide whether mLists[i>0] should be non-NULL when display i is
246b685c542836b93c99cd85053e07696406ea37adbJesse Hall    //       not attached/enabled.
247b685c542836b93c99cd85053e07696406ea37adbJesse Hall    struct hwc_display_contents_1*  mLists[MAX_DISPLAYS];
2481e26087493ac0e7d7dc6dea8ad85cfef08b3271fMathias Agopian
2495880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall    size_t                          mCapacity;
2505880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall    mutable size_t                  mNumOVLayers;
2515880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall    mutable size_t                  mNumFBLayers;
2525880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall    cb_context*                     mCBContext;
2535880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall    EventHandler&                   mEventHandler;
2545880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall    nsecs_t                         mRefreshPeriod;
2558b736f138cfd9b239a2c7073347a13c489534ae1Mathias Agopian    float                           mDpiX;
2568b736f138cfd9b239a2c7073347a13c489534ae1Mathias Agopian    float                           mDpiY;
2575880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall    size_t                          mVSyncCount;
2585880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall    sp<VSyncThread>                 mVSyncThread;
2595880cc573823148237eac9ab7bc586b8e4eb7160Jesse Hall    bool                            mDebugForceFakeVSync;
260d3ee231eddce0b69ec5e35188dbd0f4a2c3b9ac3Mathias Agopian
261d3ee231eddce0b69ec5e35188dbd0f4a2c3b9ac3Mathias Agopian    // protected by mLock
262d3ee231eddce0b69ec5e35188dbd0f4a2c3b9ac3Mathias Agopian    mutable Mutex mLock;
263d3ee231eddce0b69ec5e35188dbd0f4a2c3b9ac3Mathias Agopian    mutable nsecs_t mLastHwVSync;
264a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian};
265a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
266a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian// ---------------------------------------------------------------------------
267a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian}; // namespace android
268a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
269a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian#endif // ANDROID_SF_HWCOMPOSER_H
270