OSDN Git Service

Add external layer buffer cache management.
[android-x86/external-IA-Hardware-Composer.git] / os / android / platformdefines.h
1 /*
2 // Copyright (c) 2016 Intel Corporation
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 OS_ANDROID_PLATFORMDEFINES_H_
18 #define OS_ANDROID_PLATFORMDEFINES_H_
19
20 #ifndef LOG_TAG
21 #define LOG_TAG "iahwcomposer"
22 #endif
23
24 #ifndef ATRACE_TAG
25 #define ATRACE_TAG ATRACE_TAG_GRAPHICS
26 #endif
27
28 #include <utils/Trace.h>
29 #include <cutils/log.h>
30 #include <hardware/hardware.h>
31 #include <hardware/hwcomposer.h>
32 #include <ui/GraphicBuffer.h>
33 #include "platformcommondefines.h"
34 #include <cros_gralloc_handle.h>
35 #define DRV_I915 1
36 #include <i915_private_android_types.h>
37
38 #ifdef _cplusplus
39 extern "C" {
40 #endif
41
42 struct gralloc_handle {
43   buffer_handle_t handle_ = NULL;
44   android::sp<android::GraphicBuffer> buffer_ = NULL;
45   native_handle_t* imported_handle_ = NULL;
46   uint32_t gem_handle_ = 0;
47   HwcBuffer meta_data_;
48   bool hwc_buffer_ = false;
49 };
50
51 typedef struct gralloc_handle* HWCNativeHandle;
52 typedef struct cros_gralloc_handle HWCNativeBuffer;
53 #define GETNATIVEBUFFER(handle) (*(cros_gralloc_handle*)(handle->handle_))
54
55
56 struct BufferHash {
57   size_t operator()(HWCNativeBuffer const& buffer) const {
58     const native_handle_t & p = buffer.base;
59     std::size_t seed = 0;
60     for (int i = 0; i < p.numFds + p.numInts; i++) {
61       hash_combine_hwc(seed, (const size_t)p.data[i]);
62     }
63     return seed;
64   }
65 };
66
67 struct BufferEqual {
68   bool operator()(const HWCNativeBuffer& buffer1, const HWCNativeBuffer& buffer2) const {
69     const native_handle_t &p1 = buffer1.base;
70     const native_handle_t &p2 = buffer2.base;
71     bool equal = (p1.numFds == p2.numFds) && (p1.numInts ==  p2.numInts);
72     if (equal) {
73       for (int i = 0; i < p1.numFds + p1.numInts; i++) {
74         equal = equal && (p1.data[i] == p2.data[i]);
75         if (!equal)
76           break;
77       }
78     }
79     return equal;
80   }
81 };
82
83
84 #define VTRACE(fmt, ...) ALOGV("%s: " fmt, __func__, ##__VA_ARGS__)
85 #define DTRACE(fmt, ...) ALOGD("%s: " fmt, __func__, ##__VA_ARGS__)
86 #define ITRACE(fmt, ...) ALOGI(fmt, ##__VA_ARGS__)
87 #define WTRACE(fmt, ...) ALOGW("%s: " fmt, __func__, ##__VA_ARGS__)
88 #define ETRACE(fmt, ...) ALOGE("%s: " fmt, __func__, ##__VA_ARGS__)
89 #define STRACE() ATRACE_CALL()
90 // _cplusplus
91 #ifdef _cplusplus
92 }
93 #endif
94
95 #endif  // OS_ANDROID_PLATFORMDEFINES_H_