diff options
-rw-r--r-- | ash/ash.gyp | 3 | ||||
-rw-r--r-- | ash/shell.cc | 2 | ||||
-rw-r--r-- | ash/shell.h | 5 | ||||
-rw-r--r-- | ash/wm/power_button_controller.h | 3 | ||||
-rw-r--r-- | ash/wm/video_detector.cc | 111 | ||||
-rw-r--r-- | ash/wm/video_detector.h | 100 | ||||
-rw-r--r-- | ash/wm/video_detector_unittest.cc | 196 | ||||
-rw-r--r-- | chrome/browser/chromeos/chrome_browser_main_chromeos.cc | 5 | ||||
-rw-r--r-- | chrome/browser/chromeos/chrome_browser_main_chromeos.h | 2 | ||||
-rw-r--r-- | chrome/browser/chromeos/power/video_property_writer.cc | 47 | ||||
-rw-r--r-- | chrome/browser/chromeos/power/video_property_writer.h | 35 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 4 | ||||
-rw-r--r-- | content/browser/renderer_host/render_widget_host_view_aura.cc | 4 | ||||
-rw-r--r-- | ui/aura/window.cc | 12 | ||||
-rw-r--r-- | ui/aura/window.h | 4 | ||||
-rw-r--r-- | ui/aura/window_observer.h | 6 | ||||
-rw-r--r-- | ui/base/x/x11_util.cc | 36 | ||||
-rw-r--r-- | ui/base/x/x11_util.h | 9 | ||||
-rw-r--r-- | ui/gfx/compositor/layer.h | 4 |
19 files changed, 7 insertions, 581 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp index 67460cf..4b95c66 100644 --- a/ash/ash.gyp +++ b/ash/ash.gyp @@ -151,8 +151,6 @@ 'wm/toplevel_layout_manager.h', 'wm/toplevel_window_event_filter.cc', 'wm/toplevel_window_event_filter.h', - 'wm/video_detector.cc', - 'wm/video_detector.h', 'wm/window_cycle_controller.cc', 'wm/window_cycle_controller.h', 'wm/window_cycle_list.cc', @@ -229,7 +227,6 @@ 'wm/shelf_layout_manager_unittest.cc', 'wm/toplevel_layout_manager_unittest.cc', 'wm/toplevel_window_event_filter_unittest.cc', - 'wm/video_detector_unittest.cc', 'wm/window_cycle_controller_unittest.cc', 'wm/window_modality_controller_unittest.cc', 'wm/workspace_controller_unittest.cc', diff --git a/ash/shell.cc b/ash/shell.cc index 40df7c9..3f50105 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -37,7 +37,6 @@ #include "ash/wm/window_modality_controller.h" #include "ash/wm/window_util.h" #include "ash/wm/workspace_controller.h" -#include "ash/wm/video_detector.h" #include "base/bind.h" #include "base/command_line.h" #include "ui/aura/client/aura_constants.h" @@ -267,7 +266,6 @@ void Shell::Init() { drag_drop_controller_.reset(new internal::DragDropController); power_button_controller_.reset(new PowerButtonController); - video_detector_.reset(new VideoDetector); window_cycle_controller_.reset(new WindowCycleController); } diff --git a/ash/shell.h b/ash/shell.h index 66ad2ce..e9251ed 100644 --- a/ash/shell.h +++ b/ash/shell.h @@ -38,7 +38,6 @@ class AcceleratorController; class Launcher; class PowerButtonController; class ShellDelegate; -class VideoDetector; class WindowCycleController; namespace internal { @@ -107,9 +106,6 @@ class ASH_EXPORT Shell { PowerButtonController* power_button_controller() { return power_button_controller_.get(); } - VideoDetector* video_detector() { - return video_detector_.get(); - } WindowCycleController* window_cycle_controller() { return window_cycle_controller_.get(); } @@ -177,7 +173,6 @@ class ASH_EXPORT Shell { scoped_ptr<internal::ShadowController> shadow_controller_; scoped_ptr<internal::TooltipController> tooltip_controller_; scoped_ptr<PowerButtonController> power_button_controller_; - scoped_ptr<VideoDetector> video_detector_; scoped_ptr<WindowCycleController> window_cycle_controller_; // An event filter that pre-handles all key events to send them to an IME. diff --git a/ash/wm/power_button_controller.h b/ash/wm/power_button_controller.h index 00a1507..3bac34e 100644 --- a/ash/wm/power_button_controller.h +++ b/ash/wm/power_button_controller.h @@ -64,8 +64,7 @@ class ASH_EXPORT PowerButtonController : public aura::RootWindowObserver { // Helper class used by tests to access internal state. class ASH_EXPORT TestApi { public: - explicit TestApi(PowerButtonController* controller) - : controller_(controller) {} + TestApi(PowerButtonController* controller) : controller_(controller) {} bool lock_timer_is_running() const { return controller_->lock_timer_.IsRunning(); diff --git a/ash/wm/video_detector.cc b/ash/wm/video_detector.cc deleted file mode 100644 index 8be1e4f..0000000 --- a/ash/wm/video_detector.cc +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ash/wm/video_detector.h" - -#include "ui/aura/root_window.h" -#include "ui/aura/window.h" -#include "ui/gfx/rect.h" - -namespace ash { - -const int VideoDetector::kMinUpdateWidth = 300; -const int VideoDetector::kMinUpdateHeight = 225; -const int VideoDetector::kMinFramesPerSecond = 15; -const double VideoDetector::kNotifyIntervalSec = 1.0; - -// Stores information about updates to a window and determines whether it's -// likely that a video is playing in it. -class VideoDetector::WindowInfo { - public: - WindowInfo() : num_video_updates_in_second_(0) {} - - // Handles an update within a window, returning true if this update made us - // believe that a video is playing in the window. true is returned at most - // once per second. - bool RecordUpdateAndCheckForVideo(const gfx::Rect& region, - base::TimeTicks now) { - if (region.width() < kMinUpdateWidth || region.height() < kMinUpdateHeight) - return false; - - if (second_start_time_.is_null() || - (now - second_start_time_).InSecondsF() >= 1.0) { - second_start_time_ = now; - num_video_updates_in_second_ = 0; - } - num_video_updates_in_second_++; - - return num_video_updates_in_second_ == kMinFramesPerSecond; - } - - private: - // Number of video-sized updates that we've seen in the second starting at - // |second_start_time_|. (Keeping a rolling window is overkill here.) - int num_video_updates_in_second_; - - base::TimeTicks second_start_time_; - - DISALLOW_COPY_AND_ASSIGN(WindowInfo); -}; - -VideoDetector::VideoDetector() { - aura::RootWindow::GetInstance()->AddRootWindowObserver(this); -} - -VideoDetector::~VideoDetector() { - aura::RootWindow::GetInstance()->RemoveRootWindowObserver(this); - for (WindowInfoMap::const_iterator it = window_infos_.begin(); - it != window_infos_.end(); ++it) { - aura::Window* window = it->first; - window->RemoveObserver(this); - } -} - -void VideoDetector::AddObserver(VideoDetectorObserver* observer) { - observers_.AddObserver(observer); -} - -void VideoDetector::RemoveObserver(VideoDetectorObserver* observer) { - observers_.RemoveObserver(observer); -} - -void VideoDetector::OnWindowInitialized(aura::Window* window) { - window->AddObserver(this); -} - -void VideoDetector::OnWindowPaintScheduled(aura::Window* window, - const gfx::Rect& region) { - linked_ptr<WindowInfo>& info = window_infos_[window]; - if (!info.get()) - info.reset(new WindowInfo); - - base::TimeTicks now = - !now_for_test_.is_null() ? now_for_test_ : base::TimeTicks::Now(); - if (info->RecordUpdateAndCheckForVideo(region, now)) - MaybeNotifyObservers(window, now); -} - -void VideoDetector::OnWindowDestroyed(aura::Window* window) { - window_infos_.erase(window); -} - -void VideoDetector::MaybeNotifyObservers(aura::Window* window, - base::TimeTicks now) { - if (!last_observer_notification_time_.is_null() && - (now - last_observer_notification_time_).InSecondsF() < - kNotifyIntervalSec) - return; - - if (!window->IsVisible()) - return; - - gfx::Rect root_bounds = aura::RootWindow::GetInstance()->bounds(); - if (!window->GetScreenBounds().Intersects(root_bounds)) - return; - - FOR_EACH_OBSERVER(VideoDetectorObserver, observers_, OnVideoDetected()); - last_observer_notification_time_ = now; -} - -} // namespace ash diff --git a/ash/wm/video_detector.h b/ash/wm/video_detector.h deleted file mode 100644 index d6778b6..0000000 --- a/ash/wm/video_detector.h +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef ASH_WM_VIDEO_DETECTOR_H_ -#define ASH_WM_VIDEO_DETECTOR_H_ -#pragma once - -#include <map> - -#include "ash/ash_export.h" -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "base/memory/linked_ptr.h" -#include "base/observer_list.h" -#include "base/time.h" -#include "ui/aura/root_window_observer.h" -#include "ui/aura/window_observer.h" - -namespace aura { -class Window; -} - -namespace gfx { -class Rect; -} - -namespace ash { - -class ASH_EXPORT VideoDetectorObserver { - public: - // Invoked periodically while a video is being played onscreen. - virtual void OnVideoDetected() = 0; - - protected: - virtual ~VideoDetectorObserver() {} -}; - -// Watches for updates to windows and tries to detect when a video is playing. -// We err on the side of false positives and can be fooled by things like -// continuous scrolling of a page. -class ASH_EXPORT VideoDetector : public aura::RootWindowObserver, - public aura::WindowObserver { - public: - // Minimum dimensions in pixels that a window update must have to be - // considered a potential video frame. - static const int kMinUpdateWidth; - static const int kMinUpdateHeight; - - // Number of video-sized updates that we must see within a second in a window - // before we assume that a video is playing. - static const int kMinFramesPerSecond; - - // Minimum amount of time between notifications to observers that a video is - // playing. - static const double kNotifyIntervalSec; - - VideoDetector(); - virtual ~VideoDetector(); - - void set_now_for_test(base::TimeTicks now) { now_for_test_ = now; } - - void AddObserver(VideoDetectorObserver* observer); - void RemoveObserver(VideoDetectorObserver* observer); - - // RootWindowObserver overrides. - virtual void OnWindowInitialized(aura::Window* window) OVERRIDE; - - // WindowObserver overrides. - virtual void OnWindowPaintScheduled(aura::Window* window, - const gfx::Rect& region) OVERRIDE; - virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; - - private: - class WindowInfo; - typedef std::map<aura::Window*, linked_ptr<WindowInfo> > WindowInfoMap; - - // Possibly notifies observers in response to detection of a video in - // |window|. Notifications are rate-limited and don't get sent if the window - // is invisible or offscreen. - void MaybeNotifyObservers(aura::Window* window, base::TimeTicks now); - - // Maps from a window that we're tracking to information about it. - WindowInfoMap window_infos_; - - ObserverList<VideoDetectorObserver> observers_; - - // Last time at which we notified observers that a video was playing. - base::TimeTicks last_observer_notification_time_; - - // If set, used when the current time is needed. This can be set by tests to - // simulate the passage of time. - base::TimeTicks now_for_test_; - - DISALLOW_COPY_AND_ASSIGN(VideoDetector); -}; - -} // namespace ash - -#endif // ASH_WM_VIDEO_DETECTOR_H_ diff --git a/ash/wm/video_detector_unittest.cc b/ash/wm/video_detector_unittest.cc deleted file mode 100644 index 0b82208..0000000 --- a/ash/wm/video_detector_unittest.cc +++ /dev/null @@ -1,196 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "ash/wm/video_detector.h" - -#include "ash/shell.h" -#include "ash/test/aura_shell_test_base.h" -#include "base/compiler_specific.h" -#include "base/memory/scoped_ptr.h" -#include "base/time.h" -#include "third_party/skia/include/core/SkColor.h" -#include "ui/aura/client/window_types.h" -#include "ui/aura/root_window.h" -#include "ui/aura/test/test_windows.h" -#include "ui/aura/window.h" -#include "ui/gfx/rect.h" - -namespace ash { -namespace test { - -// Implementation that just counts the number of times we've been told that a -// video is playing. -class TestVideoDetectorObserver : public VideoDetectorObserver { - public: - TestVideoDetectorObserver() : num_invocations_(0) {} - - int num_invocations() const { return num_invocations_; } - void reset_stats() { num_invocations_ = 0; } - - // VideoDetectorObserver implementation. - virtual void OnVideoDetected() OVERRIDE { num_invocations_++; } - - private: - // Number of times that OnVideoDetected() has been called. - int num_invocations_; - - DISALLOW_COPY_AND_ASSIGN(TestVideoDetectorObserver); -}; - -class VideoDetectorTest : public AuraShellTestBase { - public: - VideoDetectorTest() {} - virtual ~VideoDetectorTest() {} - - void SetUp() OVERRIDE { - AuraShellTestBase::SetUp(); - observer_.reset(new TestVideoDetectorObserver); - detector_ = Shell::GetInstance()->video_detector(); - detector_->AddObserver(observer_.get()); - - now_ = base::TimeTicks::Now(); - detector_->set_now_for_test(now_); - } - - protected: - // Move |detector_|'s idea of the current time forward by |delta|. - void AdvanceTime(base::TimeDelta delta) { - now_ += delta; - detector_->set_now_for_test(now_); - } - - VideoDetector* detector_; // not owned - - scoped_ptr<TestVideoDetectorObserver> observer_; - - base::TimeTicks now_; - - private: - DISALLOW_COPY_AND_ASSIGN(VideoDetectorTest); -}; - -TEST_F(VideoDetectorTest, Basic) { - gfx::Rect window_bounds(gfx::Point(), gfx::Size(1024, 768)); - scoped_ptr<aura::Window> window( - aura::test::CreateTestWindow(SK_ColorRED, 12345, window_bounds, NULL)); - - // Send enough updates, but make them be too small to trigger detection. - gfx::Rect update_region( - gfx::Point(), - gfx::Size(VideoDetector::kMinUpdateWidth - 1, - VideoDetector::kMinUpdateHeight)); - for (int i = 0; i < VideoDetector::kMinFramesPerSecond; ++i) - detector_->OnWindowPaintScheduled(window.get(), update_region); - EXPECT_EQ(0, observer_->num_invocations()); - - // Send not-quite-enough adaquately-sized updates. - observer_->reset_stats(); - AdvanceTime(base::TimeDelta::FromSeconds(2)); - update_region.set_size( - gfx::Size(VideoDetector::kMinUpdateWidth, - VideoDetector::kMinUpdateHeight)); - for (int i = 0; i < VideoDetector::kMinFramesPerSecond - 1; ++i) - detector_->OnWindowPaintScheduled(window.get(), update_region); - EXPECT_EQ(0, observer_->num_invocations()); - - // We should get notified after the next update, but not in response to - // additional updates. - detector_->OnWindowPaintScheduled(window.get(), update_region); - EXPECT_EQ(1, observer_->num_invocations()); - detector_->OnWindowPaintScheduled(window.get(), update_region); - EXPECT_EQ(1, observer_->num_invocations()); - - // Spread out the frames over two seconds; we shouldn't detect video. - observer_->reset_stats(); - AdvanceTime(base::TimeDelta::FromSeconds(2)); - for (int i = 0; i < VideoDetector::kMinFramesPerSecond - 1; ++i) - detector_->OnWindowPaintScheduled(window.get(), update_region); - AdvanceTime(base::TimeDelta::FromSeconds(1)); - for (int i = 0; i < VideoDetector::kMinFramesPerSecond - 1; ++i) - detector_->OnWindowPaintScheduled(window.get(), update_region); - EXPECT_EQ(0, observer_->num_invocations()); -} - -TEST_F(VideoDetectorTest, WindowNotVisible) { - gfx::Rect window_bounds(gfx::Point(), gfx::Size(1024, 768)); - scoped_ptr<aura::Window> window( - aura::test::CreateTestWindow(SK_ColorRED, 12345, window_bounds, NULL)); - gfx::Rect update_region( - gfx::Point(), - gfx::Size(VideoDetector::kMinUpdateWidth, - VideoDetector::kMinUpdateHeight)); - - // We shouldn't report video that's played in a hidden window. - window->Hide(); - for (int i = 0; i < VideoDetector::kMinFramesPerSecond; ++i) - detector_->OnWindowPaintScheduled(window.get(), update_region); - EXPECT_EQ(0, observer_->num_invocations()); - - // Make the window visible and send more updates. - observer_->reset_stats(); - AdvanceTime(base::TimeDelta::FromSeconds(2)); - window->Show(); - for (int i = 0; i < VideoDetector::kMinFramesPerSecond; ++i) - detector_->OnWindowPaintScheduled(window.get(), update_region); - EXPECT_EQ(1, observer_->num_invocations()); - - // We also shouldn't report video in a window that's fully offscreen. - observer_->reset_stats(); - AdvanceTime(base::TimeDelta::FromSeconds(2)); - gfx::Rect offscreen_bounds( - gfx::Point(aura::RootWindow::GetInstance()->bounds().width(), 0), - window_bounds.size()); - window->SetBounds(offscreen_bounds); - ASSERT_EQ(offscreen_bounds, window->bounds()); - for (int i = 0; i < VideoDetector::kMinFramesPerSecond; ++i) - detector_->OnWindowPaintScheduled(window.get(), update_region); - EXPECT_EQ(0, observer_->num_invocations()); -} - -TEST_F(VideoDetectorTest, MultipleWindows) { - // Create two windows. - gfx::Rect window_bounds(gfx::Point(), gfx::Size(1024, 768)); - scoped_ptr<aura::Window> window1( - aura::test::CreateTestWindow(SK_ColorRED, 12345, window_bounds, NULL)); - scoped_ptr<aura::Window> window2( - aura::test::CreateTestWindow(SK_ColorBLUE, 23456, window_bounds, NULL)); - - // Even if there's video playing in both, the observer should only receive a - // single notification. - gfx::Rect update_region( - gfx::Point(), - gfx::Size(VideoDetector::kMinUpdateWidth, - VideoDetector::kMinUpdateHeight)); - for (int i = 0; i < VideoDetector::kMinFramesPerSecond; ++i) - detector_->OnWindowPaintScheduled(window1.get(), update_region); - for (int i = 0; i < VideoDetector::kMinFramesPerSecond; ++i) - detector_->OnWindowPaintScheduled(window2.get(), update_region); - EXPECT_EQ(1, observer_->num_invocations()); -} - -// Test that the observer receives repeated notifications. -TEST_F(VideoDetectorTest, RepeatedNotifications) { - gfx::Rect window_bounds(gfx::Point(), gfx::Size(1024, 768)); - scoped_ptr<aura::Window> window( - aura::test::CreateTestWindow(SK_ColorRED, 12345, window_bounds, NULL)); - - gfx::Rect update_region( - gfx::Point(), - gfx::Size(VideoDetector::kMinUpdateWidth, - VideoDetector::kMinUpdateHeight)); - for (int i = 0; i < VideoDetector::kMinFramesPerSecond; ++i) - detector_->OnWindowPaintScheduled(window.get(), update_region); - EXPECT_EQ(1, observer_->num_invocations()); - - // Let enough time pass that a second notification should be sent. - observer_->reset_stats(); - AdvanceTime(base::TimeDelta::FromSeconds( - static_cast<int64>(VideoDetector::kNotifyIntervalSec + 1))); - for (int i = 0; i < VideoDetector::kMinFramesPerSecond; ++i) - detector_->OnWindowPaintScheduled(window.get(), update_region); - EXPECT_EQ(1, observer_->num_invocations()); -} - -} // namespace test -} // namespace ash diff --git a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc index 1bafd75..00681a3 100644 --- a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc +++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc @@ -64,7 +64,6 @@ #include "chrome/browser/chromeos/legacy_window_manager/initial_browser_window_observer.h" #include "chrome/browser/chromeos/power/power_button_controller_delegate_chromeos.h" #include "chrome/browser/chromeos/power/power_button_observer.h" -#include "chrome/browser/chromeos/power/video_property_writer.h" #endif class MessageLoopObserver : public MessageLoopForUI::Observer { @@ -456,13 +455,11 @@ void ChromeBrowserMainPartsChromeos::PostBrowserStart() { } #if defined(USE_AURA) - // These are dependent on the ash::Shell singleton already having been + // This is dependent on the ash::Shell singleton already having been // initialized. power_button_observer_.reset(new chromeos::PowerButtonObserver); chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver( power_button_observer_.get()); - - video_property_writer_.reset(new chromeos::VideoPropertyWriter); #endif ChromeBrowserMainPartsLinux::PostBrowserStart(); diff --git a/chrome/browser/chromeos/chrome_browser_main_chromeos.h b/chrome/browser/chromeos/chrome_browser_main_chromeos.h index 7e165f8..6aa771f 100644 --- a/chrome/browser/chromeos/chrome_browser_main_chromeos.h +++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.h @@ -15,7 +15,6 @@ class SessionManagerObserver; #if defined(USE_AURA) class InitialBrowserWindowObserver; class PowerButtonObserver; -class VideoPropertyWriter; #endif } // namespace chromeos @@ -47,7 +46,6 @@ class ChromeBrowserMainPartsChromeos : public ChromeBrowserMainPartsLinux { scoped_ptr<chromeos::InitialBrowserWindowObserver> initial_browser_window_observer_; scoped_ptr<chromeos::PowerButtonObserver> power_button_observer_; - scoped_ptr<chromeos::VideoPropertyWriter> video_property_writer_; #endif DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainPartsChromeos); diff --git a/chrome/browser/chromeos/power/video_property_writer.cc b/chrome/browser/chromeos/power/video_property_writer.cc deleted file mode 100644 index 186e104..0000000 --- a/chrome/browser/chromeos/power/video_property_writer.cc +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/chromeos/power/video_property_writer.h" - -#include <ctime> - -#include "ash/shell.h" -#include "ui/base/x/x11_util.h" - -namespace { - -// Minimum number of seconds between updates to the X property. -const int kUpdateIntervalSec = 5; - -// Name of the X property on the root window. Also used as the property's type. -const char kPropertyName[] = "_CHROME_VIDEO_TIME"; - -} // namespace - -namespace chromeos { - -VideoPropertyWriter::VideoPropertyWriter() { - ash::Shell::GetInstance()->video_detector()->AddObserver(this); -} - -VideoPropertyWriter::~VideoPropertyWriter() { - ash::Shell::GetInstance()->video_detector()->RemoveObserver(this); -} - -void VideoPropertyWriter::OnVideoDetected() { - base::TimeTicks now = base::TimeTicks::Now(); - if (last_update_time_.is_null() || - (now - last_update_time_).InSecondsF() >= kUpdateIntervalSec) { - last_update_time_ = now; - if (!ui::SetIntProperty( - ui::GetX11RootWindow(), - kPropertyName, - kPropertyName, - time(NULL))) { - LOG(WARNING) << "Failed setting " << kPropertyName << " on root window"; - } - } -} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/power/video_property_writer.h b/chrome/browser/chromeos/power/video_property_writer.h deleted file mode 100644 index 95480a7..0000000 --- a/chrome/browser/chromeos/power/video_property_writer.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_CHROMEOS_POWER_VIDEO_PROPERTY_WRITER_H_ -#define CHROME_BROWSER_CHROMEOS_POWER_VIDEO_PROPERTY_WRITER_H_ -#pragma once - -#include "ash/wm/video_detector.h" -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "base/time.h" - -namespace chromeos { - -// Writes a property on the X root window to inform the power manager that a -// video is playing. -class VideoPropertyWriter : public ash::VideoDetectorObserver { - public: - VideoPropertyWriter(); - virtual ~VideoPropertyWriter(); - - // ash::VideoDetectorObserver implementation. - virtual void OnVideoDetected() OVERRIDE; - - private: - // Last time that the X property was updated. - base::TimeTicks last_update_time_; - - DISALLOW_COPY_AND_ASSIGN(VideoPropertyWriter); -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_CHROMEOS_POWER_VIDEO_PROPERTY_WRITER_H_ diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 382c34f..c5abb17 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -739,8 +739,6 @@ 'browser/chromeos/power/power_button_controller_delegate_chromeos.h', 'browser/chromeos/power/power_button_observer.cc', 'browser/chromeos/power/power_button_observer.h', - 'browser/chromeos/power/video_property_writer.cc', - 'browser/chromeos/power/video_property_writer.h', 'browser/chromeos/preferences.cc', 'browser/chromeos/preferences.h', 'browser/chromeos/prerender_condition_network.cc', @@ -5216,8 +5214,6 @@ ['exclude', '^browser/chromeos/power/power_button_controller_delegate_chromeos.h'], ['exclude', '^browser/chromeos/power/power_button_observer.cc'], ['exclude', '^browser/chromeos/power/power_button_observer.h'], - ['exclude', '^browser/chromeos/power/video_property_writer.cc'], - ['exclude', '^browser/chromeos/power/video_property_writer.h'], ['exclude', '^browser/download/download_shelf.h'], ['exclude', '^browser/notifications/balloon_collection_impl.cc'], ['exclude', '^browser/notifications/balloon_collection_impl.h'], diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index 9c3750c..ccc695c 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -333,11 +333,11 @@ void RenderWidgetHostViewAura::UpdateExternalTexture() { #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) if (current_surface_ != gfx::kNullPluginWindow && host_->is_accelerated_compositing_active()) { - window_->SetExternalTexture( + window_->layer()->SetExternalTexture( accelerated_surface_containers_[current_surface_]->GetTexture()); glFlush(); } else { - window_->SetExternalTexture(NULL); + window_->layer()->SetExternalTexture(NULL); } #endif } diff --git a/ui/aura/window.cc b/ui/aura/window.cc index a168501..b0a1ed6 100644 --- a/ui/aura/window.cc +++ b/ui/aura/window.cc @@ -153,8 +153,6 @@ 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) { @@ -163,16 +161,6 @@ 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 e83f531..73ba2dd 100644 --- a/ui/aura/window.h +++ b/ui/aura/window.h @@ -27,7 +27,6 @@ class SkCanvas; namespace ui { class Layer; -class Texture; class Transform; } @@ -117,9 +116,6 @@ 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 d2730c1..3aa0c14 100644 --- a/ui/aura/window_observer.h +++ b/ui/aura/window_observer.h @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -46,10 +46,6 @@ 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 has been destroyed (i.e. from its destructor). virtual void OnWindowDestroyed(Window* window) {} diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc index 302ffd6..9605fde 100644 --- a/ui/base/x/x11_util.cc +++ b/ui/base/x/x11_util.cc @@ -18,7 +18,6 @@ #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" @@ -515,46 +514,11 @@ 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 411c941..757b149 100644 --- a/ui/base/x/x11_util.h +++ b/ui/base/x/x11_util.h @@ -124,15 +124,6 @@ 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 51dd4ca..72f1beb 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(); } - // Assigns a new external texture. |texture| can be NULL to disable external - // updates. + // |texture| cannot be NULL, and this function cannot be called more than + // once. // TODO(beng): This can be removed from the API when we are in a // single-compositor world. void SetExternalTexture(ui::Texture* texture); |