blob: 91401679cb2ccada5ea82b5458303e808fdbe29d [file] [log] [blame]
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -07001/*
2 * Copyright (C) 2008 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_VRAM_HEAP_H
18#define ANDROID_VRAM_HEAP_H
19
20#include <stdint.h>
21#include <sys/types.h>
22#include <utils/MemoryDealer.h>
23
24namespace android {
25
26// ---------------------------------------------------------------------------
27
28class PMemHeap;
29class MemoryHeapPmem;
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080030class SurfaceFlinger;
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070031
32// ---------------------------------------------------------------------------
33
34class SurfaceHeapManager : public RefBase
35{
36public:
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080037 SurfaceHeapManager(const sp<SurfaceFlinger>& flinger, size_t clientHeapSize);
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070038 virtual ~SurfaceHeapManager();
39 virtual void onFirstRef();
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080040 /* use ISurfaceComposer flags eGPU|eHArdware|eSecure */
41 sp<MemoryDealer> createHeap(uint32_t flags=0, pid_t client_pid = 0,
42 const sp<MemoryDealer>& defaultAllocator = 0);
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070043
44 // used for debugging only...
45 sp<SimpleBestFitAllocator> getAllocator(int type) const;
46
47private:
48 sp<PMemHeap> getHeap(int type) const;
49
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080050 sp<SurfaceFlinger> mFlinger;
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070051 mutable Mutex mLock;
52 size_t mClientHeapSize;
53 sp<PMemHeap> mPMemHeap;
54 static int global_pmem_heap;
55};
56
57// ---------------------------------------------------------------------------
58
The Android Open Source Projecte09fd9e2008-12-17 18:05:43 -080059class PMemHeap : public MemoryHeapBase
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -070060{
61public:
62 PMemHeap(const char* const vram,
63 size_t size=0, size_t reserved=0);
64 virtual ~PMemHeap();
65
66 virtual const sp<SimpleBestFitAllocator>& getAllocator() const {
67 return mAllocator;
68 }
69 virtual sp<MemoryHeapPmem> createClientHeap();
70
71private:
72 sp<SimpleBestFitAllocator> mAllocator;
73};
74
75// ---------------------------------------------------------------------------
76}; // namespace android
77
78#endif // ANDROID_VRAM_HEAP_H