HWComposer.h revision c7d14e247117392fbd44aa454622778a25c076ae
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
29namespace android {
30// ---------------------------------------------------------------------------
31
32class String8;
33class SurfaceFlinger;
34
35class HWComposer
36{
37public:
38
39    HWComposer(const sp<SurfaceFlinger>& flinger);
40    ~HWComposer();
41
42    status_t initCheck() const;
43
44    // tells the HAL what the framebuffer is
45    void setFrameBuffer(EGLDisplay dpy, EGLSurface sur);
46
47    // create a work list for numLayers layer
48    status_t createWorkList(size_t numLayers);
49
50    // Asks the HAL what it can do
51    status_t prepare() const;
52
53    // commits the list
54    status_t commit() const;
55
56    // release hardware resources
57    status_t release() const;
58
59    size_t getNumLayers() const;
60    hwc_layer_t* getLayers() const;
61
62    // for debugging
63    void dump(String8& out, char* scratch, size_t SIZE) const;
64
65private:
66    struct cb_context {
67        hwc_procs_t procs;
68        HWComposer* hwc;
69    };
70    static void hook_invalidate(struct hwc_procs* procs);
71    void invalidate();
72
73    sp<SurfaceFlinger>      mFlinger;
74    hw_module_t const*      mModule;
75    hwc_composer_device_t*  mHwc;
76    hwc_layer_list_t*       mList;
77    size_t                  mCapacity;
78    hwc_display_t           mDpy;
79    hwc_surface_t           mSur;
80    cb_context              mCBContext;
81};
82
83
84// ---------------------------------------------------------------------------
85}; // namespace android
86
87#endif // ANDROID_SF_HWCOMPOSER_H
88