blob: 81e735998efa41b75d89f9959085140061058ab0 [file] [log] [blame]
Mathias Agopiana350ff92010-08-10 17:14:02 -07001/*
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
Mathias Agopianc7d14e22011-08-01 16:32:21 -070027#include <utils/StrongPointer.h>
Mathias Agopian22da60c2011-09-09 00:49:11 -070028#include <utils/Vector.h>
Mathias Agopianc7d14e22011-08-01 16:32:21 -070029
Mathias Agopiana350ff92010-08-10 17:14:02 -070030namespace android {
31// ---------------------------------------------------------------------------
32
Mathias Agopian83727852010-09-23 18:13:21 -070033class String8;
Mathias Agopianc7d14e22011-08-01 16:32:21 -070034class SurfaceFlinger;
Mathias Agopian22da60c2011-09-09 00:49:11 -070035class LayerBase;
Mathias Agopian83727852010-09-23 18:13:21 -070036
Mathias Agopiana350ff92010-08-10 17:14:02 -070037class HWComposer
38{
39public:
40
Mathias Agopianc7d14e22011-08-01 16:32:21 -070041 HWComposer(const sp<SurfaceFlinger>& flinger);
Mathias Agopiana350ff92010-08-10 17:14:02 -070042 ~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
Mathias Agopian7ee4cd52011-09-02 12:22:39 -070055 // disable hwc until next createWorkList
56 status_t disable();
57
Mathias Agopiana350ff92010-08-10 17:14:02 -070058 // commits the list
59 status_t commit() const;
60
Antti Hatalaf5f27122010-09-09 02:33:05 -070061 // release hardware resources
62 status_t release() const;
Mathias Agopiana350ff92010-08-10 17:14:02 -070063
Mathias Agopian45721772010-08-12 15:03:26 -070064 size_t getNumLayers() const;
65 hwc_layer_t* getLayers() const;
Mathias Agopiana350ff92010-08-10 17:14:02 -070066
Mathias Agopian9c6e2972011-09-20 17:21:56 -070067 // updated in preapre()
68 size_t getLayerCount(int type) const;
69
Mathias Agopian83727852010-09-23 18:13:21 -070070 // for debugging
Mathias Agopian22da60c2011-09-09 00:49:11 -070071 void dump(String8& out, char* scratch, size_t SIZE,
72 const Vector< sp<LayerBase> >& visibleLayersSortedByZ) const;
Mathias Agopian83727852010-09-23 18:13:21 -070073
Mathias Agopiana350ff92010-08-10 17:14:02 -070074private:
Mathias Agopian31d28432012-04-03 16:31:39 -070075
76 struct callbacks : public hwc_procs_t {
77 // these are here to facilitate the transition when adding
78 // new callbacks (an implementation can check for NULL before
79 // calling a new callback).
80 void (*zero[4])(void);
81 };
82
Mathias Agopianc7d14e22011-08-01 16:32:21 -070083 struct cb_context {
Mathias Agopian31d28432012-04-03 16:31:39 -070084 callbacks procs;
Mathias Agopianc7d14e22011-08-01 16:32:21 -070085 HWComposer* hwc;
86 };
Mathias Agopian31d28432012-04-03 16:31:39 -070087
Mathias Agopianc7d14e22011-08-01 16:32:21 -070088 static void hook_invalidate(struct hwc_procs* procs);
Mathias Agopian31d28432012-04-03 16:31:39 -070089 static void hook_vsync(struct hwc_procs* procs, int dpy, int64_t timestamp);
90
Mathias Agopianc7d14e22011-08-01 16:32:21 -070091 void invalidate();
Mathias Agopian31d28432012-04-03 16:31:39 -070092 void vsync(int dpy, int64_t timestamp);
Mathias Agopianc7d14e22011-08-01 16:32:21 -070093
94 sp<SurfaceFlinger> mFlinger;
Mathias Agopiana350ff92010-08-10 17:14:02 -070095 hw_module_t const* mModule;
96 hwc_composer_device_t* mHwc;
97 hwc_layer_list_t* mList;
Mathias Agopian45721772010-08-12 15:03:26 -070098 size_t mCapacity;
Mathias Agopian9c6e2972011-09-20 17:21:56 -070099 mutable size_t mNumOVLayers;
100 mutable size_t mNumFBLayers;
Mathias Agopiana350ff92010-08-10 17:14:02 -0700101 hwc_display_t mDpy;
102 hwc_surface_t mSur;
Mathias Agopianc7d14e22011-08-01 16:32:21 -0700103 cb_context mCBContext;
Mathias Agopiana350ff92010-08-10 17:14:02 -0700104};
105
106
107// ---------------------------------------------------------------------------
108}; // namespace android
109
110#endif // ANDROID_SF_HWCOMPOSER_H