Commit 8b5345a7 authored by cpu@chromium.org's avatar cpu@chromium.org

Remove using the Shell desktop Window when we don't have an acceleated widget.

For Windows Ash (metro mode) we did not had timely access to the
real window (aka 'core window') so to keep the compositor from CHECKIing
we gave the shell desktop Window when it wanted a window here

RootWindow::RootWindow(const CreateParams& params) {
  ...
  compositor_.reset(new ui::Compositor(this, host_->GetAcceleratedWidget())); 
 ...
}

This was called from:
ash::DisplayController::AddRootWindowForDisplay
ash::DisplayController::InitPrimaryDisplay
ash::Shell::Init

Because ash was always created. Later on when the viewer process had started
it sends an IPC back with the core window which set the real window with 

void ChromeMetroViewerProcessHost::OnSetTargetSurface(..) {
  scoped_refptr<AcceleratedPresenter> any_window =
      AcceleratedPresenter::GetForWindow(NULL);
  any_window->SetNewTargetWindow(hwnd);
  ....
}

All this hackery can go away because now Ash starts on demand
once the aforementioned IPC arrives.

BUG=none
TEST=chromes starts in metro mode.

Review URL: https://chromiumcodereview.appspot.com/22876030

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@220694 0039d316-1c4b-4281-b951-d872f2087c98
parent 86691a6f
...@@ -30,13 +30,9 @@ void TestMetroViewerProcessHost::OnSetTargetSurface( ...@@ -30,13 +30,9 @@ void TestMetroViewerProcessHost::OnSetTargetSurface(
gfx::NativeViewId target_surface) { gfx::NativeViewId target_surface) {
DLOG(INFO) << __FUNCTION__ << ", target_surface = " << target_surface; DLOG(INFO) << __FUNCTION__ << ", target_surface = " << target_surface;
HWND hwnd = reinterpret_cast<HWND>(target_surface); HWND hwnd = reinterpret_cast<HWND>(target_surface);
aura::RemoteRootWindowHostWin::Instance()->Connected(this, hwnd);
backing_surface_.reset(new AcceleratedSurface(hwnd)); backing_surface_.reset(new AcceleratedSurface(hwnd));
scoped_refptr<AcceleratedPresenter> any_window =
AcceleratedPresenter::GetForWindow(NULL);
any_window->SetNewTargetWindow(hwnd);
aura::RemoteRootWindowHostWin::Instance()->Connected(this);
} }
void TestMetroViewerProcessHost::OnOpenURL(const string16& url) { void TestMetroViewerProcessHost::OnOpenURL(const string16& url) {
......
...@@ -97,13 +97,11 @@ void ChromeMetroViewerProcessHost::OnChannelConnected(int32 /*peer_pid*/) { ...@@ -97,13 +97,11 @@ void ChromeMetroViewerProcessHost::OnChannelConnected(int32 /*peer_pid*/) {
void ChromeMetroViewerProcessHost::OnSetTargetSurface( void ChromeMetroViewerProcessHost::OnSetTargetSurface(
gfx::NativeViewId target_surface) { gfx::NativeViewId target_surface) {
DLOG(INFO) << __FUNCTION__ << ", target_surface = " << target_surface;
HWND hwnd = reinterpret_cast<HWND>(target_surface); HWND hwnd = reinterpret_cast<HWND>(target_surface);
// Tell our root window host that the viewer has connected.
aura::RemoteRootWindowHostWin::Instance()->Connected(this, hwnd);
// Now start the Ash shell environment.
chrome::OpenAsh(); chrome::OpenAsh();
scoped_refptr<AcceleratedPresenter> any_window =
AcceleratedPresenter::GetForWindow(NULL);
any_window->SetNewTargetWindow(hwnd);
aura::RemoteRootWindowHostWin::Instance()->Connected(this);
ash::Shell::GetInstance()->CreateLauncher(); ash::Shell::GetInstance()->CreateLauncher();
ash::Shell::GetInstance()->ShowLauncher(); ash::Shell::GetInstance()->ShowLauncher();
// Tell the rest of Chrome that Ash is running. // Tell the rest of Chrome that Ash is running.
......
...@@ -108,33 +108,39 @@ void HandleSelectFolder(const base::string16& title, ...@@ -108,33 +108,39 @@ void HandleSelectFolder(const base::string16& title,
RemoteRootWindowHostWin* g_instance = NULL; RemoteRootWindowHostWin* g_instance = NULL;
RemoteRootWindowHostWin* RemoteRootWindowHostWin::Instance() { RemoteRootWindowHostWin* RemoteRootWindowHostWin::Instance() {
return g_instance; if (g_instance)
return g_instance;
return Create(gfx::Rect());
} }
RemoteRootWindowHostWin* RemoteRootWindowHostWin::Create( RemoteRootWindowHostWin* RemoteRootWindowHostWin::Create(
const gfx::Rect& bounds) { const gfx::Rect& bounds) {
g_instance = new RemoteRootWindowHostWin(bounds); g_instance = g_instance ? g_instance : new RemoteRootWindowHostWin(bounds);
return g_instance; return g_instance;
} }
RemoteRootWindowHostWin::RemoteRootWindowHostWin(const gfx::Rect& bounds) RemoteRootWindowHostWin::RemoteRootWindowHostWin(const gfx::Rect& bounds)
: delegate_(NULL), : remote_window_(NULL),
delegate_(NULL),
host_(NULL), host_(NULL),
ignore_mouse_moves_until_set_cursor_ack_(false) { ignore_mouse_moves_until_set_cursor_ack_(false) {
prop_.reset(new ui::ViewProp(NULL, kRootWindowHostWinKey, this)); prop_.reset(new ui::ViewProp(NULL, kRootWindowHostWinKey, this));
} }
RemoteRootWindowHostWin::~RemoteRootWindowHostWin() { RemoteRootWindowHostWin::~RemoteRootWindowHostWin() {
g_instance = NULL;
} }
void RemoteRootWindowHostWin::Connected(IPC::Sender* host) { void RemoteRootWindowHostWin::Connected(IPC::Sender* host, HWND remote_window) {
CHECK(host_ == NULL); CHECK(host_ == NULL);
host_ = host; host_ = host;
remote_window_ = remote_window;
} }
void RemoteRootWindowHostWin::Disconnected() { void RemoteRootWindowHostWin::Disconnected() {
CHECK(host_ != NULL); CHECK(host_ != NULL);
host_ = NULL; host_ = NULL;
remote_window_ = NULL;
} }
bool RemoteRootWindowHostWin::OnMessageReceived(const IPC::Message& message) { bool RemoteRootWindowHostWin::OnMessageReceived(const IPC::Message& message) {
...@@ -271,10 +277,9 @@ RootWindow* RemoteRootWindowHostWin::GetRootWindow() { ...@@ -271,10 +277,9 @@ RootWindow* RemoteRootWindowHostWin::GetRootWindow() {
} }
gfx::AcceleratedWidget RemoteRootWindowHostWin::GetAcceleratedWidget() { gfx::AcceleratedWidget RemoteRootWindowHostWin::GetAcceleratedWidget() {
// TODO(cpu): This is bad. Chrome's compositor needs a valid window if (remote_window_)
// initially and then later on we swap it. Since the compositor never return remote_window_;
// uses this initial window we tell ourselves this hack is ok to get // Getting here should only happen for ash_unittests.exe and related code.
// thing off the ground.
return ::GetDesktopWindow(); return ::GetDesktopWindow();
} }
......
...@@ -86,12 +86,15 @@ AURA_EXPORT void HandleSelectFolder(const base::string16& title, ...@@ -86,12 +86,15 @@ AURA_EXPORT void HandleSelectFolder(const base::string16& title,
// frontend process, which forwards input events to this class. // frontend process, which forwards input events to this class.
class AURA_EXPORT RemoteRootWindowHostWin : public RootWindowHost { class AURA_EXPORT RemoteRootWindowHostWin : public RootWindowHost {
public: public:
// Returns the only RemoteRootWindowHostWin, if this is the first time
// this function is called, it will call Create() wiht empty bounds.
static RemoteRootWindowHostWin* Instance(); static RemoteRootWindowHostWin* Instance();
static RemoteRootWindowHostWin* Create(const gfx::Rect& bounds); static RemoteRootWindowHostWin* Create(const gfx::Rect& bounds);
// Called when the remote process has established its IPC connection. // Called when the remote process has established its IPC connection.
// The |host| can be used when we need to send a message to it. // The |host| can be used when we need to send a message to it and
void Connected(IPC::Sender* host); // |remote_window| is the actual window owned by the viewer process.
void Connected(IPC::Sender* host, HWND remote_window);
// Called when the remote process has closed its IPC connection. // Called when the remote process has closed its IPC connection.
void Disconnected(); void Disconnected();
...@@ -200,6 +203,7 @@ class AURA_EXPORT RemoteRootWindowHostWin : public RootWindowHost { ...@@ -200,6 +203,7 @@ class AURA_EXPORT RemoteRootWindowHostWin : public RootWindowHost {
uint32 flags, uint32 flags,
bool is_character); bool is_character);
HWND remote_window_;
RootWindowHostDelegate* delegate_; RootWindowHostDelegate* delegate_;
IPC::Sender* host_; IPC::Sender* host_;
scoped_ptr<ui::ViewProp> prop_; scoped_ptr<ui::ViewProp> prop_;
......
...@@ -332,12 +332,6 @@ void AcceleratedPresenterMap::RemovePresenter( ...@@ -332,12 +332,6 @@ void AcceleratedPresenterMap::RemovePresenter(
scoped_refptr<AcceleratedPresenter> AcceleratedPresenterMap::GetPresenter( scoped_refptr<AcceleratedPresenter> AcceleratedPresenterMap::GetPresenter(
gfx::PluginWindowHandle window) { gfx::PluginWindowHandle window) {
base::AutoLock locked(lock_); base::AutoLock locked(lock_);
#if defined(USE_AURA)
if (!window)
return presenters_.begin()->second;
#endif
PresenterMap::iterator it = presenters_.find(window); PresenterMap::iterator it = presenters_.find(window);
if (it == presenters_.end()) if (it == presenters_.end())
return scoped_refptr<AcceleratedPresenter>(); return scoped_refptr<AcceleratedPresenter>();
...@@ -672,13 +666,6 @@ void AcceleratedPresenter::ResetPresentThread( ...@@ -672,13 +666,6 @@ void AcceleratedPresenter::ResetPresentThread(
quantized_size_ = gfx::Size(); quantized_size_ = gfx::Size();
} }
#if defined(USE_AURA)
void AcceleratedPresenter::SetNewTargetWindow(gfx::PluginWindowHandle window) {
window_ = window;
swap_chain_ = NULL;
}
#endif
AcceleratedPresenter::~AcceleratedPresenter() { AcceleratedPresenter::~AcceleratedPresenter() {
} }
......
...@@ -89,12 +89,6 @@ class SURFACE_EXPORT AcceleratedPresenter ...@@ -89,12 +89,6 @@ class SURFACE_EXPORT AcceleratedPresenter
// the given present thread. // the given present thread.
void ResetPresentThread(PresentThread* present_thread); void ResetPresentThread(PresentThread* present_thread);
#if defined(USE_AURA)
// TODO(scottmg): This is a temporary hack until we have a two-worlds ash/aura
// separation.
void SetNewTargetWindow(gfx::PluginWindowHandle window);
#endif
private: private:
friend class base::RefCountedThreadSafe<AcceleratedPresenter>; friend class base::RefCountedThreadSafe<AcceleratedPresenter>;
......
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