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

Unified Diff: content/common/gpu/media/rendering_helper.cc

Issue 835653005: gpu: media: RenderingHelper: wait for the display & window to be ready (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update after Owen's and Pawel's comments Created 5 years, 11 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
« no previous file with comments | « content/common/gpu/media/DEPS ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/gpu/media/rendering_helper.cc
diff --git a/content/common/gpu/media/rendering_helper.cc b/content/common/gpu/media/rendering_helper.cc
index 950ae6e71dd07e3eb0a41739e695cab20a9e4825..dd155fee76e2fa3a04663904047715dfe307f6a2 100644
--- a/content/common/gpu/media/rendering_helper.cc
+++ b/content/common/gpu/media/rendering_helper.cc
@@ -13,6 +13,7 @@
#include "base/command_line.h"
#include "base/mac/scoped_nsautorelease_pool.h"
#include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
#include "base/strings/stringize_macros.h"
#include "base/synchronization/waitable_event.h"
#include "base/time/time.h"
@@ -39,6 +40,7 @@
#if defined(USE_OZONE)
#if defined(OS_CHROMEOS)
#include "ui/display/chromeos/display_configurator.h"
+#include "ui/display/types/display_constants.h"
#endif // defined(OS_CHROMEOS)
#include "ui/ozone/public/ozone_platform.h"
#include "ui/ozone/public/ui_thread_gpu.h"
@@ -70,16 +72,46 @@ namespace content {
#if defined(USE_OZONE)
+class DisplayConfiguratorObserver : public ui::DisplayConfigurator::Observer {
+ public:
+ DisplayConfiguratorObserver(base::RunLoop* loop) : loop_(loop) {}
+ ~DisplayConfiguratorObserver() override {}
+
+ private:
+ // ui::DisplayConfigurator::Observer overrides:
+ void OnDisplayModeChanged(
+ const ui::DisplayConfigurator::DisplayStateList& outputs) override {
+ if (!loop_)
+ return;
+ loop_->Quit();
+ loop_ = nullptr;
+ }
+ void OnDisplayModeChangeFailed(
+ ui::MultipleDisplayState failed_new_state) override {
+ LOG(FATAL) << "Could not setup display";
+ }
+
+ base::RunLoop* loop_;
+
+ DISALLOW_COPY_AND_ASSIGN(DisplayConfiguratorObserver);
+};
+
class RenderingHelper::StubOzoneDelegate : public ui::PlatformWindowDelegate {
public:
- StubOzoneDelegate() : accelerated_widget_(gfx::kNullAcceleratedWidget) {
+ StubOzoneDelegate(base::RunLoop* loop)
+ : accelerated_widget_(gfx::kNullAcceleratedWidget), loop_(loop) {
ui_thread_gpu_.Initialize();
platform_window_ = ui::OzonePlatform::GetInstance()->CreatePlatformWindow(
this, gfx::Rect());
}
virtual ~StubOzoneDelegate() {}
- void OnBoundsChanged(const gfx::Rect& new_bounds) override {}
+ void OnBoundsChanged(const gfx::Rect& new_bounds) override {
+ if (!loop_)
+ return;
+ loop_->Quit();
+ loop_ = nullptr;
+ }
void OnDamageRect(const gfx::Rect& damaged_region) override {}
@@ -110,6 +142,7 @@ class RenderingHelper::StubOzoneDelegate : public ui::PlatformWindowDelegate {
ui::UiThreadGpu ui_thread_gpu_;
scoped_ptr<ui::PlatformWindow> platform_window_;
gfx::AcceleratedWidget accelerated_widget_;
+ base::RunLoop* loop_;
DISALLOW_COPY_AND_ASSIGN(StubOzoneDelegate);
};
@@ -229,17 +262,34 @@ void RenderingHelper::Initialize(const RenderingHelperParams& params,
XSelectInput(display, window_, ExposureMask);
XMapWindow(display, window_);
#elif defined(USE_OZONE)
- platform_window_delegate_.reset(new RenderingHelper::StubOzoneDelegate());
+ base::RunLoop wait_resize_loop;
+
+ platform_window_delegate_.reset(
+ new RenderingHelper::StubOzoneDelegate(&wait_resize_loop));
window_ = platform_window_delegate_->accelerated_widget();
#if defined(OS_CHROMEOS)
- display_configurator_.reset(new ui::DisplayConfigurator());
+ // We hold onto the main loop here to wait for the DisplayController
+ // to give us the size of the display so we can create a window of
+ // the same size.
+ base::MessageLoop::ScopedNestableTaskAllower nest_loop(
+ base::MessageLoop::current());
+ base::RunLoop wait_mode_change_loop;
+ DisplayConfiguratorObserver display_observer(&wait_mode_change_loop);
+ display_configurator_.reset(new ui::DisplayConfigurator);
+ display_configurator_->AddObserver(&display_observer);
dnicoara 2015/01/21 16:23:57 You can remove all the nested message loops and th
llandwerlin-old 2015/01/21 18:45:51 Done.
display_configurator_->Init(true);
+ display_configurator_->SetDisplayMode(ui::MULTIPLE_DISPLAY_STATE_SINGLE);
Owen Lin 2015/01/23 08:57:38 Why this line is removed ?
dnicoara 2015/01/23 15:10:13 You don't need to set the display mode since Force
display_configurator_->ForceInitialConfigure(0);
+ // Wait for the display to probe the screen's size.
+ wait_mode_change_loop.Run();
+ display_configurator_->RemoveObserver(&display_observer);
platform_window_delegate_->platform_window()->SetBounds(
gfx::Rect(display_configurator_->framebuffer_size()));
#else
platform_window_delegate_->platform_window()->SetBounds(gfx::Rect(800, 600));
#endif
+ // Wait for the window to be resized.
+ wait_resize_loop.Run();
dnicoara 2015/01/21 16:23:57 This also needs to be replaced by a "base::RunLoop
llandwerlin-old 2015/01/21 18:45:51 Done.
#else
#error unknown platform
#endif
« no previous file with comments | « content/common/gpu/media/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698