The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 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> |
Mathias Agopian | 0795272 | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 22 | #include <binder/MemoryDealer.h> |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 23 | |
| 24 | namespace android { |
| 25 | |
| 26 | // --------------------------------------------------------------------------- |
| 27 | |
| 28 | class PMemHeap; |
| 29 | class MemoryHeapPmem; |
| 30 | class SurfaceFlinger; |
| 31 | |
| 32 | // --------------------------------------------------------------------------- |
| 33 | |
| 34 | class SurfaceHeapManager : public RefBase |
| 35 | { |
| 36 | public: |
| 37 | SurfaceHeapManager(const sp<SurfaceFlinger>& flinger, size_t clientHeapSize); |
| 38 | virtual ~SurfaceHeapManager(); |
| 39 | virtual void onFirstRef(); |
| 40 | /* 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); |
| 43 | |
| 44 | // used for debugging only... |
| 45 | sp<SimpleBestFitAllocator> getAllocator(int type) const; |
| 46 | |
| 47 | private: |
| 48 | sp<PMemHeap> getHeap(int type) const; |
| 49 | |
| 50 | sp<SurfaceFlinger> mFlinger; |
| 51 | mutable Mutex mLock; |
| 52 | size_t mClientHeapSize; |
| 53 | sp<PMemHeap> mPMemHeap; |
| 54 | static int global_pmem_heap; |
| 55 | }; |
| 56 | |
| 57 | // --------------------------------------------------------------------------- |
| 58 | |
| 59 | class PMemHeap : public MemoryHeapBase |
| 60 | { |
| 61 | public: |
| 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 | |
| 71 | private: |
| 72 | sp<SimpleBestFitAllocator> mAllocator; |
| 73 | }; |
| 74 | |
| 75 | // --------------------------------------------------------------------------- |
| 76 | }; // namespace android |
| 77 | |
| 78 | #endif // ANDROID_VRAM_HEAP_H |