forked from Pissandshittium/pissandshittium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisplay.h
136 lines (112 loc) · 4.64 KB
/
display.h
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CC_SURFACES_DISPLAY_H_
#define CC_SURFACES_DISPLAY_H_
#include <memory>
#include <vector>
#include "base/macros.h"
#include "cc/output/output_surface_client.h"
#include "cc/resources/returned_resource.h"
#include "cc/scheduler/begin_frame_source.h"
#include "cc/surfaces/display_scheduler.h"
#include "cc/surfaces/frame_sink_id.h"
#include "cc/surfaces/surface_aggregator.h"
#include "cc/surfaces/surface_id.h"
#include "cc/surfaces/surface_manager.h"
#include "cc/surfaces/surfaces_export.h"
#include "gpu/command_buffer/common/texture_in_use_response.h"
#include "ui/events/latency_info.h"
#include "ui/gfx/color_space.h"
namespace gpu {
class GpuMemoryBufferManager;
}
namespace gfx {
class Size;
}
namespace cc {
class BeginFrameSource;
class DirectRenderer;
class DisplayClient;
class OutputSurface;
class RendererSettings;
class ResourceProvider;
class SharedBitmapManager;
class SoftwareRenderer;
class SurfaceAggregator;
class TextureMailboxDeleter;
// A Display produces a surface that can be used to draw to a physical display
// (OutputSurface). The client is responsible for creating and sizing the
// surface IDs used to draw into the display and deciding when to draw.
class CC_SURFACES_EXPORT Display : public DisplaySchedulerClient,
public OutputSurfaceClient,
public SurfaceObserver {
public:
// The |begin_frame_source| and |scheduler| may be null (together). In that
// case, DrawAndSwap must be called externally when needed.
Display(SharedBitmapManager* bitmap_manager,
gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
const RendererSettings& settings,
const FrameSinkId& frame_sink_id,
BeginFrameSource* begin_frame_source,
std::unique_ptr<OutputSurface> output_surface,
std::unique_ptr<DisplayScheduler> scheduler,
std::unique_ptr<TextureMailboxDeleter> texture_mailbox_deleter);
~Display() override;
void Initialize(DisplayClient* client, SurfaceManager* surface_manager);
// device_scale_factor is used to communicate to the external window system
// what scale this was rendered at.
void SetLocalSurfaceId(const LocalSurfaceId& id, float device_scale_factor);
void SetVisible(bool visible);
void Resize(const gfx::Size& new_size);
void SetColorSpace(const gfx::ColorSpace& blending_color_space,
const gfx::ColorSpace& device_color_space);
void SetOutputIsSecure(bool secure);
const SurfaceId& CurrentSurfaceId();
// DisplaySchedulerClient implementation.
bool DrawAndSwap() override;
// OutputSurfaceClient implementation.
void SetNeedsRedrawRect(const gfx::Rect& damage_rect) override;
void DidReceiveSwapBuffersAck() override;
void DidReceiveTextureInUseResponses(
const gpu::TextureInUseResponses& responses) override;
// SurfaceObserver implementation.
void OnSurfaceDamaged(const SurfaceId& surface, bool* changed) override;
void OnSurfaceCreated(const SurfaceInfo& surface_info) override;
bool has_scheduler() const { return !!scheduler_; }
DirectRenderer* renderer_for_testing() const { return renderer_.get(); }
void ForceImmediateDrawAndSwapIfPossible();
private:
void InitializeRenderer();
void UpdateRootSurfaceResourcesLocked();
void DidLoseContextProvider();
SharedBitmapManager* const bitmap_manager_;
gpu::GpuMemoryBufferManager* const gpu_memory_buffer_manager_;
const RendererSettings settings_;
DisplayClient* client_ = nullptr;
SurfaceManager* surface_manager_ = nullptr;
const FrameSinkId frame_sink_id_;
SurfaceId current_surface_id_;
gfx::Size current_surface_size_;
float device_scale_factor_ = 1.f;
gfx::ColorSpace blending_color_space_;
gfx::ColorSpace device_color_space_;
bool visible_ = false;
bool swapped_since_resize_ = false;
bool output_is_secure_ = false;
// The begin_frame_source_ is not owned here, and also often known by the
// output_surface_ and the scheduler_.
BeginFrameSource* begin_frame_source_;
std::unique_ptr<OutputSurface> output_surface_;
std::unique_ptr<DisplayScheduler> scheduler_;
std::unique_ptr<ResourceProvider> resource_provider_;
std::unique_ptr<SurfaceAggregator> aggregator_;
std::unique_ptr<TextureMailboxDeleter> texture_mailbox_deleter_;
std::unique_ptr<DirectRenderer> renderer_;
SoftwareRenderer* software_renderer_ = nullptr;
std::vector<ui::LatencyInfo> stored_latency_info_;
private:
DISALLOW_COPY_AND_ASSIGN(Display);
};
} // namespace cc
#endif // CC_SURFACES_DISPLAY_H_