diff options
author | Haixia Shi <hshi@chromium.org> | 2015-10-05 14:35:09 -0700 |
---|---|---|
committer | Haixia Shi <hshi@chromium.org> | 2015-10-07 16:03:10 -0700 |
commit | d21f528156b17c9e069bfb4e215d7e399c94795b (patch) | |
tree | 3774d9aa41472d237df92583a07feefcbae47ba6 /hwcomposer.cpp | |
parent | c9d98e57d47177b8ce1b5eff8e8f490e9bdbc16f (diff) | |
download | drm_hwcomposer-d21f528156b17c9e069bfb4e215d7e399c94795b.tar.gz |
drm_hwcomposer: support virtual displaysmarshmallow-dr-dev
Virtual display support is mandatory for HWC version 1.4.
As a minimal implementation, we use frambuffer target and let SF take care of
GLES composition. We still need to handle the acquire and release fences for
both the virtual display and all layers in a separate worker thread.
BUG=24609829
TEST=screen casting to chromecast
Change-Id: Idb962f4b5bb852c9ec9ebcaa1679a653c01737fb
Diffstat (limited to 'hwcomposer.cpp')
-rw-r--r-- | hwcomposer.cpp | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/hwcomposer.cpp b/hwcomposer.cpp index 3035362..a7c9e43 100644 --- a/hwcomposer.cpp +++ b/hwcomposer.cpp @@ -20,6 +20,7 @@ #include "drm_hwcomposer.h" #include "drmresources.h" #include "importer.h" +#include "virtualcompositorworker.h" #include "vsyncworker.h" #include <stdlib.h> @@ -133,6 +134,7 @@ struct hwc_context_t { } ~hwc_context_t() { + virtual_compositor_worker.Exit(); delete importer; } @@ -145,6 +147,7 @@ struct hwc_context_t { const gralloc_module_t *gralloc; DummySwSyncTimeline dummy_timeline; bool use_framebuffer_target; + VirtualCompositorWorker virtual_compositor_worker; }; static native_handle_t *dup_buffer_handle(buffer_handle_t handle) { @@ -346,17 +349,22 @@ static int hwc_prepare(hwc_composer_device_1_t *dev, size_t num_displays, if (!display_contents[i]) continue; - DrmCrtc *crtc = ctx->drm.GetCrtcForDisplay(i); - if (!crtc) { - ALOGE("No crtc for display %d", i); - return -ENODEV; + bool use_framebuffer_target = ctx->use_framebuffer_target; + if (i == HWC_DISPLAY_VIRTUAL) { + use_framebuffer_target = true; + } else { + DrmCrtc *crtc = ctx->drm.GetCrtcForDisplay(i); + if (!crtc) { + ALOGE("No crtc for display %d", i); + return -ENODEV; + } } int num_layers = display_contents[i]->numHwLayers; for (int j = 0; j < num_layers; j++) { hwc_layer_1_t *layer = &display_contents[i]->hwLayers[j]; - if (!ctx->use_framebuffer_target) { + if (!use_framebuffer_target) { if (layer->compositionType == HWC_FRAMEBUFFER) layer->compositionType = HWC_OVERLAY; } else { @@ -415,6 +423,11 @@ static int hwc_set(hwc_composer_device_1_t *dev, size_t num_displays, if (!sf_display_contents[i]) continue; + if (i == HWC_DISPLAY_VIRTUAL) { + ctx->virtual_compositor_worker.QueueComposite(dc); + continue; + } + std::ostringstream display_index_formatter; display_index_formatter << "retire fence for display " << i; std::string display_fence_description(display_index_formatter.str()); @@ -576,7 +589,7 @@ static int hwc_query(struct hwc_composer_device_1 * /* dev */, int what, *value = 1000 * 1000 * 1000 / 60; break; case HWC_DISPLAY_TYPES_SUPPORTED: - *value = HWC_DISPLAY_PRIMARY | HWC_DISPLAY_EXTERNAL; + *value = HWC_DISPLAY_PRIMARY | HWC_DISPLAY_EXTERNAL | HWC_DISPLAY_VIRTUAL; break; } return 0; @@ -789,6 +802,11 @@ static int hwc_enumerate_displays(struct hwc_context_t *ctx) { } } + ret = ctx->virtual_compositor_worker.Init(); + if (ret) { + ALOGE("Failed to initialize virtual compositor worker"); + return ret; + } return 0; } |