summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-19 22:13:38 +0000
committerderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-19 22:13:38 +0000
commit6aa614a9ac971f5b027eee0749f211883f1d6934 (patch)
treeab48ab3a1a3e6a9ebebc19f7579f55dd273ebae8 /ui
parent1d6ed7bc2007d2521d14f8bdaf1962ba499d0b81 (diff)
downloadchromium_src-6aa614a9ac971f5b027eee0749f211883f1d6934.zip
chromium_src-6aa614a9ac971f5b027eee0749f211883f1d6934.tar.gz
chromium_src-6aa614a9ac971f5b027eee0749f211883f1d6934.tar.bz2
Reland "aura/chromeos: Avoid suspending while video is playing."
This reverts r118199, which was a revert of r118171. aura::VideoPropertyWriter (not ash::VideoDetector -- made a typo in the revert's description) was outliving the ash::Shell singleton. Now we explicitly destroy the VideoPropertyWriter before the shell. The only differences from r118171 are the addition of the final chunk in chrome_browser_main_chromeos.cc and a change to reparent a window in VideoDetectorTest.WindowNotVisible needed in response to r118259. BUG=110114 TEST=avoided missing DCHECK on shutdown in trybot logs this time Review URL: http://codereview.chromium.org/9254018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118375 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/aura/window.cc12
-rw-r--r--ui/aura/window.h4
-rw-r--r--ui/aura/window_observer.h4
-rw-r--r--ui/base/x/x11_util.cc36
-rw-r--r--ui/base/x/x11_util.h9
-rw-r--r--ui/gfx/compositor/layer.h4
6 files changed, 67 insertions, 2 deletions
diff --git a/ui/aura/window.cc b/ui/aura/window.cc
index f9a11ca..75bb1e9 100644
--- a/ui/aura/window.cc
+++ b/ui/aura/window.cc
@@ -164,6 +164,8 @@ const gfx::Rect& Window::bounds() const {
void Window::SchedulePaintInRect(const gfx::Rect& rect) {
layer_->SchedulePaint(rect);
+ FOR_EACH_OBSERVER(
+ WindowObserver, observers_, OnWindowPaintScheduled(this, rect));
}
void Window::SetCanvas(const SkCanvas& canvas, const gfx::Point& origin) {
@@ -172,6 +174,16 @@ void Window::SetCanvas(const SkCanvas& canvas, const gfx::Point& origin) {
// to be unhappy if we try to set a texture on a size bigger than the size of
// the texture.
layer_->SetCanvas(canvas, origin);
+ gfx::Rect region(gfx::Point(), bounds().size());
+ FOR_EACH_OBSERVER(
+ WindowObserver, observers_, OnWindowPaintScheduled(this, region));
+}
+
+void Window::SetExternalTexture(ui::Texture* texture) {
+ layer_->SetExternalTexture(texture);
+ gfx::Rect region(gfx::Point(), bounds().size());
+ FOR_EACH_OBSERVER(
+ WindowObserver, observers_, OnWindowPaintScheduled(this, region));
}
void Window::SetParent(Window* parent) {
diff --git a/ui/aura/window.h b/ui/aura/window.h
index 698c90e..9fc775e 100644
--- a/ui/aura/window.h
+++ b/ui/aura/window.h
@@ -27,6 +27,7 @@ class SkCanvas;
namespace ui {
class Layer;
+class Texture;
class Transform;
}
@@ -126,6 +127,9 @@ class AURA_EXPORT Window : public ui::LayerDelegate {
// Sets the contents of the window.
void SetCanvas(const SkCanvas& canvas, const gfx::Point& origin);
+ // Assigns a new external texture to the window's layer.
+ void SetExternalTexture(ui::Texture* texture);
+
// Sets the parent window of the window. If NULL, the window is parented to
// the root window.
void SetParent(Window* parent);
diff --git a/ui/aura/window_observer.h b/ui/aura/window_observer.h
index bd5138f..6055ef4 100644
--- a/ui/aura/window_observer.h
+++ b/ui/aura/window_observer.h
@@ -46,6 +46,10 @@ class AURA_EXPORT WindowObserver {
// has changed.
virtual void OnWindowStackingChanged(Window* window) {}
+ // Invoked when a region of |window| is scheduled to be redrawn.
+ virtual void OnWindowPaintScheduled(Window* window,
+ const gfx::Rect& region) {}
+
// Invoked when the Window is being destroyed (i.e. from the start of its
// destructor).
virtual void OnWindowDestroying(Window* window) {}
diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc
index 9605fde..302ffd6 100644
--- a/ui/base/x/x11_util.cc
+++ b/ui/base/x/x11_util.cc
@@ -18,6 +18,7 @@
#include "base/bind.h"
#include "base/command_line.h"
#include "base/logging.h"
+#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
#include "base/message_loop.h"
#include "base/string_number_conversions.h"
@@ -514,11 +515,46 @@ bool GetStringProperty(
return true;
}
+bool SetIntProperty(XID window,
+ const std::string& name,
+ const std::string& type,
+ int value) {
+ std::vector<int> values(1, value);
+ return SetIntArrayProperty(window, name, type, values);
+}
+
+bool SetIntArrayProperty(XID window,
+ const std::string& name,
+ const std::string& type,
+ const std::vector<int>& value) {
+ DCHECK(!value.empty());
+ Atom name_atom = GetAtom(name.c_str());
+ Atom type_atom = GetAtom(type.c_str());
+
+ // XChangeProperty() expects values of type 32 to be longs.
+ scoped_array<long> data(new long[value.size()]);
+ for (size_t i = 0; i < value.size(); ++i)
+ data[i] = value[i];
+
+ gdk_error_trap_push();
+ XChangeProperty(ui::GetXDisplay(),
+ window,
+ name_atom,
+ type_atom,
+ 32, // size in bits of items in 'value'
+ PropModeReplace,
+ reinterpret_cast<const unsigned char*>(data.get()),
+ value.size()); // num items
+ XSync(ui::GetXDisplay(), False);
+ return gdk_error_trap_pop() == 0;
+}
+
Atom GetAtom(const char* name) {
#if defined(TOOLKIT_USES_GTK)
return gdk_x11_get_xatom_by_name_for_display(
gdk_display_get_default(), name);
#else
+ // TODO(derat): Cache atoms to avoid round-trips to the server.
return XInternAtom(GetXDisplay(), name, false);
#endif
}
diff --git a/ui/base/x/x11_util.h b/ui/base/x/x11_util.h
index 757b149..411c941 100644
--- a/ui/base/x/x11_util.h
+++ b/ui/base/x/x11_util.h
@@ -124,6 +124,15 @@ UI_EXPORT bool GetAtomArrayProperty(XID window,
UI_EXPORT bool GetStringProperty(
XID window, const std::string& property_name, std::string* value);
+UI_EXPORT bool SetIntProperty(XID window,
+ const std::string& name,
+ const std::string& type,
+ int value);
+UI_EXPORT bool SetIntArrayProperty(XID window,
+ const std::string& name,
+ const std::string& type,
+ const std::vector<int>& value);
+
// Gets the X atom for default display corresponding to atom_name.
Atom GetAtom(const char* atom_name);
diff --git a/ui/gfx/compositor/layer.h b/ui/gfx/compositor/layer.h
index 72f1beb..51dd4ca 100644
--- a/ui/gfx/compositor/layer.h
+++ b/ui/gfx/compositor/layer.h
@@ -163,8 +163,8 @@ class COMPOSITOR_EXPORT Layer :
const ui::Texture* texture() const { return texture_.get(); }
- // |texture| cannot be NULL, and this function cannot be called more than
- // once.
+ // Assigns a new external texture. |texture| can be NULL to disable external
+ // updates.
// TODO(beng): This can be removed from the API when we are in a
// single-compositor world.
void SetExternalTexture(ui::Texture* texture);