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.
5 #include "cc/test/test_context_support.h"
8 #include "base/message_loop/message_loop.h"
12 TestContextSupport::TestContextSupport()
13 : weak_ptr_factory_(this) {
16 TestContextSupport::~TestContextSupport() {}
18 void TestContextSupport::SignalSyncPoint(uint32 sync_point
,
19 const base::Closure
& callback
) {
20 sync_point_callbacks_
.push_back(callback
);
21 base::MessageLoop::current()->PostTask(
23 base::Bind(&TestContextSupport::CallAllSyncPointCallbacks
,
24 weak_ptr_factory_
.GetWeakPtr()));
27 void TestContextSupport::SignalQuery(uint32 query
,
28 const base::Closure
& callback
) {
29 sync_point_callbacks_
.push_back(callback
);
30 base::MessageLoop::current()->PostTask(
32 base::Bind(&TestContextSupport::CallAllSyncPointCallbacks
,
33 weak_ptr_factory_
.GetWeakPtr()));
36 void TestContextSupport::SetSurfaceVisible(bool visible
) {
37 if (!set_visible_callback_
.is_null()) {
38 set_visible_callback_
.Run(visible
);
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
]);
47 sync_point_callbacks_
.clear();
50 void TestContextSupport::SetSurfaceVisibleCallback(
51 const SurfaceVisibleCallback
& set_visible_callback
) {
52 set_visible_callback_
= set_visible_callback
;
55 void TestContextSupport::SetScheduleOverlayPlaneCallback(
56 const ScheduleOverlayPlaneCallback
& schedule_overlay_plane_callback
) {
57 schedule_overlay_plane_callback_
= schedule_overlay_plane_callback
;
60 void TestContextSupport::Swap() {
63 uint32
TestContextSupport::InsertFutureSyncPointCHROMIUM() {
68 void TestContextSupport::RetireSyncPointCHROMIUM(uint32 sync_point
) {
72 void TestContextSupport::PartialSwapBuffers(const gfx::Rect
& sub_buffer
) {
75 void TestContextSupport::ScheduleOverlayPlane(
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
,