blob: cc41bae469c5df988fa58bcec5f48dea3a014859 [file] [log] [blame]
Dan Stoza289ade12014-02-28 11:17:17 -08001/*
2 * Copyright 2014 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_GUI_BUFFERITEM_H
18#define ANDROID_GUI_BUFFERITEM_H
19
20#include <EGL/egl.h>
21#include <EGL/eglext.h>
22
Dan Stoza289ade12014-02-28 11:17:17 -080023#include <ui/Rect.h>
24
Dan Stoza1c87e472015-03-13 14:40:34 -070025#include <system/graphics.h>
26
Dan Stoza289ade12014-02-28 11:17:17 -080027#include <utils/Flattenable.h>
28#include <utils/StrongPointer.h>
29
30namespace android {
31
32class Fence;
33class GraphicBuffer;
34
35class BufferItem : public Flattenable<BufferItem> {
36 friend class Flattenable<BufferItem>;
37 size_t getPodSize() const;
38 size_t getFlattenedSize() const;
39 size_t getFdCount() const;
40 status_t flatten(void*& buffer, size_t& size, int*& fds, size_t& count) const;
41 status_t unflatten(void const*& buffer, size_t& size, int const*& fds, size_t& count);
42
43 public:
44 // The default value of mBuf, used to indicate this doesn't correspond to a slot.
45 enum { INVALID_BUFFER_SLOT = -1 };
46 BufferItem();
Dan Stoza8dc55392014-11-04 11:37:46 -080047 ~BufferItem();
Dan Stoza289ade12014-02-28 11:17:17 -080048
49 static const char* scalingModeName(uint32_t scalingMode);
50
51 // mGraphicBuffer points to the buffer allocated for this slot, or is NULL
52 // if the buffer in this slot has been acquired in the past (see
53 // BufferSlot.mAcquireCalled).
54 sp<GraphicBuffer> mGraphicBuffer;
55
56 // mFence is a fence that will signal when the buffer is idle.
57 sp<Fence> mFence;
58
59 // mCrop is the current crop rectangle for this buffer slot.
60 Rect mCrop;
61
62 // mTransform is the current transform flags for this buffer slot.
63 // refer to NATIVE_WINDOW_TRANSFORM_* in <window.h>
64 uint32_t mTransform;
65
66 // mScalingMode is the current scaling mode for this buffer slot.
67 // refer to NATIVE_WINDOW_SCALING_* in <window.h>
68 uint32_t mScalingMode;
69
70 // mTimestamp is the current timestamp for this buffer slot. This gets
71 // to set by queueBuffer each time this slot is queued. This value
72 // is guaranteed to be monotonically increasing for each newly
73 // acquired buffer.
74 int64_t mTimestamp;
75
76 // mIsAutoTimestamp indicates whether mTimestamp was generated
77 // automatically when the buffer was queued.
78 bool mIsAutoTimestamp;
79
Eino-Ville Talvala82c6bcc2015-02-19 16:10:43 -080080 // mDataSpace is the current dataSpace value for this buffer slot. This gets
81 // set by queueBuffer each time this slot is queued. The meaning of the
82 // dataSpace is format-dependent.
83 android_dataspace mDataSpace;
84
Dan Stoza289ade12014-02-28 11:17:17 -080085 // mFrameNumber is the number of the queued frame for this slot.
86 uint64_t mFrameNumber;
87
Dan Stozacf3834d2015-03-11 14:04:22 -070088 union {
89 // mSlot is the slot index of this buffer (default INVALID_BUFFER_SLOT).
90 int mSlot;
91
92 // mBuf is the former name for mSlot
93 int mBuf;
94 };
Dan Stoza289ade12014-02-28 11:17:17 -080095
96 // mIsDroppable whether this buffer was queued with the
97 // property that it can be replaced by a new buffer for the purpose of
98 // making sure dequeueBuffer() won't block.
99 // i.e.: was the BufferQueue in "mDequeueBufferCannotBlock" when this buffer
100 // was queued.
101 bool mIsDroppable;
102
103 // Indicates whether this buffer has been seen by a consumer yet
104 bool mAcquireCalled;
105
106 // Indicates this buffer must be transformed by the inverse transform of the screen
107 // it is displayed onto. This is applied after mTransform.
108 bool mTransformToDisplayInverse;
109};
110
111} // namespace android
112
113#endif