Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e13ec188 authored by Daniel Nicoara's avatar Daniel Nicoara
Browse files

VR: Replace sw sync fences with egl sync fences

HWComposer::presentDisplay() synchronously calls into the VR WM
presentation code to queue the new frame. If VR WM is showing (drawing)
it will return an EGL fence that will be used to signal when the last
showing frame is no longer used in VR WM. Otherwise an invalid FD (-1)
is returned symbolizing that the last frame isn't in use anymore and the
caller can re-use those buffers immediately.

Bug: b/35096352
Test: Verified SurfaceFlinger output shows correctly in vr_wm
Change-Id: I2b7c2c767d4aa85370dd6519113cb9a2269c7477
parent bc000a77
Loading
Loading
Loading
Loading
+0 −18
Original line number Diff line number Diff line
@@ -6,13 +6,9 @@ genrule {
    cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hidl:system/libhidl/transport -randroid.hardware:hardware/interfaces/ -randroid.dvr:frameworks/native/services/vr/vr_window_manager android.dvr.composer@1.0",
    srcs: [
        "IVrComposerClient.hal",
        "IVrComposerView.hal",
        "IVrComposerCallback.hal",
    ],
    out: [
        "android/dvr/composer/1.0/VrComposerClientAll.cpp",
        "android/dvr/composer/1.0/VrComposerViewAll.cpp",
        "android/dvr/composer/1.0/VrComposerCallbackAll.cpp",
    ],
}

@@ -22,8 +18,6 @@ genrule {
    cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hidl:system/libhidl/transport -randroid.hardware:hardware/interfaces/ -randroid.dvr:frameworks/native/services/vr/vr_window_manager android.dvr.composer@1.0",
    srcs: [
        "IVrComposerClient.hal",
        "IVrComposerView.hal",
        "IVrComposerCallback.hal",
    ],
    out: [
        "android/dvr/composer/1.0/IVrComposerClient.h",
@@ -31,18 +25,6 @@ genrule {
        "android/dvr/composer/1.0/BnHwVrComposerClient.h",
        "android/dvr/composer/1.0/BpHwVrComposerClient.h",
        "android/dvr/composer/1.0/BsVrComposerClient.h",

        "android/dvr/composer/1.0/IVrComposerView.h",
        "android/dvr/composer/1.0/IHwVrComposerView.h",
        "android/dvr/composer/1.0/BnHwVrComposerView.h",
        "android/dvr/composer/1.0/BpHwVrComposerView.h",
        "android/dvr/composer/1.0/BsVrComposerView.h",

        "android/dvr/composer/1.0/IVrComposerCallback.h",
        "android/dvr/composer/1.0/IHwVrComposerCallback.h",
        "android/dvr/composer/1.0/BnHwVrComposerCallback.h",
        "android/dvr/composer/1.0/BpHwVrComposerCallback.h",
        "android/dvr/composer/1.0/BsVrComposerCallback.h",
    ],
}

+0 −18
Original line number Diff line number Diff line
package android.dvr.composer@1.0;

import android.hardware.graphics.composer@2.1::IComposerClient;

interface IVrComposerCallback {
    struct Layer {
        handle buffer;
        handle fence;
        android.hardware.graphics.composer@2.1::IComposerClient.Rect display_frame;
        android.hardware.graphics.composer@2.1::IComposerClient.FRect crop;
        android.hardware.graphics.composer@2.1::IComposerClient.BlendMode blend_mode;
        float alpha;
        uint32_t type;
        uint32_t app_id;
    };

    onNewFrame(vec<Layer> frame);
};
+0 −9
Original line number Diff line number Diff line
package android.dvr.composer@1.0;

import IVrComposerCallback;

interface IVrComposerView {
    registerCallback(IVrComposerCallback callback);

    releaseFrame();
};
+0 −6
Original line number Diff line number Diff line
@@ -6,7 +6,6 @@ cc_library_shared {
  name: "libvrhwc",

  srcs: [
    "impl/sync_timeline.cpp",
    "impl/vr_composer_view.cpp",
    "impl/vr_hwc.cpp",
    "impl/vr_composer_client.cpp",
@@ -33,11 +32,6 @@ cc_library_shared {

  export_include_dirs: ["."],

  include_dirs: [
    // Access to software sync timeline.
    "system/core/libsync",
  ],

  cflags: [
    "-DLOG_TAG=\"vrhwc\"",
  ],
+0 −43
Original line number Diff line number Diff line
/*
 * Copyright 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#include "sync_timeline.h"

#include <sys/cdefs.h>
#include <sw_sync.h>
#include <unistd.h>

namespace android {
namespace dvr {

SyncTimeline::SyncTimeline() {}

SyncTimeline::~SyncTimeline() {}

bool SyncTimeline::Initialize() {
  timeline_fd_.reset(sw_sync_timeline_create());
  return timeline_fd_ >= 0;
}

int SyncTimeline::CreateFence(int time) {
  return sw_sync_fence_create(timeline_fd_.get(), "dummy fence", time);
}

bool SyncTimeline::IncrementTimeline() {
  return sw_sync_timeline_inc(timeline_fd_.get(), 1) == 0;
}

}  // namespace dvr
}  // namespace android
Loading