forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoverlay_candidate.h
142 lines (120 loc) · 5.29 KB
/
overlay_candidate.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
137
138
139
140
141
142
// 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_OUTPUT_OVERLAY_CANDIDATE_H_
#define CC_OUTPUT_OVERLAY_CANDIDATE_H_
#include <map>
#include <vector>
#include "cc/cc_export.h"
#include "components/viz/common/quads/render_pass.h"
#include "components/viz/common/resources/resource_id.h"
#include "ui/gfx/buffer_types.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_f.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/overlay_transform.h"
#include "ui/gfx/transform.h"
namespace gfx {
class Rect;
}
namespace viz {
class StreamVideoDrawQuad;
class TextureDrawQuad;
class TileDrawQuad;
} // namespace viz
namespace cc {
class DisplayResourceProvider;
class CC_EXPORT OverlayCandidate {
public:
// Returns true and fills in |candidate| if |draw_quad| is of a known quad
// type and contains an overlayable resource.
static bool FromDrawQuad(DisplayResourceProvider* resource_provider,
const SkMatrix44& output_color_matrix,
const viz::DrawQuad* quad,
OverlayCandidate* candidate);
// Returns true if |quad| will not block quads underneath from becoming
// an overlay.
static bool IsInvisibleQuad(const viz::DrawQuad* quad);
// Returns true if any any of the quads in the list given by |quad_list_begin|
// and |quad_list_end| are visible and on top of |candidate|.
static bool IsOccluded(const OverlayCandidate& candidate,
viz::QuadList::ConstIterator quad_list_begin,
viz::QuadList::ConstIterator quad_list_end);
OverlayCandidate();
OverlayCandidate(const OverlayCandidate& other);
~OverlayCandidate();
// Transformation to apply to layer during composition.
gfx::OverlayTransform transform;
// Format of the buffer to scanout.
gfx::BufferFormat format;
// Size of the resource, in pixels.
gfx::Size resource_size_in_pixels;
// Rect on the display to position the overlay to. Implementer must convert
// to integer coordinates if setting |overlay_handled| to true.
gfx::RectF display_rect;
// Crop within the buffer to be placed inside |display_rect|.
gfx::RectF uv_rect;
// Clip rect in the target content space after composition.
gfx::Rect clip_rect;
// If the quad is clipped after composition.
bool is_clipped;
// If the quad doesn't require blending.
bool is_opaque;
// True if the texture for this overlay should be the same one used by the
// output surface's main overlay.
bool use_output_surface_for_resource;
// Texture resource to present in an overlay.
unsigned resource_id;
#if defined(OS_ANDROID)
// For candidates from StreamVideoDrawQuads, this records whether the quad is
// marked as being backed by a SurfaceTexture or not. If so, it's not really
// promotable to an overlay.
bool is_backed_by_surface_texture;
// Filled in by the OverlayCandidateValidator to indicate whether this is a
// promotable candidate or not.
bool is_promotable_hint;
#endif
// Stacking order of the overlay plane relative to the main surface,
// which is 0. Signed to allow for "underlays".
int plane_z_order;
// True if the overlay does not have any visible quads on top of it. Set by
// the strategy so the OverlayProcessor can consider subtracting damage caused
// by underlay quads.
bool is_unoccluded;
// To be modified by the implementer if this candidate can go into
// an overlay.
bool overlay_handled;
private:
static bool FromDrawQuadResource(DisplayResourceProvider* resource_provider,
const viz::DrawQuad* quad,
viz::ResourceId resource_id,
bool y_flipped,
OverlayCandidate* candidate);
static bool FromTextureQuad(DisplayResourceProvider* resource_provider,
const viz::TextureDrawQuad* quad,
OverlayCandidate* candidate);
static bool FromTileQuad(DisplayResourceProvider* resource_provider,
const viz::TileDrawQuad* quad,
OverlayCandidate* candidate);
static bool FromStreamVideoQuad(DisplayResourceProvider* resource_provider,
const viz::StreamVideoDrawQuad* quad,
OverlayCandidate* candidate);
};
class CC_EXPORT OverlayCandidateList : public std::vector<OverlayCandidate> {
public:
OverlayCandidateList();
OverlayCandidateList(const OverlayCandidateList&);
OverlayCandidateList(OverlayCandidateList&&);
~OverlayCandidateList();
OverlayCandidateList& operator=(const OverlayCandidateList&);
OverlayCandidateList& operator=(OverlayCandidateList&&);
// [id] == candidate's |display_rect| for all promotable resources.
using PromotionHintInfoMap = std::map<viz::ResourceId, gfx::RectF>;
// For android, this provides a set of resources that could be promoted to
// overlay, if one backs them with a SurfaceView.
PromotionHintInfoMap promotion_hint_info_map_;
// Helper to insert |candidate| into |promotion_hint_info_|.
void AddPromotionHint(const OverlayCandidate& candidate);
};
} // namespace cc
#endif // CC_OUTPUT_OVERLAY_CANDIDATE_H_