blob: 77c1a4b2abac0bf68a6fa4ee7ac1c151037feb8d [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>
28
Mathias Agopiana350ff92010-08-10 17:14:02 -070029namespace android {
30// ---------------------------------------------------------------------------
31
Mathias Agopian83727852010-09-23 18:13:21 -070032class String8;
Mathias Agopianc7d14e22011-08-01 16:32:21 -070033class SurfaceFlinger;
Mathias Agopian83727852010-09-23 18:13:21 -070034
Mathias Agopiana350ff92010-08-10 17:14:02 -070035class HWComposer
36{
37public:
38
Mathias Agopianc7d14e22011-08-01 16:32:21 -070039 HWComposer(const sp<SurfaceFlinger>& flinger);
Mathias Agopiana350ff92010-08-10 17:14:02 -070040 ~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
Mathias Agopian7ee4cd52011-09-02 12:22:39 -070053 // disable hwc until next createWorkList
54 status_t disable();
55
Mathias Agopiana350ff92010-08-10 17:14:02 -070056 // commits the list
57 status_t commit() const;
58
Antti Hatalaf5f27122010-09-09 02:33:05 -070059 // release hardware resources
60 status_t release() const;
Mathias Agopiana350ff92010-08-10 17:14:02 -070061
Mathias Agopian45721772010-08-12 15:03:26 -070062 size_t getNumLayers() const;
63 hwc_layer_t* getLayers() const;
Mathias Agopiana350ff92010-08-10 17:14:02 -070064
Mathias Agopian83727852010-09-23 18:13:21 -070065 // for debugging
66 void dump(String8& out, char* scratch, size_t SIZE) const;
67
Mathias Agopiana350ff92010-08-10 17:14:02 -070068private:
Mathias Agopianc7d14e22011-08-01 16:32:21 -070069 struct cb_context {
70 hwc_procs_t procs;
71 HWComposer* hwc;
72 };
73 static void hook_invalidate(struct hwc_procs* procs);
74 void invalidate();
75
76 sp<SurfaceFlinger> mFlinger;
Mathias Agopiana350ff92010-08-10 17:14:02 -070077 hw_module_t const* mModule;
78 hwc_composer_device_t* mHwc;
79 hwc_layer_list_t* mList;
Mathias Agopian45721772010-08-12 15:03:26 -070080 size_t mCapacity;
Mathias Agopiana350ff92010-08-10 17:14:02 -070081 hwc_display_t mDpy;
82 hwc_surface_t mSur;
Mathias Agopianc7d14e22011-08-01 16:32:21 -070083 cb_context mCBContext;
Mathias Agopiana350ff92010-08-10 17:14:02 -070084};
85
86
87// ---------------------------------------------------------------------------
88}; // namespace android
89
90#endif // ANDROID_SF_HWCOMPOSER_H