OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "cc/test/test_context_support.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" |
| 9 |
| 10 namespace cc { |
| 11 |
| 12 TestContextSupport::TestContextSupport() |
| 13 : weak_ptr_factory_(this) { |
| 14 } |
| 15 |
| 16 TestContextSupport::~TestContextSupport() {} |
| 17 |
| 18 void TestContextSupport::SignalSyncPoint(uint32 sync_point, |
| 19 const base::Closure& callback) { |
| 20 sync_point_callbacks_.push_back(callback); |
| 21 base::MessageLoop::current()->PostTask( |
| 22 FROM_HERE, |
| 23 base::Bind(&TestContextSupport::CallAllSyncPointCallbacks, |
| 24 weak_ptr_factory_.GetWeakPtr())); |
| 25 } |
| 26 |
| 27 void TestContextSupport::SignalQuery(uint32 query, |
| 28 const base::Closure& callback) { |
| 29 sync_point_callbacks_.push_back(callback); |
| 30 base::MessageLoop::current()->PostTask( |
| 31 FROM_HERE, |
| 32 base::Bind(&TestContextSupport::CallAllSyncPointCallbacks, |
| 33 weak_ptr_factory_.GetWeakPtr())); |
| 34 } |
| 35 |
| 36 void TestContextSupport::SetSurfaceVisible(bool visible) { |
| 37 if (!set_visible_callback_.is_null()) { |
| 38 set_visible_callback_.Run(visible); |
| 39 } |
| 40 } |
| 41 |
| 42 void TestContextSupport::CallAllSyncPointCallbacks() { |
| 43 for (size_t i = 0; i < sync_point_callbacks_.size(); ++i) { |
| 44 base::MessageLoop::current()->PostTask( |
| 45 FROM_HERE, sync_point_callbacks_[i]); |
| 46 } |
| 47 sync_point_callbacks_.clear(); |
| 48 } |
| 49 |
| 50 void TestContextSupport::SetSurfaceVisibleCallback( |
| 51 const SurfaceVisibleCallback& set_visible_callback) { |
| 52 set_visible_callback_ = set_visible_callback; |
| 53 } |
| 54 |
| 55 void TestContextSupport::SetScheduleOverlayPlaneCallback( |
| 56 const ScheduleOverlayPlaneCallback& schedule_overlay_plane_callback) { |
| 57 schedule_overlay_plane_callback_ = schedule_overlay_plane_callback; |
| 58 } |
| 59 |
| 60 void TestContextSupport::Swap() { |
| 61 } |
| 62 |
| 63 uint32 TestContextSupport::InsertFutureSyncPointCHROMIUM() { |
| 64 NOTIMPLEMENTED(); |
| 65 return 0; |
| 66 } |
| 67 |
| 68 void TestContextSupport::RetireSyncPointCHROMIUM(uint32 sync_point) { |
| 69 NOTIMPLEMENTED(); |
| 70 } |
| 71 |
| 72 void TestContextSupport::PartialSwapBuffers(const gfx::Rect& sub_buffer) { |
| 73 } |
| 74 |
| 75 void TestContextSupport::ScheduleOverlayPlane( |
| 76 int plane_z_order, |
| 77 gfx::OverlayTransform plane_transform, |
| 78 unsigned overlay_texture_id, |
| 79 const gfx::Rect& display_bounds, |
| 80 const gfx::RectF& uv_rect) { |
| 81 if (!schedule_overlay_plane_callback_.is_null()) { |
| 82 schedule_overlay_plane_callback_.Run(plane_z_order, |
| 83 plane_transform, |
| 84 overlay_texture_id, |
| 85 display_bounds, |
| 86 uv_rect); |
| 87 } |
| 88 } |
| 89 |
| 90 } // namespace cc |
OLD | NEW |