buffer_types.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. // Copyright 2015 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef UI_GFX_BUFFER_TYPES_H_
  5. #define UI_GFX_BUFFER_TYPES_H_
  6. #include <stdint.h>
  7. #include <tuple>
  8. namespace gfx {
  9. // The format needs to be taken into account when mapping a buffer into the
  10. // client's address space.
  11. enum class BufferFormat {
  12. R_8,
  13. R_16,
  14. RG_88,
  15. RG_1616,
  16. BGR_565,
  17. RGBA_4444,
  18. RGBX_8888,
  19. RGBA_8888,
  20. BGRX_8888,
  21. BGRA_1010102,
  22. RGBA_1010102,
  23. BGRA_8888,
  24. RGBA_F16,
  25. YVU_420,
  26. YUV_420_BIPLANAR,
  27. P010,
  28. LAST = P010
  29. };
  30. // The usage mode affects how a buffer can be used. Only buffers created with
  31. // *_CPU_READ_WRITE_* can be mapped into the client's address space and accessed
  32. // by the CPU.
  33. // *_VDA_WRITE is for cases where a video decode accelerator writes into the
  34. // buffers.
  35. // PROTECTED_* are for HW protected buffers that cannot be read by the CPU and
  36. // can only be read in protected GPU contexts or scanned out to overlays.
  37. // At present, SCANOUT implies GPU_READ_WRITE. This doesn't apply to other
  38. // SCANOUT_* values.
  39. // TODO(reveman): Add GPU_READ_WRITE for use-cases where SCANOUT is not
  40. // required.
  41. enum class BufferUsage {
  42. GPU_READ,
  43. SCANOUT,
  44. // SCANOUT_CAMERA_READ_WRITE implies CPU_READ_WRITE.
  45. SCANOUT_CAMERA_READ_WRITE,
  46. CAMERA_AND_CPU_READ_WRITE,
  47. SCANOUT_CPU_READ_WRITE,
  48. SCANOUT_VDA_WRITE,
  49. PROTECTED_SCANOUT_VDA_WRITE,
  50. GPU_READ_CPU_READ_WRITE,
  51. SCANOUT_VEA_CPU_READ,
  52. SCANOUT_FRONT_RENDERING,
  53. VEA_READ_CAMERA_AND_CPU_READ_WRITE,
  54. LAST = VEA_READ_CAMERA_AND_CPU_READ_WRITE
  55. };
  56. struct BufferUsageAndFormat {
  57. BufferUsageAndFormat()
  58. : usage(BufferUsage::GPU_READ), format(BufferFormat::RGBA_8888) {}
  59. BufferUsageAndFormat(BufferUsage usage, BufferFormat format)
  60. : usage(usage), format(format) {}
  61. bool operator==(const BufferUsageAndFormat& other) const {
  62. return std::tie(usage, format) == std::tie(other.usage, other.format);
  63. }
  64. BufferUsage usage;
  65. BufferFormat format;
  66. };
  67. // Used to identify the plane of a GpuMemoryBuffer to use when creating a
  68. // SharedImage.
  69. enum class BufferPlane {
  70. // For single-plane GpuMemoryBuffer, this refers to that single plane. For
  71. // YUV_420, YUV_420_BIPLANAR, and P010 GpuMemoryBuffers, this refers to an
  72. // RGB representation of the planes (either bound directly as a texture or
  73. // created through an extra copy).
  74. DEFAULT,
  75. // The Y plane for YUV_420, YUV_420_BIPLANAR, and P010.
  76. Y,
  77. // The UV plane for YUV_420_BIPLANAR and P010.
  78. UV,
  79. // The U plane for YUV_420.
  80. U,
  81. // The V plane for YUV_420.
  82. V,
  83. LAST = V
  84. };
  85. // This enum is used for histogram states and should only have new values added
  86. // to the end before kMaxValue. tools/metrics/histograms/enums.xml should be
  87. // updated together.
  88. // These values are persisted to logs. Entries should not be renumbered and
  89. // numeric values should never be reused.
  90. enum class OddSize {
  91. kEvenWidthAndHeight = 0,
  92. kOddWidthOnly = 1,
  93. kOddHeightOnly = 2,
  94. kOddWidthAndHeight = 3,
  95. kMaxValue = kOddWidthAndHeight,
  96. };
  97. // These values are persisted to logs. Entries should not be renumbered and
  98. // numeric values should never be reused.
  99. enum class OddOffset {
  100. kEvenXAndY = 0,
  101. kOddXOnly = 1,
  102. kOddYOnly = 2,
  103. kOddXAndY = 3,
  104. kMaxValue = kOddXAndY,
  105. };
  106. } // namespace gfx
  107. #endif // UI_GFX_BUFFER_TYPES_H_