Merge "[HWC2on1Adapter]: Add support for HWC2_PFN_GET_CLIENT_TARGET_SUPPORT"
diff --git a/include/gui/FrameTimestamps.h b/include/gui/FrameTimestamps.h
index bda3c5c..cbb4491 100644
--- a/include/gui/FrameTimestamps.h
+++ b/include/gui/FrameTimestamps.h
@@ -105,7 +105,7 @@
struct CompositorTiming {
nsecs_t deadline{0};
nsecs_t interval{16666667};
- nsecs_t presentLatency{0};
+ nsecs_t presentLatency{16666667};
};
// A short history of frames that are synchronized between the consumer and
diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp
index da6f13d..58227e6 100644
--- a/libs/gui/tests/Surface_test.cpp
+++ b/libs/gui/tests/Surface_test.cpp
@@ -52,6 +52,8 @@
mComposerClient = new SurfaceComposerClient;
ASSERT_EQ(NO_ERROR, mComposerClient->initCheck());
+ // TODO(brianderson): The following sometimes fails and is a source of
+ // test flakiness.
mSurfaceControl = mComposerClient->createSurface(
String8("Test Surface"), 32, 32, PIXEL_FORMAT_RGBA_8888, 0);
@@ -526,7 +528,7 @@
};
-class GetFrameTimestampsTest : public SurfaceTest {
+class GetFrameTimestampsTest : public ::testing::Test {
protected:
struct FenceAndFenceTime {
explicit FenceAndFenceTime(FenceToFenceTimeMap& fenceMap)
@@ -616,11 +618,9 @@
RefreshEvents mRefreshes[3];
};
- GetFrameTimestampsTest() : SurfaceTest() {}
+ GetFrameTimestampsTest() {}
virtual void SetUp() {
- SurfaceTest::SetUp();
-
BufferQueue::createBufferQueue(&mProducer, &mConsumer);
mFakeConsumer = new FakeConsumer;
mCfeh = &mFakeConsumer->mFrameEventHistory;
diff --git a/libs/vr/libpdx/private/pdx/rpc/remote_method.h b/libs/vr/libpdx/private/pdx/rpc/remote_method.h
index 49bee40..679503c 100644
--- a/libs/vr/libpdx/private/pdx/rpc/remote_method.h
+++ b/libs/vr/libpdx/private/pdx/rpc/remote_method.h
@@ -25,10 +25,9 @@
// Evaluates to true if the method type is <any>(Void), false otherwise.
template <typename RemoteMethodType>
using IsVoidMethod = typename std::integral_constant<
- bool,
- RemoteMethodType::Traits::Arity == 1 &&
- std::is_same<typename RemoteMethodType::Traits::template Arg<0>,
- Void>::value>;
+ bool, RemoteMethodType::Traits::Arity == 1 &&
+ std::is_same<typename RemoteMethodType::Traits::template Arg<0>,
+ Void>::value>;
// Utility to determine if a method is of type <any>(Void).
template <typename RemoteMethodType>
@@ -274,7 +273,9 @@
void DispatchRemoteMethod(
Class& instance, ChannelHandle<Mode> (Class::*method)(Message&, Args...),
Message& message, std::size_t max_capacity = InitialBufferCapacity) {
- using Signature = typename RemoteMethodType::template RewriteArgs<Args...>;
+ using Signature =
+ typename RemoteMethodType::template RewriteSignature<ChannelHandle<Mode>,
+ Args...>;
rpc::ServicePayload<ReceiveBuffer> payload(message);
payload.Resize(max_capacity);
diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk
index 3aab4cf..a6ea750 100644
--- a/services/surfaceflinger/Android.mk
+++ b/services/surfaceflinger/Android.mk
@@ -69,16 +69,6 @@
LOCAL_CFLAGS += -DNUM_FRAMEBUFFER_SURFACE_BUFFERS=$(NUM_FRAMEBUFFER_SURFACE_BUFFERS)
endif
-ifeq ($(TARGET_RUNNING_WITHOUT_SYNC_FRAMEWORK),true)
- LOCAL_CFLAGS += -DRUNNING_WITHOUT_SYNC_FRAMEWORK
-endif
-
-ifneq ($(MAX_VIRTUAL_DISPLAY_DIMENSION),)
- LOCAL_CFLAGS += -DMAX_VIRTUAL_DISPLAY_DIMENSION=$(MAX_VIRTUAL_DISPLAY_DIMENSION)
-else
- LOCAL_CFLAGS += -DMAX_VIRTUAL_DISPLAY_DIMENSION=0
-endif
-
LOCAL_CFLAGS += -fvisibility=hidden -Werror=format
LOCAL_HEADER_LIBRARIES := \
diff --git a/services/surfaceflinger/DispSync.cpp b/services/surfaceflinger/DispSync.cpp
index d7654f1..bd9b8aa 100644
--- a/services/surfaceflinger/DispSync.cpp
+++ b/services/surfaceflinger/DispSync.cpp
@@ -216,7 +216,8 @@
return BAD_VALUE;
}
- // This method is only here to handle the kIgnorePresentFences case.
+ // This method is only here to handle the !SurfaceFlinger::hasSyncFramework
+ // case.
bool hasAnyEventListeners() {
if (kTraceDetailedInfo) ATRACE_CALL();
Mutex::Autolock lock(mMutex);
@@ -376,7 +377,8 @@
DispSync::DispSync(const char* name) :
mName(name),
mRefreshSkipCount(0),
- mThread(new DispSyncThread(name)) {
+ mThread(new DispSyncThread(name)),
+ mIgnorePresentFences(!SurfaceFlinger::hasSyncFramework){
mPresentTimeOffset = SurfaceFlinger::dispSyncPresentTimeOffset;
mThread->run("DispSync", PRIORITY_URGENT_DISPLAY + PRIORITY_MORE_FAVORABLE);
@@ -397,7 +399,7 @@
// Even if we're just ignoring the fences, the zero-phase tracing is
// not needed because any time there is an event registered we will
// turn on the HW vsync events.
- if (!kIgnorePresentFences && kEnableZeroPhaseTracer) {
+ if (!mIgnorePresentFences && kEnableZeroPhaseTracer) {
addEventListener("ZeroPhaseTracer", 0, new ZeroPhaseTracer());
}
}
@@ -476,7 +478,7 @@
resetErrorLocked();
}
- if (kIgnorePresentFences) {
+ if (mIgnorePresentFences) {
// If we don't have the sync framework we will never have
// addPresentFence called. This means we have no way to know whether
// or not we're synchronized with the HW vsyncs, so we just request
@@ -641,7 +643,7 @@
void DispSync::dump(String8& result) const {
Mutex::Autolock lock(mMutex);
result.appendFormat("present fences are %s\n",
- kIgnorePresentFences ? "ignored" : "used");
+ mIgnorePresentFences ? "ignored" : "used");
result.appendFormat("mPeriod: %" PRId64 " ns (%.3f fps; skipCount=%d)\n",
mPeriod, 1000000000.0 / mPeriod, mRefreshSkipCount);
result.appendFormat("mPhase: %" PRId64 " ns\n", mPhase);
diff --git a/services/surfaceflinger/DispSync.h b/services/surfaceflinger/DispSync.h
index 5b7083d..82ae795 100644
--- a/services/surfaceflinger/DispSync.h
+++ b/services/surfaceflinger/DispSync.h
@@ -25,15 +25,6 @@
namespace android {
-// Ignore present (retire) fences if the device doesn't have support for the
-// sync framework
-#if defined(RUNNING_WITHOUT_SYNC_FRAMEWORK)
-static const bool kIgnorePresentFences = true;
-#else
-static const bool kIgnorePresentFences = false;
-#endif
-
-
class String8;
class Fence;
class DispSyncThread;
@@ -186,6 +177,10 @@
// This is the offset from the present fence timestamps to the corresponding
// vsync event.
int64_t mPresentTimeOffset;
+
+ // Ignore present (retire) fences if the device doesn't have support for the
+ // sync framework
+ bool mIgnorePresentFences;
};
}
diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp
index 9af4402..11df4e2 100644
--- a/services/surfaceflinger/DisplayDevice.cpp
+++ b/services/surfaceflinger/DisplayDevice.cpp
@@ -118,6 +118,9 @@
mNativeWindow = surface = new Surface(producer, false);
ANativeWindow* const window = mNativeWindow.get();
+#ifdef USE_HWC2
+ mActiveColorMode = static_cast<android_color_mode_t>(-1);
+#endif
/*
* Create our display's surface
*/
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
index 6644bd9..23b7a45 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
@@ -267,12 +267,12 @@
return NO_MEMORY;
}
- if (MAX_VIRTUAL_DISPLAY_DIMENSION != 0 &&
- (width > MAX_VIRTUAL_DISPLAY_DIMENSION ||
- height > MAX_VIRTUAL_DISPLAY_DIMENSION)) {
+ if (SurfaceFlinger::maxVirtualDisplaySize != 0 &&
+ (width > SurfaceFlinger::maxVirtualDisplaySize ||
+ height > SurfaceFlinger::maxVirtualDisplaySize)) {
ALOGE("createVirtualDisplay: Can't create a virtual display with"
- " a dimension > %u (tried %u x %u)",
- MAX_VIRTUAL_DISPLAY_DIMENSION, width, height);
+ " a dimension > %" PRIu64 " (tried %u x %u)",
+ SurfaceFlinger::maxVirtualDisplaySize, width, height);
return INVALID_OPERATION;
}
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 295b229..861a7d9 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -760,9 +760,7 @@
mHwcLayers[hwcId].forceClientComposition = true;
}
-#endif
-#ifdef USE_HWC2
void Layer::setPerFrameData(const sp<const DisplayDevice>& displayDevice) {
// Apply this display's projection's viewport to the visible region
// before giving it to the HWC HAL.
@@ -865,6 +863,10 @@
static_cast<int32_t>(error));
}
}
+
+android_dataspace Layer::getDataSpace() const {
+ return mCurrentState.dataSpace;
+}
#else
void Layer::setPerFrameData(const sp<const DisplayDevice>& hw,
HWComposer::HWCLayerInterface& layer) {
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index 6b228b0..afe6074 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -261,6 +261,8 @@
void forceClientComposition(int32_t hwcId);
void setPerFrameData(const sp<const DisplayDevice>& displayDevice);
+ android_dataspace getDataSpace() const;
+
// callIntoHwc exists so we can update our local state and call
// acceptDisplayChanges without unnecessarily updating the device's state
void setCompositionType(int32_t hwcId, HWC2::Composition type,
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 5f1d16f..06dd903 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -99,6 +99,7 @@
namespace android {
+
using namespace android::hardware::configstore;
using namespace android::hardware::configstore::V1_0;
@@ -115,6 +116,8 @@
bool SurfaceFlinger::useContextPriority;
int64_t SurfaceFlinger::dispSyncPresentTimeOffset;
bool SurfaceFlinger::useHwcForRgbToYuv;
+uint64_t SurfaceFlinger::maxVirtualDisplaySize;
+bool SurfaceFlinger::hasSyncFramework;
SurfaceFlinger::SurfaceFlinger()
: BnSurfaceComposer(),
@@ -158,6 +161,7 @@
,mEnterVrMode(false)
#endif
{
+ ALOGI("SurfaceFlinger is starting");
vsyncPhaseOffsetNs = getInt64< ISurfaceFlingerConfigs,
&ISurfaceFlingerConfigs::vsyncEventPhaseOffsetNs>(1000000);
@@ -165,7 +169,8 @@
sfVsyncPhaseOffsetNs = getInt64< ISurfaceFlingerConfigs,
&ISurfaceFlingerConfigs::vsyncSfEventPhaseOffsetNs>(1000000);
- ALOGI("SurfaceFlinger is starting");
+ hasSyncFramework = getBool< ISurfaceFlingerConfigs,
+ &ISurfaceFlingerConfigs::hasSyncFramework>(true);
useContextPriority = getBool< ISurfaceFlingerConfigs,
&ISurfaceFlingerConfigs::useContextPriority>(false);
@@ -176,6 +181,9 @@
useHwcForRgbToYuv = getBool< ISurfaceFlingerConfigs,
&ISurfaceFlingerConfigs::useHwcForRGBtoYUV>(false);
+ maxVirtualDisplaySize = getUInt64<ISurfaceFlingerConfigs,
+ &ISurfaceFlingerConfigs::maxVirtualDisplaySize>(0);
+
// debugging stuff...
char value[PROPERTY_VALUE_MAX];
@@ -1121,7 +1129,7 @@
}
void SurfaceFlinger::getCompositorTiming(CompositorTiming* compositorTiming) {
- std::lock_guard<std::mutex> lock(mCompositeTimingLock);
+ std::lock_guard<std::mutex> lock(mCompositorTimingLock);
*compositorTiming = mCompositorTiming;
}
@@ -1418,34 +1426,39 @@
mCompositePresentTimes.pop();
}
+ setCompositorTimingSnapped(
+ vsyncPhase, vsyncInterval, compositeToPresentLatency);
+}
+
+void SurfaceFlinger::setCompositorTimingSnapped(nsecs_t vsyncPhase,
+ nsecs_t vsyncInterval, nsecs_t compositeToPresentLatency) {
// Integer division and modulo round toward 0 not -inf, so we need to
// treat negative and positive offsets differently.
- nsecs_t idealLatency = (sfVsyncPhaseOffsetNs >= 0) ?
+ nsecs_t idealLatency = (sfVsyncPhaseOffsetNs > 0) ?
(vsyncInterval - (sfVsyncPhaseOffsetNs % vsyncInterval)) :
((-sfVsyncPhaseOffsetNs) % vsyncInterval);
+ // Just in case sfVsyncPhaseOffsetNs == -vsyncInterval.
+ if (idealLatency <= 0) {
+ idealLatency = vsyncInterval;
+ }
+
// Snap the latency to a value that removes scheduling jitter from the
// composition and present times, which often have >1ms of jitter.
// Reducing jitter is important if an app attempts to extrapolate
// something (such as user input) to an accurate diasplay time.
// Snapping also allows an app to precisely calculate sfVsyncPhaseOffsetNs
// with (presentLatency % interval).
- nsecs_t snappedCompositeToPresentLatency = -1;
- if (compositeToPresentLatency >= 0) {
- nsecs_t bias = vsyncInterval / 2;
- int64_t extraVsyncs =
- (compositeToPresentLatency - idealLatency + bias) /
- vsyncInterval;
- nsecs_t extraLatency = extraVsyncs * vsyncInterval;
- snappedCompositeToPresentLatency = idealLatency + extraLatency;
- }
+ nsecs_t bias = vsyncInterval / 2;
+ int64_t extraVsyncs =
+ (compositeToPresentLatency - idealLatency + bias) / vsyncInterval;
+ nsecs_t snappedCompositeToPresentLatency = (extraVsyncs > 0) ?
+ idealLatency + (extraVsyncs * vsyncInterval) : idealLatency;
- std::lock_guard<std::mutex> lock(mCompositeTimingLock);
+ std::lock_guard<std::mutex> lock(mCompositorTimingLock);
mCompositorTiming.deadline = vsyncPhase - idealLatency;
mCompositorTiming.interval = vsyncInterval;
- if (snappedCompositeToPresentLatency >= 0) {
- mCompositorTiming.presentLatency = snappedCompositeToPresentLatency;
- }
+ mCompositorTiming.presentLatency = snappedCompositeToPresentLatency;
}
void SurfaceFlinger::postComposition(nsecs_t refreshStartTime)
@@ -1492,10 +1505,15 @@
// since updateCompositorTiming has snapping logic.
updateCompositorTiming(
vsyncPhase, vsyncInterval, refreshStartTime, displayFenceTime);
+ CompositorTiming compositorTiming;
+ {
+ std::lock_guard<std::mutex> lock(mCompositorTimingLock);
+ compositorTiming = mCompositorTiming;
+ }
mDrawingState.traverseInZOrder([&](Layer* layer) {
bool frameLatched = layer->onPostComposition(glCompositionDoneFenceTime,
- *presentFenceTime, *retireFenceTime, mCompositorTiming);
+ *presentFenceTime, *retireFenceTime, compositorTiming);
if (frameLatched) {
recordBufferingStats(layer->getName().string(),
layer->getOccupancyHistory(false));
@@ -1510,7 +1528,7 @@
}
}
- if (kIgnorePresentFences) {
+ if (!hasSyncFramework) {
if (hw->isDisplayOn()) {
enableHardwareVsync();
}
@@ -2974,10 +2992,9 @@
const nsecs_t period = activeConfig->getVsyncPeriod();
mAnimFrameTracker.setDisplayRefreshPeriod(period);
- {
- std::lock_guard<std::mutex> lock(mCompositeTimingLock);
- mCompositorTiming.interval = period;
- }
+ // Use phase of 0 since phase is not known.
+ // Use latency of 0, which will snap to the ideal latency.
+ setCompositorTimingSnapped(0, period, 0);
}
void SurfaceFlinger::initializeDisplays() {
@@ -3243,6 +3260,8 @@
result.appendFormat(" PRESENT_TIME_OFFSET=%" PRId64 , dispSyncPresentTimeOffset);
result.appendFormat(" FORCE_HWC_FOR_RBG_TO_YUV=%d", useHwcForRgbToYuv);
+ result.appendFormat(" MAX_VIRT_DISPLAY_DIM=%" PRIu64, maxVirtualDisplaySize);
+ result.appendFormat(" RUNNING_WITHOUT_SYNC_FRAMEWORK=%d", !hasSyncFramework);
result.append("]");
}
diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h
index e6ccc41..921ecf6 100644
--- a/services/surfaceflinger/SurfaceFlinger.h
+++ b/services/surfaceflinger/SurfaceFlinger.h
@@ -105,7 +105,6 @@
{
public:
-
// This is the phase offset in nanoseconds of the software vsync event
// relative to the vsync event reported by HWComposer. The software vsync
// event is when SurfaceFlinger and Choreographer-based applications run each
@@ -129,6 +128,9 @@
static int64_t vsyncPhaseOffsetNs;
static int64_t sfVsyncPhaseOffsetNs;
+ // If fences from sync Framework are supported.
+ static bool hasSyncFramework;
+
// Instruct the Render Engine to use EGL_IMG_context_priority is available.
static bool useContextPriority;
@@ -142,6 +144,10 @@
// GL composition.
static bool useHwcForRgbToYuv;
+ // Maximum dimension supported by HWC for virtual display.
+ // Equal to min(max_height, max_width).
+ static uint64_t maxVirtualDisplaySize;
+
static char const* getServiceName() ANDROID_API {
return "SurfaceFlinger";
}
@@ -460,6 +466,9 @@
void updateCompositorTiming(
nsecs_t vsyncPhase, nsecs_t vsyncInterval, nsecs_t compositeTime,
std::shared_ptr<FenceTime>& presentFenceTime);
+ void setCompositorTimingSnapped(
+ nsecs_t vsyncPhase, nsecs_t vsyncInterval,
+ nsecs_t compositeToPresentLatency);
void rebuildLayerStacks();
void setUpHWComposer();
void doComposition();
@@ -630,7 +639,7 @@
bool mHWVsyncAvailable;
// protected by mCompositorTimingLock;
- mutable std::mutex mCompositeTimingLock;
+ mutable std::mutex mCompositorTimingLock;
CompositorTiming mCompositorTiming;
// Only accessed from the main thread.
diff --git a/services/surfaceflinger/SurfaceFlinger_hwc1.cpp b/services/surfaceflinger/SurfaceFlinger_hwc1.cpp
index 6f6c08b..e8147cf 100644
--- a/services/surfaceflinger/SurfaceFlinger_hwc1.cpp
+++ b/services/surfaceflinger/SurfaceFlinger_hwc1.cpp
@@ -114,6 +114,8 @@
bool SurfaceFlinger::useContextPriority;
int64_t SurfaceFlinger::dispSyncPresentTimeOffset;
bool SurfaceFlinger::useHwcForRgbToYuv;
+uint64_t SurfaceFlinger::maxVirtualDisplaySize;
+bool SurfaceFlinger::hasSyncFramework;
SurfaceFlinger::SurfaceFlinger()
: BnSurfaceComposer(),
@@ -150,13 +152,19 @@
mLastSwapTime(0),
mNumLayers(0)
{
+ ALOGI("SurfaceFlinger is starting");
+
vsyncPhaseOffsetNs = getInt64< ISurfaceFlingerConfigs,
&ISurfaceFlingerConfigs::vsyncEventPhaseOffsetNs>(1000000);
sfVsyncPhaseOffsetNs = getInt64< ISurfaceFlingerConfigs,
&ISurfaceFlingerConfigs::vsyncSfEventPhaseOffsetNs>(1000000);
- ALOGI("SurfaceFlinger is starting");
+ maxVirtualDisplaySize = getUInt64<ISurfaceFlingerConfigs,
+ &ISurfaceFlingerConfigs::maxVirtualDisplaySize>(0);
+
+ hasSyncFramework = getBool< ISurfaceFlingerConfigs,
+ &ISurfaceFlingerConfigs::hasSyncFramework>(true);
useContextPriority = getBool< ISurfaceFlingerConfigs,
&ISurfaceFlingerConfigs::useContextPriority>(false);
@@ -1040,7 +1048,7 @@
}
void SurfaceFlinger::getCompositorTiming(CompositorTiming* compositorTiming) {
- std::lock_guard<std::mutex> lock(mCompositeTimingLock);
+ std::lock_guard<std::mutex> lock(mCompositorTimingLock);
*compositorTiming = mCompositorTiming;
}
@@ -1203,34 +1211,39 @@
mCompositePresentTimes.pop();
}
+ setCompositorTimingSnapped(
+ vsyncPhase, vsyncInterval, compositeToPresentLatency);
+}
+
+void SurfaceFlinger::setCompositorTimingSnapped(nsecs_t vsyncPhase,
+ nsecs_t vsyncInterval, nsecs_t compositeToPresentLatency) {
// Integer division and modulo round toward 0 not -inf, so we need to
// treat negative and positive offsets differently.
- nsecs_t idealLatency = (sfVsyncPhaseOffsetNs >= 0) ?
+ nsecs_t idealLatency = (sfVsyncPhaseOffsetNs > 0) ?
(vsyncInterval - (sfVsyncPhaseOffsetNs % vsyncInterval)) :
((-sfVsyncPhaseOffsetNs) % vsyncInterval);
+ // Just in case sfVsyncPhaseOffsetNs == -vsyncInterval.
+ if (idealLatency <= 0) {
+ idealLatency = vsyncInterval;
+ }
+
// Snap the latency to a value that removes scheduling jitter from the
// composition and present times, which often have >1ms of jitter.
// Reducing jitter is important if an app attempts to extrapolate
// something (such as user input) to an accurate diasplay time.
// Snapping also allows an app to precisely calculate sfVsyncPhaseOffsetNs
// with (presentLatency % interval).
- nsecs_t snappedCompositeToPresentLatency = -1;
- if (compositeToPresentLatency >= 0) {
- nsecs_t bias = vsyncInterval / 2;
- int64_t extraVsyncs =
- (compositeToPresentLatency - idealLatency + bias) /
- vsyncInterval;
- nsecs_t extraLatency = extraVsyncs * vsyncInterval;
- snappedCompositeToPresentLatency = idealLatency + extraLatency;
- }
+ nsecs_t bias = vsyncInterval / 2;
+ int64_t extraVsyncs =
+ (compositeToPresentLatency - idealLatency + bias) / vsyncInterval;
+ nsecs_t snappedCompositeToPresentLatency = (extraVsyncs > 0) ?
+ idealLatency + (extraVsyncs * vsyncInterval) : idealLatency;
- std::lock_guard<std::mutex> lock(mCompositeTimingLock);
+ std::lock_guard<std::mutex> lock(mCompositorTimingLock);
mCompositorTiming.deadline = vsyncPhase - idealLatency;
mCompositorTiming.interval = vsyncInterval;
- if (snappedCompositeToPresentLatency >= 0) {
- mCompositorTiming.presentLatency = snappedCompositeToPresentLatency;
- }
+ mCompositorTiming.presentLatency = snappedCompositeToPresentLatency;
}
void SurfaceFlinger::postComposition(nsecs_t refreshStartTime)
@@ -1262,10 +1275,15 @@
// since updateCompositorTiming has snapping logic.
updateCompositorTiming(
vsyncPhase, vsyncInterval, refreshStartTime, retireFenceTime);
+ CompositorTiming compositorTiming;
+ {
+ std::lock_guard<std::mutex> lock(mCompositorTimingLock);
+ compositorTiming = mCompositorTiming;
+ }
mDrawingState.traverseInZOrder([&](Layer* layer) {
bool frameLatched = layer->onPostComposition(glCompositionDoneFenceTime,
- presentFenceTime, retireFenceTime, mCompositorTiming);
+ presentFenceTime, retireFenceTime, compositorTiming);
if (frameLatched) {
recordBufferingStats(layer->getName().string(),
layer->getOccupancyHistory(false));
@@ -1280,7 +1298,7 @@
}
}
- if (kIgnorePresentFences) {
+ if (!hasSyncFramework) {
if (hw->isDisplayOn()) {
enableHardwareVsync();
}
@@ -1701,9 +1719,9 @@
ALOGE_IF(status != NO_ERROR,
"Unable to query height (%d)", status);
if (mUseHwcVirtualDisplays &&
- (MAX_VIRTUAL_DISPLAY_DIMENSION == 0 ||
- (width <= MAX_VIRTUAL_DISPLAY_DIMENSION &&
- height <= MAX_VIRTUAL_DISPLAY_DIMENSION))) {
+ (SurfaceFlinger::maxVirtualDisplaySize == 0 ||
+ (width <= static_cast<int>(SurfaceFlinger::maxVirtualDisplaySize) &&
+ height <= static_cast<int>(SurfaceFlinger::maxVirtualDisplaySize)))) {
hwcDisplayId = allocateHwcDisplayId(state.type);
}
@@ -2750,6 +2768,10 @@
const nsecs_t period =
getHwComposer().getRefreshPeriod(HWC_DISPLAY_PRIMARY);
mAnimFrameTracker.setDisplayRefreshPeriod(period);
+
+ // Use phase of 0 since phase is not known.
+ // Use latency of 0, which will snap to the ideal latency.
+ setCompositorTimingSnapped(0, period, 0);
}
void SurfaceFlinger::initializeDisplays() {
@@ -3015,6 +3037,8 @@
result.appendFormat(" PRESENT_TIME_OFFSET=%" PRId64, dispSyncPresentTimeOffset);
result.appendFormat(" FORCE_HWC_FOR_RBG_TO_YUV=%d", useHwcForRgbToYuv);
+ result.appendFormat(" MAX_VIRT_DISPLAY_DIM=%" PRIu64, maxVirtualDisplaySize);
+ result.appendFormat(" RUNNING_WITHOUT_SYNC_FRAMEWORK=%d", !hasSyncFramework);
result.append("]");
}
diff --git a/services/vr/vr_window_manager/composer/impl/vr_hwc.cpp b/services/vr/vr_window_manager/composer/impl/vr_hwc.cpp
index 99e21ec..60ca818 100644
--- a/services/vr/vr_window_manager/composer/impl/vr_hwc.cpp
+++ b/services/vr/vr_window_manager/composer/impl/vr_hwc.cpp
@@ -312,32 +312,12 @@
return Error::BAD_CONFIG;
}
- int error = 0;
- auto display_client = DisplayClient::Create(&error);
- SystemDisplayMetrics metrics;
-
- if (error) {
- ALOGE("Could not connect to display service : %s(%d)", strerror(error), error);
- } else {
- error = display_client->GetDisplayMetrics(&metrics);
-
- if (error) {
- ALOGE("Could not get display metrics from display service : %s(%d)", strerror(error), error);
- }
- }
-
- if (error) {
- metrics.display_native_width = 1080;
- metrics.display_native_height = 1920;
- ALOGI("Setting display metrics to default : width=%d height=%d", metrics.display_native_width, metrics.display_native_height);
- }
-
switch (attribute) {
case IComposerClient::Attribute::WIDTH:
- *outValue = metrics.display_native_width;
+ *outValue = 1080;
break;
case IComposerClient::Attribute::HEIGHT:
- *outValue = metrics.display_native_height;
+ *outValue = 1920;
break;
case IComposerClient::Attribute::VSYNC_PERIOD:
*outValue = 1000 * 1000 * 1000 / 30; // 30fps
diff --git a/services/vr/vr_window_manager/surface_flinger_view.cpp b/services/vr/vr_window_manager/surface_flinger_view.cpp
index 46eb880..8411806 100644
--- a/services/vr/vr_window_manager/surface_flinger_view.cpp
+++ b/services/vr/vr_window_manager/surface_flinger_view.cpp
@@ -39,29 +39,9 @@
vr_composer_view_->Initialize(GetComposerViewFromIComposer(
vr_hwcomposer_.get()));
- int error = 0;
- auto display_client = DisplayClient::Create(&error);
- SystemDisplayMetrics metrics;
-
- if (error) {
- ALOGE("Could not connect to display service : %s(%d)", strerror(error), error);
- } else {
- error = display_client->GetDisplayMetrics(&metrics);
-
- if (error) {
- ALOGE("Could not get display metrics from display service : %s(%d)", strerror(error), error);
- }
- }
-
- if (error) {
- metrics.display_native_height = 1920;
- metrics.display_native_width = 1080;
- ALOGI("Setting display metrics to default : width=%d height=%d", metrics.display_native_height, metrics.display_native_width);
- }
-
// TODO(alexst): Refactor ShellView to account for orientation and change this back.
- width_ = metrics.display_native_height;
- height_ = metrics.display_native_width;
+ width_ = 1920;
+ height_ = 1080;
return true;
}
diff --git a/vulkan/include/vulkan/vulkan.h b/vulkan/include/vulkan/vulkan.h
index 2293960..4b3b8bf 100644
--- a/vulkan/include/vulkan/vulkan.h
+++ b/vulkan/include/vulkan/vulkan.h
@@ -3306,14 +3306,14 @@
VK_COLOR_SPACE_SRGB_NONLINEAR_KHR = 0,
VK_COLOR_SPACE_DISPLAY_P3_NONLINEAR_EXT = 1000104001,
VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT = 1000104002,
- VK_COLOR_SPACE_EXTENDED_SRGB_NONLINEAR_EXT = 1000104003,
- VK_COLOR_SPACE_DCI_P3_LINEAR_EXT = 1000104004,
- VK_COLOR_SPACE_DCI_P3_NONLINEAR_EXT = 1000104005,
- VK_COLOR_SPACE_BT709_LINEAR_EXT = 1000104006,
- VK_COLOR_SPACE_BT709_NONLINEAR_EXT = 1000104007,
- VK_COLOR_SPACE_BT2020_LINEAR_EXT = 1000104008,
- VK_COLOR_SPACE_BT2020_170M_EXT = 1000104009,
- VK_COLOR_SPACE_BT2020_ST2084_EXT = 1000104010,
+ VK_COLOR_SPACE_DCI_P3_LINEAR_EXT = 1000104003,
+ VK_COLOR_SPACE_DCI_P3_NONLINEAR_EXT = 1000104004,
+ VK_COLOR_SPACE_BT709_LINEAR_EXT = 1000104005,
+ VK_COLOR_SPACE_BT709_NONLINEAR_EXT = 1000104006,
+ VK_COLOR_SPACE_BT2020_LINEAR_EXT = 1000104007,
+ VK_COLOR_SPACE_HDR10_ST2084_EXT = 1000104008,
+ VK_COLOR_SPACE_DOLBYVISION_EXT = 1000104009,
+ VK_COLOR_SPACE_HDR10_HLG_EXT = 1000104010,
VK_COLOR_SPACE_ADOBERGB_LINEAR_EXT = 1000104011,
VK_COLOR_SPACE_ADOBERGB_NONLINEAR_EXT = 1000104012,
VK_COLOR_SPACE_PASS_THROUGH_EXT = 1000104013,
diff --git a/vulkan/libvulkan/swapchain.cpp b/vulkan/libvulkan/swapchain.cpp
index b24bc1b..f7695ea 100644
--- a/vulkan/libvulkan/swapchain.cpp
+++ b/vulkan/libvulkan/swapchain.cpp
@@ -411,8 +411,6 @@
return HAL_DATASPACE_DISPLAY_P3;
case VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT:
return HAL_DATASPACE_V0_SCRGB_LINEAR;
- case VK_COLOR_SPACE_EXTENDED_SRGB_NONLINEAR_EXT:
- return HAL_DATASPACE_V0_SCRGB;
case VK_COLOR_SPACE_DCI_P3_LINEAR_EXT:
return HAL_DATASPACE_DCI_P3_LINEAR;
case VK_COLOR_SPACE_DCI_P3_NONLINEAR_EXT:
@@ -421,14 +419,20 @@
return HAL_DATASPACE_V0_SRGB_LINEAR;
case VK_COLOR_SPACE_BT709_NONLINEAR_EXT:
return HAL_DATASPACE_V0_SRGB;
- case VK_COLOR_SPACE_BT2020_170M_EXT:
- return static_cast<android_dataspace>(
- HAL_DATASPACE_STANDARD_BT2020 |
- HAL_DATASPACE_TRANSFER_SMPTE_170M | HAL_DATASPACE_RANGE_FULL);
- case VK_COLOR_SPACE_BT2020_ST2084_EXT:
+ case VK_COLOR_SPACE_BT2020_LINEAR_EXT:
+ return HAL_DATASPACE_BT2020_LINEAR;
+ case VK_COLOR_SPACE_HDR10_ST2084_EXT:
return static_cast<android_dataspace>(
HAL_DATASPACE_STANDARD_BT2020 | HAL_DATASPACE_TRANSFER_ST2084 |
HAL_DATASPACE_RANGE_FULL);
+ case VK_COLOR_SPACE_DOLBYVISION_EXT:
+ return static_cast<android_dataspace>(
+ HAL_DATASPACE_STANDARD_BT2020 | HAL_DATASPACE_TRANSFER_ST2084 |
+ HAL_DATASPACE_RANGE_FULL);
+ case VK_COLOR_SPACE_HDR10_HLG_EXT:
+ return static_cast<android_dataspace>(
+ HAL_DATASPACE_STANDARD_BT2020 | HAL_DATASPACE_TRANSFER_HLG |
+ HAL_DATASPACE_RANGE_FULL);
case VK_COLOR_SPACE_ADOBERGB_LINEAR_EXT:
return static_cast<android_dataspace>(
HAL_DATASPACE_STANDARD_ADOBE_RGB |