• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
23 #include <gui/IGraphicBufferConsumer.h>
24 
25 #include <ui/Rect.h>
26 
27 #include <utils/Flattenable.h>
28 #include <utils/StrongPointer.h>
29 
30 namespace android {
31 
32 class Fence;
33 class GraphicBuffer;
34 
35 class 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();
47     operator IGraphicBufferConsumer::BufferItem() const;
48 
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 
80     // mFrameNumber is the number of the queued frame for this slot.
81     uint64_t mFrameNumber;
82 
83     // mSlot is the slot index of this buffer (default INVALID_BUFFER_SLOT).
84     int mSlot;
85 
86     // mIsDroppable whether this buffer was queued with the
87     // property that it can be replaced by a new buffer for the purpose of
88     // making sure dequeueBuffer() won't block.
89     // i.e.: was the BufferQueue in "mDequeueBufferCannotBlock" when this buffer
90     // was queued.
91     bool mIsDroppable;
92 
93     // Indicates whether this buffer has been seen by a consumer yet
94     bool mAcquireCalled;
95 
96     // Indicates this buffer must be transformed by the inverse transform of the screen
97     // it is displayed onto. This is applied after mTransform.
98     bool mTransformToDisplayInverse;
99 };
100 
101 } // namespace android
102 
103 #endif
104