HWComposer.h revision 9c6e297271ec9af9d974242d89cfa08cb6ceaa0a
1/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_SF_HWCOMPOSER_H
18#define ANDROID_SF_HWCOMPOSER_H
19
20#include <stdint.h>
21#include <sys/types.h>
22
23#include <EGL/egl.h>
24
25#include <hardware/hwcomposer.h>
26
27#include <utils/StrongPointer.h>
28#include <utils/Vector.h>
29
30namespace android {
31// ---------------------------------------------------------------------------
32
33class String8;
34class SurfaceFlinger;
35class LayerBase;
36
37class HWComposer
38{
39public:
40
41    HWComposer(const sp<SurfaceFlinger>& flinger);
42    ~HWComposer();
43
44    status_t initCheck() const;
45
46    // tells the HAL what the framebuffer is
47    void setFrameBuffer(EGLDisplay dpy, EGLSurface sur);
48
49    // create a work list for numLayers layer
50    status_t createWorkList(size_t numLayers);
51
52    // Asks the HAL what it can do
53    status_t prepare() const;
54
55    // disable hwc until next createWorkList
56    status_t disable();
57
58    // commits the list
59    status_t commit() const;
60
61    // release hardware resources
62    status_t release() const;
63
64    size_t getNumLayers() const;
65    hwc_layer_t* getLayers() const;
66
67    // updated in preapre()
68    size_t getLayerCount(int type) const;
69
70    // for debugging
71    void dump(String8& out, char* scratch, size_t SIZE,
72            const Vector< sp<LayerBase> >& visibleLayersSortedByZ) const;
73
74private:
75    struct cb_context {
76        hwc_procs_t procs;
77        HWComposer* hwc;
78    };
79    static void hook_invalidate(struct hwc_procs* procs);
80    void invalidate();
81
82    sp<SurfaceFlinger>      mFlinger;
83    hw_module_t const*      mModule;
84    hwc_composer_device_t*  mHwc;
85    hwc_layer_list_t*       mList;
86    size_t                  mCapacity;
87    mutable size_t          mNumOVLayers;
88    mutable size_t          mNumFBLayers;
89    hwc_display_t           mDpy;
90    hwc_surface_t           mSur;
91    cb_context              mCBContext;
92};
93
94
95// ---------------------------------------------------------------------------
96}; // namespace android
97
98#endif // ANDROID_SF_HWCOMPOSER_H
99