Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Unified Diff: ui/ozone/platform/dri/dri_wrapper.cc

Issue 960273003: ozone: dri: add synchronous SwapBuffers support on surfaceless (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/ozone/platform/dri/dri_wrapper.cc
diff --git a/ui/ozone/platform/dri/dri_wrapper.cc b/ui/ozone/platform/dri/dri_wrapper.cc
index a2b333f16e762f6d5ce2d67e762e7f9fb730ff80..e8fcd5cb42edb4fa878b298eb1450e1659330d1d 100644
--- a/ui/ozone/platform/dri/dri_wrapper.cc
+++ b/ui/ozone/platform/dri/dri_wrapper.cc
@@ -13,6 +13,7 @@
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "base/stl_util.h"
+#include "base/synchronization/waitable_event.h"
#include "base/task_runner.h"
#include "base/thread_task_runner_handle.h"
#include "base/trace_event/trace_event.h"
@@ -104,9 +105,20 @@ class DriWrapper::IOWatcher
public:
IOWatcher(int fd,
const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner)
- : io_task_runner_(io_task_runner) {
+ : io_task_runner_(io_task_runner), paused_(false), fd_(fd) {
io_task_runner_->PostTask(FROM_HERE,
dnicoara 2015/02/26 18:22:21 I think we should remove this since the call to Se
llandwerlin-old 2015/02/26 22:02:56 Done.
- base::Bind(&IOWatcher::RegisterOnIO, this, fd));
+ base::Bind(&IOWatcher::RegisterOnIO, this));
+ }
+
+ void SetPaused(bool value) {
dnicoara 2015/02/26 18:22:21 Just rename |value| to |paused| and remove the par
llandwerlin-old 2015/02/26 22:02:56 Done.
+ bool paused = !!value;
+ if (paused_ == paused)
+ return;
+
+ base::WaitableEvent done(false, false);
+ io_task_runner_->PostTask(
+ FROM_HERE, base::Bind(&IOWatcher::SetPausedOnIO, this, paused, &done));
+ paused_ = paused;
}
void Shutdown() {
dnicoara 2015/02/26 18:22:21 We should check if |paused_| is false and return i
llandwerlin-old 2015/02/26 22:02:56 Done.
@@ -117,12 +129,14 @@ class DriWrapper::IOWatcher
private:
friend class base::RefCountedThreadSafe<IOWatcher>;
- ~IOWatcher() override {}
+ ~IOWatcher() override {
+ SetPaused(true);
+ }
- void RegisterOnIO(int fd) {
+ void RegisterOnIO() {
DCHECK(base::MessageLoopForIO::IsCurrent());
base::MessageLoopForIO::current()->WatchFileDescriptor(
- fd, true, base::MessageLoopForIO::WATCH_READ, &controller_, this);
+ fd_, true, base::MessageLoopForIO::WATCH_READ, &controller_, this);
}
void UnregisterOnIO() {
@@ -130,6 +144,15 @@ class DriWrapper::IOWatcher
controller_.StopWatchingFileDescriptor();
}
+ void SetPausedOnIO(bool paused, base::WaitableEvent* done) {
+ DCHECK(base::MessageLoopForIO::IsCurrent());
+ if (paused)
+ UnregisterOnIO();
+ else
+ RegisterOnIO();
+ done->Signal();
+ }
+
// base::MessagePumpLibevent::Watcher overrides:
void OnFileCanReadWithoutBlocking(int fd) override {
DCHECK(base::MessageLoopForIO::IsCurrent());
@@ -149,6 +172,9 @@ class DriWrapper::IOWatcher
base::MessagePumpLibevent::FileDescriptorWatcher controller_;
+ bool paused_;
+ int fd_;
+
DISALLOW_COPY_AND_ASSIGN(IOWatcher);
};
@@ -270,12 +296,15 @@ bool DriWrapper::RemoveFramebuffer(uint32_t framebuffer) {
bool DriWrapper::PageFlip(uint32_t crtc_id,
uint32_t framebuffer,
+ bool is_sync,
const PageFlipCallback& callback) {
DCHECK(file_.IsValid());
TRACE_EVENT2("dri", "DriWrapper::PageFlip",
"crtc", crtc_id,
"framebuffer", framebuffer);
+ watcher_->SetPaused(is_sync);
dnicoara 2015/02/26 18:22:21 |watcher_| may not be initialized. you'll want to
llandwerlin-old 2015/02/26 22:02:56 Adding the check on watcher_, but on line 319 I st
+
// NOTE: Calling drmModeSetCrtc will immediately update the state, though
// callbacks to already scheduled page flips will be honored by the kernel.
scoped_ptr<PageFlipPayload> payload(
@@ -285,9 +314,9 @@ bool DriWrapper::PageFlip(uint32_t crtc_id,
// If successful the payload will be removed by a PageFlip event.
ignore_result(payload.release());
- // If a task runner isn't installed then fall back to synchronously handling
- // the page flip events.
- if (!task_runner_) {
+ // If the flip was requested synchronous or if a task runner isn't
+ // installed then synchronously handle the page flip events.
+ if (is_sync || !task_runner_) {
TRACE_EVENT1("dri", "OnDrmEvent", "socket", file_.GetPlatformFile());
drmEventContext event;

Powered by Google App Engine
This is Rietveld 408576698