1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
content / public / test / test_synchronous_compositor_android.cc [blame]
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/public/test/test_synchronous_compositor_android.h"
#include <utility>
#include "components/viz/common/quads/compositor_frame.h"
namespace content {
TestSynchronousCompositor::TestSynchronousCompositor(
const viz::FrameSinkId& frame_sink_id)
: client_(nullptr), frame_sink_id_(frame_sink_id) {}
TestSynchronousCompositor::~TestSynchronousCompositor() {
SetClient(nullptr);
}
void TestSynchronousCompositor::SetClient(SynchronousCompositorClient* client) {
if (client_)
client_->DidDestroyCompositor(this, frame_sink_id_);
client_ = client;
if (client_)
client_->DidInitializeCompositor(this, frame_sink_id_);
}
scoped_refptr<SynchronousCompositor::FrameFuture>
TestSynchronousCompositor::DemandDrawHwAsync(
const gfx::Size& viewport_size,
const gfx::Rect& viewport_rect_for_tile_priority,
const gfx::Transform& transform_for_tile_priority) {
auto future = base::MakeRefCounted<FrameFuture>();
future->SetFrame(std::move(hardware_frame_));
return future;
}
void TestSynchronousCompositor::ReturnResources(
uint32_t layer_tree_frame_sink_id,
std::vector<viz::ReturnedResource> resources) {
ReturnedResources returned_resources;
returned_resources.layer_tree_frame_sink_id = layer_tree_frame_sink_id;
returned_resources.resources = std::move(resources);
frame_ack_array_.push_back(std::move(returned_resources));
}
void TestSynchronousCompositor::SwapReturnedResources(FrameAckArray* array) {
DCHECK(array);
frame_ack_array_.swap(*array);
}
bool TestSynchronousCompositor::DemandDrawSw(SkCanvas* canvas,
bool software_canvas) {
DCHECK(canvas);
return true;
}
float TestSynchronousCompositor::GetVelocityInPixelsPerSecond() {
return 0.f;
}
void TestSynchronousCompositor::SetHardwareFrame(
uint32_t layer_tree_frame_sink_id,
std::unique_ptr<viz::CompositorFrame> frame) {
hardware_frame_ = std::make_unique<Frame>();
hardware_frame_->layer_tree_frame_sink_id = layer_tree_frame_sink_id;
hardware_frame_->local_surface_id =
viz::LocalSurfaceId(1, base::UnguessableToken::Create());
hardware_frame_->frame = std::move(frame);
}
TestSynchronousCompositor::ReturnedResources::ReturnedResources()
: layer_tree_frame_sink_id(0u) {}
TestSynchronousCompositor::ReturnedResources::ReturnedResources(
ReturnedResources&&) = default;
TestSynchronousCompositor::ReturnedResources::~ReturnedResources() {}
} // namespace content