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/location.h"
9 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h"
14 TestContextSupport::TestContextSupport()
15 : weak_ptr_factory_(this) {
18 TestContextSupport::~TestContextSupport() {}
20 void TestContextSupport::SignalSyncPoint(uint32 sync_point
,
21 const base::Closure
& callback
) {
22 sync_point_callbacks_
.push_back(callback
);
23 base::ThreadTaskRunnerHandle::Get()->PostTask(
24 FROM_HERE
, base::Bind(&TestContextSupport::CallAllSyncPointCallbacks
,
25 weak_ptr_factory_
.GetWeakPtr()));
28 void TestContextSupport::SignalQuery(uint32 query
,
29 const base::Closure
& callback
) {
30 sync_point_callbacks_
.push_back(callback
);
31 base::ThreadTaskRunnerHandle::Get()->PostTask(
32 FROM_HERE
, 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::SetAggressivelyFreeResources(
43 bool aggressively_free_resources
) {
46 void TestContextSupport::CallAllSyncPointCallbacks() {
47 for (size_t i
= 0; i
< sync_point_callbacks_
.size(); ++i
) {
48 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE
,
49 sync_point_callbacks_
[i
]);
51 sync_point_callbacks_
.clear();
54 void TestContextSupport::SetSurfaceVisibleCallback(
55 const SurfaceVisibleCallback
& set_visible_callback
) {
56 set_visible_callback_
= set_visible_callback
;
59 void TestContextSupport::SetScheduleOverlayPlaneCallback(
60 const ScheduleOverlayPlaneCallback
& schedule_overlay_plane_callback
) {
61 schedule_overlay_plane_callback_
= schedule_overlay_plane_callback
;
64 void TestContextSupport::Swap() {
67 uint32
TestContextSupport::InsertFutureSyncPointCHROMIUM() {
72 void TestContextSupport::RetireSyncPointCHROMIUM(uint32 sync_point
) {
76 void TestContextSupport::PartialSwapBuffers(const gfx::Rect
& sub_buffer
) {
79 void TestContextSupport::ScheduleOverlayPlane(
81 gfx::OverlayTransform plane_transform
,
82 unsigned overlay_texture_id
,
83 const gfx::Rect
& display_bounds
,
84 const gfx::RectF
& uv_rect
) {
85 if (!schedule_overlay_plane_callback_
.is_null()) {
86 schedule_overlay_plane_callback_
.Run(plane_z_order
,