diff options
Diffstat (limited to 'services/surfaceflinger/DisplayHardware/ComposerHal.h')
-rw-r--r-- | services/surfaceflinger/DisplayHardware/ComposerHal.h | 59 |
1 files changed, 47 insertions, 12 deletions
diff --git a/services/surfaceflinger/DisplayHardware/ComposerHal.h b/services/surfaceflinger/DisplayHardware/ComposerHal.h index b525e63c66..00ef782ef7 100644 --- a/services/surfaceflinger/DisplayHardware/ComposerHal.h +++ b/services/surfaceflinger/DisplayHardware/ComposerHal.h @@ -18,7 +18,6 @@ #define ANDROID_SF_COMPOSER_HAL_H #include <memory> -#include <optional> #include <string> #include <unordered_map> #include <utility> @@ -27,13 +26,14 @@ // TODO(b/129481165): remove the #pragma below and fix conversion issues #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wconversion" -#pragma clang diagnostic ignored "-Wextra" +#if defined(USE_VR_COMPOSER) && USE_VR_COMPOSER +#include <android/frameworks/vr/composer/2.0/IVrComposerClient.h> +#endif // defined(USE_VR_COMPOSER) && USE_VR_COMPOSER #include <android/hardware/graphics/common/1.1/types.h> #include <android/hardware/graphics/composer/2.4/IComposer.h> #include <android/hardware/graphics/composer/2.4/IComposerClient.h> #include <composer-command-buffer/2.4/ComposerCommandBuffer.h> -#include <gui/BufferQueue.h> #include <gui/HdrMetadata.h> #include <math/mat4.h> #include <ui/DisplayedFrameStats.h> @@ -41,12 +41,16 @@ #include <utils/StrongPointer.h> // TODO(b/129481165): remove the #pragma below and fix conversion issues -#pragma clang diagnostic pop // ignored "-Wconversion -Wextra" +#pragma clang diagnostic pop // ignored "-Wconversion" namespace android { namespace Hwc2 { +#if defined(USE_VR_COMPOSER) && USE_VR_COMPOSER +using frameworks::vr::composer::V2_0::IVrComposerClient; +#endif // defined(USE_VR_COMPOSER) && USE_VR_COMPOSER + namespace types = hardware::graphics::common; namespace V2_1 = hardware::graphics::composer::V2_1; @@ -87,6 +91,11 @@ public: virtual void registerCallback(const sp<IComposerCallback>& callback) = 0; + // Returns true if the connected composer service is running in a remote + // process, false otherwise. This will return false if the service is + // configured in passthrough mode, for example. + virtual bool isRemote() = 0; + // Reset all pending commands in the command buffer. Useful if you want to // skip a frame but have already queued some commands. virtual void resetCommands() = 0; @@ -95,8 +104,9 @@ public: virtual Error executeCommands() = 0; virtual uint32_t getMaxVirtualDisplayCount() = 0; - virtual Error createVirtualDisplay(uint32_t width, uint32_t height, PixelFormat*, - std::optional<Display> mirror, Display* outDisplay) = 0; + virtual bool isUsingVrComposer() const = 0; + virtual Error createVirtualDisplay(uint32_t width, uint32_t height, PixelFormat* format, + Display* outDisplay) = 0; virtual Error destroyVirtualDisplay(Display display) = 0; virtual Error acceptDisplayChanges(Display display) = 0; @@ -178,6 +188,7 @@ public: virtual Error setLayerVisibleRegion(Display display, Layer layer, const std::vector<IComposerClient::Rect>& visible) = 0; virtual Error setLayerZOrder(Display display, Layer layer, uint32_t z) = 0; + virtual Error setLayerInfo(Display display, Layer layer, uint32_t type, uint32_t appId) = 0; // Composer HAL 2.2 virtual Error setLayerPerFrameMetadata( @@ -333,6 +344,11 @@ public: void registerCallback(const sp<IComposerCallback>& callback) override; + // Returns true if the connected composer service is running in a remote + // process, false otherwise. This will return false if the service is + // configured in passthrough mode, for example. + bool isRemote() override; + // Reset all pending commands in the command buffer. Useful if you want to // skip a frame but have already queued some commands. void resetCommands() override; @@ -341,8 +357,9 @@ public: Error executeCommands() override; uint32_t getMaxVirtualDisplayCount() override; + bool isUsingVrComposer() const override { return mIsUsingVrComposer; } Error createVirtualDisplay(uint32_t width, uint32_t height, PixelFormat* format, - std::optional<Display> mirror, Display* outDisplay) override; + Display* outDisplay) override; Error destroyVirtualDisplay(Display display) override; Error acceptDisplayChanges(Display display) override; @@ -419,6 +436,7 @@ public: Error setLayerVisibleRegion(Display display, Layer layer, const std::vector<IComposerClient::Rect>& visible) override; Error setLayerZOrder(Display display, Layer layer, uint32_t z) override; + Error setLayerInfo(Display display, Layer layer, uint32_t type, uint32_t appId) override; // Composer HAL 2.2 Error setLayerPerFrameMetadata( @@ -472,11 +490,29 @@ public: IComposerClient::ClientTargetProperty* outClientTargetProperty) override; private: +#if defined(USE_VR_COMPOSER) && USE_VR_COMPOSER + class CommandWriter : public CommandWriterBase { + public: + explicit CommandWriter(uint32_t initialMaxSize); + ~CommandWriter() override; + + void setLayerInfo(uint32_t type, uint32_t appId); + void setClientTargetMetadata( + const IVrComposerClient::BufferMetadata& metadata); + void setLayerBufferMetadata( + const IVrComposerClient::BufferMetadata& metadata); + + private: + void writeBufferMetadata( + const IVrComposerClient::BufferMetadata& metadata); + }; +#else class CommandWriter : public CommandWriterBase { public: explicit CommandWriter(uint32_t initialMaxSize) : CommandWriterBase(initialMaxSize) {} ~CommandWriter() override {} }; +#endif // defined(USE_VR_COMPOSER) && USE_VR_COMPOSER // Many public functions above simply write a command into the command // queue to batch the calls. validateDisplay and presentDisplay will call @@ -493,13 +529,12 @@ private: // 64KiB minus a small space for metadata such as read/write pointers static constexpr size_t kWriterInitialSize = 64 * 1024 / sizeof(uint32_t) - 16; - // Max number of buffers that may be cached for a given layer - // We obtain this number by: - // 1. Tightly coupling this cache to the max size of BufferQueue - // 2. Adding an additional slot for the layer caching feature in SurfaceFlinger (see: Planner.h) - static const constexpr uint32_t kMaxLayerBufferCount = BufferQueue::NUM_BUFFER_SLOTS + 1; CommandWriter mWriter; CommandReader mReader; + + // When true, the we attach to the vr_hwcomposer service instead of the + // hwcomposer. This allows us to redirect surfaces to 3d surfaces in vr. + const bool mIsUsingVrComposer; }; } // namespace impl |