forked from Pissandshittium/pissandshittium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfake_context_factory.cc
70 lines (56 loc) · 2.11 KB
/
fake_context_factory.cc
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
// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/compositor/test/fake_context_factory.h"
#include "base/command_line.h"
#include "build/build_config.h"
#include "cc/base/switches.h"
#include "cc/test/fake_layer_tree_frame_sink.h"
#include "cc/trees/layer_tree_frame_sink_client.h"
#include "components/viz/common/frame_sinks/begin_frame_source.h"
#include "components/viz/common/frame_sinks/delay_based_time_source.h"
#include "components/viz/common/quads/compositor_frame.h"
#include "ui/compositor/compositor_switches.h"
#include "ui/display/display_switches.h"
#include "ui/gfx/switches.h"
#if BUILDFLAG(IS_APPLE)
#include "ui/accelerated_widget_mac/ca_transaction_observer.h"
#endif
namespace ui {
FakeContextFactory::FakeContextFactory() {
#if BUILDFLAG(IS_APPLE)
renderer_settings_.release_overlay_resources_after_gpu_query = true;
// Ensure that tests don't wait for frames that will never come.
ui::CATransactionCoordinator::Get().DisableForTesting();
#endif
}
FakeContextFactory::~FakeContextFactory() = default;
const viz::CompositorFrame& FakeContextFactory::GetLastCompositorFrame() const {
return *frame_sink_->last_sent_frame();
}
void FakeContextFactory::CreateLayerTreeFrameSink(
base::WeakPtr<ui::Compositor> compositor) {
auto frame_sink = cc::FakeLayerTreeFrameSink::Create3d();
frame_sink_ = frame_sink.get();
compositor->SetLayerTreeFrameSink(
std::move(frame_sink),
mojo::AssociatedRemote<viz::mojom::DisplayPrivate>());
}
scoped_refptr<viz::ContextProvider>
FakeContextFactory::SharedMainThreadContextProvider() {
return nullptr;
}
scoped_refptr<viz::RasterContextProvider>
FakeContextFactory::SharedMainThreadRasterContextProvider() {
return nullptr;
}
void FakeContextFactory::RemoveCompositor(ui::Compositor* compositor) {
frame_sink_ = nullptr;
}
gpu::GpuMemoryBufferManager* FakeContextFactory::GetGpuMemoryBufferManager() {
return &gpu_memory_buffer_manager_;
}
cc::TaskGraphRunner* FakeContextFactory::GetTaskGraphRunner() {
return &task_graph_runner_;
}
} // namespace ui