2 // Copyright (c) 2016 Intel Corporation
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef OS_ANDROID_PLATFORMDEFINES_H_
18 #define OS_ANDROID_PLATFORMDEFINES_H_
21 #define LOG_TAG "iahwcomposer"
25 #define ATRACE_TAG ATRACE_TAG_GRAPHICS
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>
36 #include <i915_private_android_types.h>
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;
48 bool hwc_buffer_ = false;
51 typedef struct gralloc_handle* HWCNativeHandle;
52 typedef struct cros_gralloc_handle HWCNativeBuffer;
53 #define GETNATIVEBUFFER(handle) (*(cros_gralloc_handle*)(handle->handle_))
57 size_t operator()(HWCNativeBuffer const& buffer) const {
58 const native_handle_t & p = buffer.base;
60 for (int i = 0; i < p.numFds + p.numInts; i++) {
61 hash_combine_hwc(seed, (const size_t)p.data[i]);
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);
73 for (int i = 0; i < p1.numFds + p1.numInts; i++) {
74 equal = equal && (p1.data[i] == p2.data[i]);
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()
95 #endif // OS_ANDROID_PLATFORMDEFINES_H_