1 #include "surface_flinger_view.h"
3 #include <impl/vr_composer_view.h>
4 #include <private/dvr/native_buffer.h>
6 #include "hwc_callback.h"
12 SurfaceFlingerView::SurfaceFlingerView() {}
14 SurfaceFlingerView::~SurfaceFlingerView() {}
16 bool SurfaceFlingerView::Initialize(HwcCallback::Client *client) {
17 const char vr_hwcomposer_name[] = "vr_hwcomposer";
18 vr_hwcomposer_ = HIDL_FETCH_IComposer(vr_hwcomposer_name);
19 if (!vr_hwcomposer_.get()) {
20 ALOGE("Failed to get vr_hwcomposer");
24 if (vr_hwcomposer_->isRemote()) {
25 ALOGE("vr_hwcomposer service is remote");
29 const android::status_t vr_hwcomposer_status =
30 vr_hwcomposer_->registerAsService(vr_hwcomposer_name);
31 if (vr_hwcomposer_status != OK) {
32 ALOGE("Failed to register vr_hwcomposer service");
37 std::make_unique<VrComposerView>(std::make_unique<HwcCallback>(client));
38 vr_composer_view_->Initialize(GetComposerViewFromIComposer(
39 vr_hwcomposer_.get()));
41 // TODO(dnicoara): Query this from the composer service.
47 bool SurfaceFlingerView::GetTextures(const HwcCallback::Frame& frame,
48 std::vector<TextureLayer>* texture_layers,
49 TextureLayer* ime_layer,
50 bool debug, bool skip_first_layer) const {
51 auto& layers = frame.layers();
52 texture_layers->clear();
55 // Skip the second layer if it is from the VR app.
56 if (!debug && skip_first_layer) {
58 if (layers[0].appid && layers[0].appid == layers[1].appid)
62 for (size_t i = start; i < layers.size(); ++i) {
63 if (!debug && layers[i].should_skip_layer())
66 std::unique_ptr<Texture> texture(new Texture());
67 if (!texture->Initialize(layers[i].buffer->getNativeBuffer())) {
68 ALOGE("Failed to create texture");
69 texture_layers->clear();
73 TextureLayer texture_layer = {
74 std::move(texture), layers[i].crop, layers[i].display_frame,
75 layers[i].blending, layers[i].alpha,
77 if (debug && layers[i].type == HwcCallback::HwcLayer::kInputMethod) {
78 *ime_layer = std::move(texture_layer);
80 texture_layers->emplace_back(std::move(texture_layer));
88 } // namespace android