Commit c6d3527b authored by Tom Anderson's avatar Tom Anderson Committed by Commit Bot

[XProto] Remove dependencies on dri2, present, and xf86vidmode

This is a partial revert of 7e489781.
It turns out removing GLX is not necessary since it's already
dynamically loaded.  Using GLX allows us to remove dependencies on
dri2, present, and xf86vidmode.

R=sunnyps

Bug: 1066670
Change-Id: I44b79b06de76a043f38dfd9270eee980134a7816
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2523661Reviewed-by: default avatarSunny Sachanandani <sunnyps@chromium.org>
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Commit-Queue: Sunny Sachanandani <sunnyps@chromium.org>
Auto-Submit: Thomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825100}
parent fba51033
......@@ -26,12 +26,6 @@
#include "ui/base/x/x11_util.h"
#include "ui/events/platform/platform_event_source.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/x/connection.h"
#include "ui/gfx/x/dri2.h"
#include "ui/gfx/x/glx.h"
#include "ui/gfx/x/present.h"
#include "ui/gfx/x/xf86vidmode.h"
#include "ui/gfx/x/xproto.h"
#include "ui/gfx/x/xproto_util.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h"
......@@ -103,8 +97,8 @@ bool CreateDummyWindow(x11::Connection* conn) {
class OMLSyncControlVSyncProvider : public SyncControlVSyncProvider {
public:
explicit OMLSyncControlVSyncProvider(x11::Window window)
: SyncControlVSyncProvider(), window_(window) {}
explicit OMLSyncControlVSyncProvider(GLXWindow glx_window)
: SyncControlVSyncProvider(), glx_window_(glx_window) {}
~OMLSyncControlVSyncProvider() override = default;
......@@ -112,85 +106,30 @@ class OMLSyncControlVSyncProvider : public SyncControlVSyncProvider {
bool GetSyncValues(int64_t* system_time,
int64_t* media_stream_counter,
int64_t* swap_buffer_counter) override {
auto* connection = x11::Connection::Get();
// First try to get the counter values using the DRI2 extension.
if (auto reply = connection->dri2().GetMSC({window_}).Sync()) {
auto merge_counter = [](uint32_t hi, uint32_t lo) {
return (static_cast<uint64_t>(hi) << 32) | lo;
};
*system_time = merge_counter(reply->ust_hi, reply->ust_lo);
*media_stream_counter = merge_counter(reply->msc_hi, reply->msc_lo);
*swap_buffer_counter = merge_counter(reply->sbc_hi, reply->sbc_lo);
return true;
}
// Next try the present extension.
auto& present = connection->present();
// Check if the present extension is available.
if (!present.present())
return false;
// Issue a NotifyMSC request and listen for the resulting event which will
// contain the counter values.
auto context = connection->GenerateId<x11::Present::Event>();
present.SelectInput(
{context, window_, x11::Present::EventMask::CompleteNotify});
connection->present().NotifyMSC({window_});
present.SelectInput({context, window_, x11::Present::EventMask::NoEvent});
connection->Sync();
connection->ReadResponses();
for (const auto& event : connection->events()) {
auto* complete = event.As<x11::Present::CompleteNotifyEvent>();
if (complete && complete->kind == x11::Present::CompleteKind::NotifyMSC &&
complete->window == window_ && complete->serial == 0) {
*system_time = complete->ust;
*media_stream_counter = complete->msc;
*swap_buffer_counter = 0;
return true;
}
}
return false;
return glXGetSyncValuesOML(x11::Connection::Get()->GetXlibDisplay(),
glx_window_, system_time, media_stream_counter,
swap_buffer_counter);
}
bool GetMscRate(int32_t* numerator, int32_t* denominator) override {
if (!g_glx_get_msc_rate_oml_supported)
return false;
auto* connection = x11::Connection::Get();
connection->xf86vidmode().SetClientVersion(
{x11::XF86VidMode::major_version, x11::XF86VidMode::minor_version});
auto reply = connection->xf86vidmode()
.GetModeLine({connection->DefaultScreenId()})
.Sync();
if (!reply) {
// Once GetModeLine has been found to fail, don't try again,
if (!glXGetMscRateOML(x11::Connection::Get()->GetXlibDisplay(), glx_window_,
numerator, denominator)) {
// Once glXGetMscRateOML has been found to fail, don't try again,
// since each failing call may spew an error message.
g_glx_get_msc_rate_oml_supported = false;
return false;
}
*numerator = static_cast<uint32_t>(reply->dotclock) * 1000;
*denominator = static_cast<uint32_t>(reply->vtotal) * reply->htotal;
// These adjustments are from mesa's __glxGetMscRate().
if (static_cast<bool>(reply->flags &
x11::XF86VidMode::ModeFlag::Interlace)) {
*numerator *= 2;
}
if (static_cast<bool>(reply->flags &
x11::XF86VidMode::ModeFlag::Composite_Sync)) {
*denominator *= 2;
}
return true;
}
bool IsHWClock() const override { return true; }
private:
x11::Window window_;
GLXWindow glx_window_;
DISALLOW_COPY_AND_ASSIGN(OMLSyncControlVSyncProvider);
};
......@@ -718,7 +657,7 @@ bool NativeViewGLSurfaceGLX::Initialize(GLSurfaceFormat format) {
if (g_glx_oml_sync_control_supported) {
vsync_provider_ = std::make_unique<OMLSyncControlVSyncProvider>(
static_cast<x11::Window>(window_));
static_cast<GLXWindow>(glx_window_));
presentation_helper_ =
std::make_unique<GLSurfacePresentationHelper>(vsync_provider_.get());
} else if (g_glx_sgi_video_sync_supported) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment