BufferItem.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. #ifndef ANDROID_GUI_BUFFERITEM_H
  17. #define ANDROID_GUI_BUFFERITEM_H
  18. #include <EGL/egl.h>
  19. #include <EGL/eglext.h>
  20. #include <ui/Rect.h>
  21. #include <ui/Region.h>
  22. #include <system/graphics.h>
  23. #include <utils/Flattenable.h>
  24. #include <utils/StrongPointer.h>
  25. namespace android {
  26. class Fence;
  27. class GraphicBuffer;
  28. class BufferItem : public Flattenable<BufferItem> {
  29. friend class Flattenable<BufferItem>;
  30. size_t getPodSize() const;
  31. size_t getFlattenedSize() const;
  32. size_t getFdCount() const;
  33. status_t flatten(void*& buffer, size_t& size, int*& fds, size_t& count) const;
  34. status_t unflatten(void const*& buffer, size_t& size, int const*& fds, size_t& count);
  35. public:
  36. // The default value of mBuf, used to indicate this doesn't correspond to a slot.
  37. enum { INVALID_BUFFER_SLOT = -1 };
  38. BufferItem();
  39. ~BufferItem();
  40. static const char* scalingModeName(uint32_t scalingMode);
  41. // mGraphicBuffer points to the buffer allocated for this slot, or is NULL
  42. // if the buffer in this slot has been acquired in the past (see
  43. // BufferSlot.mAcquireCalled).
  44. sp<GraphicBuffer> mGraphicBuffer;
  45. // mFence is a fence that will signal when the buffer is idle.
  46. sp<Fence> mFence;
  47. // mCrop is the current crop rectangle for this buffer slot.
  48. Rect mCrop;
  49. // mTransform is the current transform flags for this buffer slot.
  50. // refer to NATIVE_WINDOW_TRANSFORM_* in <window.h>
  51. uint32_t mTransform;
  52. // mScalingMode is the current scaling mode for this buffer slot.
  53. // refer to NATIVE_WINDOW_SCALING_* in <window.h>
  54. uint32_t mScalingMode;
  55. // mTimestamp is the current timestamp for this buffer slot. This gets
  56. // to set by queueBuffer each time this slot is queued. This value
  57. // is guaranteed to be monotonically increasing for each newly
  58. // acquired buffer.
  59. union {
  60. int64_t mTimestamp;
  61. struct {
  62. uint32_t mTimestampLo;
  63. uint32_t mTimestampHi;
  64. };
  65. };
  66. // mIsAutoTimestamp indicates whether mTimestamp was generated
  67. // automatically when the buffer was queued.
  68. bool mIsAutoTimestamp;
  69. // mDataSpace is the current dataSpace value for this buffer slot. This gets
  70. // set by queueBuffer each time this slot is queued. The meaning of the
  71. // dataSpace is format-dependent.
  72. android_dataspace mDataSpace;
  73. // mFrameNumber is the number of the queued frame for this slot.
  74. union {
  75. uint64_t mFrameNumber;
  76. struct {
  77. uint32_t mFrameNumberLo;
  78. uint32_t mFrameNumberHi;
  79. };
  80. };
  81. union {
  82. // mSlot is the slot index of this buffer (default INVALID_BUFFER_SLOT).
  83. int mSlot;
  84. // mBuf is the former name for mSlot
  85. int mBuf;
  86. };
  87. // mIsDroppable whether this buffer was queued with the
  88. // property that it can be replaced by a new buffer for the purpose of
  89. // making sure dequeueBuffer() won't block.
  90. // i.e.: was the BufferQueue in "mDequeueBufferCannotBlock" when this buffer
  91. // was queued.
  92. bool mIsDroppable;
  93. // Indicates whether this buffer has been seen by a consumer yet
  94. bool mAcquireCalled;
  95. // Indicates this buffer must be transformed by the inverse transform of the screen
  96. // it is displayed onto. This is applied after mTransform.
  97. bool mTransformToDisplayInverse;
  98. // Describes the portion of the surface that has been modified since the
  99. // previous frame
  100. Region mSurfaceDamage;
  101. };
  102. } // namespace android
  103. #endif