diff options
author | backer@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-06 17:27:55 +0000 |
---|---|---|
committer | backer@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-06 17:27:55 +0000 |
commit | d9884f501247498d6687ea762afbbab13e4045c9 (patch) | |
tree | e5d160659742028bc1ee7c30fd3117bfbc2bf4ef /views/widget | |
parent | 964bd398fa49519c9afa19c66d4de56d842e884d (diff) | |
download | chromium_src-d9884f501247498d6687ea762afbbab13e4045c9.zip chromium_src-d9884f501247498d6687ea762afbbab13e4045c9.tar.gz chromium_src-d9884f501247498d6687ea762afbbab13e4045c9.tar.bz2 |
Push (not pull) window geometry for the compositor.
The previous implementation used to poll the environment for the window size every drawing cycle. On Linux this is an expensive operation because it requires a round trip to the X server. This CL pushes window size change to the compositor.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/7212028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91572 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/widget')
-rw-r--r-- | views/widget/native_widget_gtk.cc | 14 | ||||
-rw-r--r-- | views/widget/native_widget_win.cc | 13 |
2 files changed, 22 insertions, 5 deletions
diff --git a/views/widget/native_widget_gtk.cc b/views/widget/native_widget_gtk.cc index 777755d..fabacc5 100644 --- a/views/widget/native_widget_gtk.cc +++ b/views/widget/native_widget_gtk.cc @@ -686,9 +686,15 @@ void NativeWidgetGtk::InitNativeWidget(const Widget::InitParams& params) { CreateGtkWidget(modified_params); if (View::get_use_acceleration_when_possible()) { - compositor_ = Widget::compositor_factory() ? - (*Widget::compositor_factory())() : - ui::Compositor::Create(GDK_WINDOW_XID(window_contents_->window)); + if (Widget::compositor_factory()) { + compositor_ = (*Widget::compositor_factory())(); + } else { + gint width, height; + gdk_drawable_get_size(window_contents_->window, &width, &height); + compositor_ = ui::Compositor::Create( + GDK_WINDOW_XID(window_contents_->window), + gfx::Size(width, height)); + } if (compositor_.get()) delegate_->AsWidget()->GetRootView()->SetPaintToLayer(true); } @@ -1290,6 +1296,8 @@ void NativeWidgetGtk::OnSizeAllocate(GtkWidget* widget, if (new_size == size_) return; size_ = new_size; + if (compositor_.get()) + compositor_->OnWidgetSizeChanged(size_); delegate_->OnNativeWidgetSizeChanged(size_); if (GetWidget()->non_client_view()) { diff --git a/views/widget/native_widget_win.cc b/views/widget/native_widget_win.cc index 8802ceca..a694ad4 100644 --- a/views/widget/native_widget_win.cc +++ b/views/widget/native_widget_win.cc @@ -1233,8 +1233,15 @@ LRESULT NativeWidgetWin::OnCreate(CREATESTRUCT* create_struct) { #if defined(VIEWS_COMPOSITOR) if (View::get_use_acceleration_when_possible()) { - compositor_ = Widget::compositor_factory() ? - (*Widget::compositor_factory())() : ui::Compositor::Create(hwnd()); + if (Widget::compositor_factory()) { + compositor_ = (*Widget::compositor_factory())(); + } else { + CRect window_rect; + GetClientRect(&window_rect); + compositor_ = ui::Compositor::Create( + hwnd(), + gfx::Size(window_rect.Width(), window_rect.Height())); + } if (compositor_.get()) delegate_->AsWidget()->GetRootView()->SetPaintToLayer(true); } @@ -2293,6 +2300,8 @@ void NativeWidgetWin::ClientAreaSizeChanged() { GetWindowRect(&r); gfx::Size s(std::max(0, static_cast<int>(r.right - r.left)), std::max(0, static_cast<int>(r.bottom - r.top))); + if (compositor_.get()) + compositor_->OnWidgetSizeChanged(s); delegate_->OnNativeWidgetSizeChanged(s); if (use_layered_buffer_) { layered_window_contents_.reset( |