HWComposer.h revision 31d2843b45ebdb69ec3355111b7567363fd2a6b7
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
23a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian#include <EGL/egl.h>
24a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
25a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian#include <hardware/hwcomposer.h>
26a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
27c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian#include <utils/StrongPointer.h>
2822da60c3e64cd57535cbba063c07127814a2b52fMathias Agopian#include <utils/Vector.h>
29c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian
30a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopiannamespace android {
31a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian// ---------------------------------------------------------------------------
32a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
338372785879d329f592f6883620b5a32d80d74691Mathias Agopianclass String8;
34c7d14e247117392fbd44aa454622778a25c076aeMathias Agopianclass SurfaceFlinger;
3522da60c3e64cd57535cbba063c07127814a2b52fMathias Agopianclass LayerBase;
368372785879d329f592f6883620b5a32d80d74691Mathias Agopian
37a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopianclass HWComposer
38a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian{
39a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopianpublic:
40a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
41c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian    HWComposer(const sp<SurfaceFlinger>& flinger);
42a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    ~HWComposer();
43a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
44a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    status_t initCheck() const;
45a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
46a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    // tells the HAL what the framebuffer is
47a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    void setFrameBuffer(EGLDisplay dpy, EGLSurface sur);
48a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
49a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    // create a work list for numLayers layer
50a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    status_t createWorkList(size_t numLayers);
51a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
52a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    // Asks the HAL what it can do
53a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    status_t prepare() const;
54a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
557ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopian    // disable hwc until next createWorkList
567ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopian    status_t disable();
577ee4cd5556cef1878e1d4729f1b389f186311027Mathias Agopian
58a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    // commits the list
59a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    status_t commit() const;
60a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
61f5f2712854599b4970643c6000fe6ae950a08ba9Antti Hatala    // release hardware resources
62f5f2712854599b4970643c6000fe6ae950a08ba9Antti Hatala    status_t release() const;
63a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
6445721773e1a68e96da4b6cc04cef276bae7ca3e9Mathias Agopian    size_t getNumLayers() const;
6545721773e1a68e96da4b6cc04cef276bae7ca3e9Mathias Agopian    hwc_layer_t* getLayers() const;
66a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
679c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian    // updated in preapre()
689c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian    size_t getLayerCount(int type) const;
699c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian
708372785879d329f592f6883620b5a32d80d74691Mathias Agopian    // for debugging
7122da60c3e64cd57535cbba063c07127814a2b52fMathias Agopian    void dump(String8& out, char* scratch, size_t SIZE,
7222da60c3e64cd57535cbba063c07127814a2b52fMathias Agopian            const Vector< sp<LayerBase> >& visibleLayersSortedByZ) const;
738372785879d329f592f6883620b5a32d80d74691Mathias Agopian
74a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopianprivate:
7531d2843b45ebdb69ec3355111b7567363fd2a6b7Mathias Agopian
7631d2843b45ebdb69ec3355111b7567363fd2a6b7Mathias Agopian    struct callbacks : public hwc_procs_t {
7731d2843b45ebdb69ec3355111b7567363fd2a6b7Mathias Agopian        // these are here to facilitate the transition when adding
7831d2843b45ebdb69ec3355111b7567363fd2a6b7Mathias Agopian        // new callbacks (an implementation can check for NULL before
7931d2843b45ebdb69ec3355111b7567363fd2a6b7Mathias Agopian        // calling a new callback).
8031d2843b45ebdb69ec3355111b7567363fd2a6b7Mathias Agopian        void (*zero[4])(void);
8131d2843b45ebdb69ec3355111b7567363fd2a6b7Mathias Agopian    };
8231d2843b45ebdb69ec3355111b7567363fd2a6b7Mathias Agopian
83c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian    struct cb_context {
8431d2843b45ebdb69ec3355111b7567363fd2a6b7Mathias Agopian        callbacks procs;
85c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian        HWComposer* hwc;
86c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian    };
8731d2843b45ebdb69ec3355111b7567363fd2a6b7Mathias Agopian
88c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian    static void hook_invalidate(struct hwc_procs* procs);
8931d2843b45ebdb69ec3355111b7567363fd2a6b7Mathias Agopian    static void hook_vsync(struct hwc_procs* procs, int dpy, int64_t timestamp);
9031d2843b45ebdb69ec3355111b7567363fd2a6b7Mathias Agopian
91c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian    void invalidate();
9231d2843b45ebdb69ec3355111b7567363fd2a6b7Mathias Agopian    void vsync(int dpy, int64_t timestamp);
93c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian
94c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian    sp<SurfaceFlinger>      mFlinger;
95a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    hw_module_t const*      mModule;
96a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    hwc_composer_device_t*  mHwc;
97a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    hwc_layer_list_t*       mList;
9845721773e1a68e96da4b6cc04cef276bae7ca3e9Mathias Agopian    size_t                  mCapacity;
999c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian    mutable size_t          mNumOVLayers;
1009c6e297271ec9af9d974242d89cfa08cb6ceaa0aMathias Agopian    mutable size_t          mNumFBLayers;
101a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    hwc_display_t           mDpy;
102a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian    hwc_surface_t           mSur;
103c7d14e247117392fbd44aa454622778a25c076aeMathias Agopian    cb_context              mCBContext;
104a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian};
105a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
106a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
107a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian// ---------------------------------------------------------------------------
108a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian}; // namespace android
109a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian
110a350ff98692b3a50cad5cc93f9f83221242ca86aMathias Agopian#endif // ANDROID_SF_HWCOMPOSER_H
111