| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 } | 302 } |
| 303 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE { | 303 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE { |
| 304 } | 304 } |
| 305 | 305 |
| 306 DISALLOW_COPY_AND_ASSIGN(NullLayerDelegate); | 306 DISALLOW_COPY_AND_ASSIGN(NullLayerDelegate); |
| 307 }; | 307 }; |
| 308 | 308 |
| 309 // Remembers if it has been notified. | 309 // Remembers if it has been notified. |
| 310 class TestCompositorObserver : public CompositorObserver { | 310 class TestCompositorObserver : public CompositorObserver { |
| 311 public: | 311 public: |
| 312 TestCompositorObserver() : started_(false), ended_(false) {} | 312 TestCompositorObserver() : started_(false), ended_(false), aborted_(false) {} |
| 313 | 313 |
| 314 bool notified() const { return started_ && ended_; } | 314 bool notified() const { return started_ && ended_; } |
| 315 bool aborted() const { return aborted_; } |
| 315 | 316 |
| 316 void Reset() { | 317 void Reset() { |
| 317 started_ = false; | 318 started_ = false; |
| 318 ended_ = false; | 319 ended_ = false; |
| 320 aborted_ = false; |
| 319 } | 321 } |
| 320 | 322 |
| 321 private: | 323 private: |
| 322 virtual void OnCompositingStarted(Compositor* compositor) OVERRIDE { | 324 virtual void OnCompositingStarted(Compositor* compositor) OVERRIDE { |
| 323 started_ = true; | 325 started_ = true; |
| 324 } | 326 } |
| 325 | 327 |
| 326 virtual void OnCompositingEnded(Compositor* compositor) OVERRIDE { | 328 virtual void OnCompositingEnded(Compositor* compositor) OVERRIDE { |
| 327 ended_ = true; | 329 ended_ = true; |
| 328 } | 330 } |
| 329 | 331 |
| 332 virtual void OnCompositingAborted(Compositor* compositor) OVERRIDE { |
| 333 aborted_ = true; |
| 334 } |
| 335 |
| 330 bool started_; | 336 bool started_; |
| 331 bool ended_; | 337 bool ended_; |
| 338 bool aborted_; |
| 332 | 339 |
| 333 DISALLOW_COPY_AND_ASSIGN(TestCompositorObserver); | 340 DISALLOW_COPY_AND_ASSIGN(TestCompositorObserver); |
| 334 }; | 341 }; |
| 335 | 342 |
| 336 } // namespace | 343 } // namespace |
| 337 | 344 |
| 338 #if defined(OS_WIN) | 345 #if defined(OS_WIN) |
| 339 // These are disabled on windows as they don't run correctly on the buildbot. | 346 // These are disabled on windows as they don't run correctly on the buildbot. |
| 340 // Reenable once we move to the real compositor. | 347 // Reenable once we move to the real compositor. |
| 341 #define MAYBE_Delegate DISABLED_Delegate | 348 #define MAYBE_Delegate DISABLED_Delegate |
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 879 // Setting the transform of a layer should alert the observers. | 886 // Setting the transform of a layer should alert the observers. |
| 880 observer.Reset(); | 887 observer.Reset(); |
| 881 Transform transform; | 888 Transform transform; |
| 882 transform.ConcatTranslate(-200, -200); | 889 transform.ConcatTranslate(-200, -200); |
| 883 transform.ConcatRotate(90.0f); | 890 transform.ConcatRotate(90.0f); |
| 884 transform.ConcatTranslate(200, 200); | 891 transform.ConcatTranslate(200, 200); |
| 885 l2->SetTransform(transform); | 892 l2->SetTransform(transform); |
| 886 RunPendingMessages(); | 893 RunPendingMessages(); |
| 887 EXPECT_TRUE(observer.notified()); | 894 EXPECT_TRUE(observer.notified()); |
| 888 | 895 |
| 896 // A change resulting in an aborted swap buffer should alert the observer |
| 897 // and also signal an abort. |
| 898 observer.Reset(); |
| 899 l2->SetOpacity(0.1f); |
| 900 GetCompositor()->OnSwapBuffersAborted(); |
| 901 RunPendingMessages(); |
| 902 EXPECT_TRUE(observer.notified()); |
| 903 EXPECT_TRUE(observer.aborted()); |
| 904 |
| 889 GetCompositor()->RemoveObserver(&observer); | 905 GetCompositor()->RemoveObserver(&observer); |
| 890 | 906 |
| 891 // Opacity changes should no longer alert the removed observer. | 907 // Opacity changes should no longer alert the removed observer. |
| 892 observer.Reset(); | 908 observer.Reset(); |
| 893 l2->SetOpacity(0.5f); | 909 l2->SetOpacity(0.5f); |
| 894 RunPendingMessages(); | 910 RunPendingMessages(); |
| 895 EXPECT_FALSE(observer.notified()); | 911 EXPECT_FALSE(observer.notified()); |
| 896 } | 912 } |
| 897 | 913 |
| 898 // Checks that modifying the hierarchy correctly affects final composite. | 914 // Checks that modifying the hierarchy correctly affects final composite. |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1255 | 1271 |
| 1256 // Resize layer. | 1272 // Resize layer. |
| 1257 child->SetBounds(gfx::Rect(200, 200, 400, 400)); | 1273 child->SetBounds(gfx::Rect(200, 200, 400, 400)); |
| 1258 child->SetVisible(true); | 1274 child->SetVisible(true); |
| 1259 EXPECT_TRUE(schedule_draw_invoked_); | 1275 EXPECT_TRUE(schedule_draw_invoked_); |
| 1260 DrawTree(root.get()); | 1276 DrawTree(root.get()); |
| 1261 EXPECT_TRUE(delegate.painted()); | 1277 EXPECT_TRUE(delegate.painted()); |
| 1262 } | 1278 } |
| 1263 | 1279 |
| 1264 } // namespace ui | 1280 } // namespace ui |
| OLD | NEW |