webrender/prim_store/
backdrop.rs1use crate::intern::{Internable, InternDebug, Handle as InternHandle};
6use crate::internal_types::LayoutPrimitiveInfo;
7use crate::prim_store::{
8 InternablePrimitive, PrimitiveKind, PrimKey, PrimTemplate,
9 PrimTemplateCommonData, PrimitiveStore, PictureIndex,
10};
11use crate::render_task_graph::RenderTaskId;
12use crate::scene_building::IsVisible;
13
14#[derive(Copy, Clone, Debug)]
19#[cfg_attr(feature = "capture", derive(Serialize))]
20pub struct BackdropRenderScratch {
21 pub src_task_id: RenderTaskId,
22}
23
24#[cfg_attr(feature = "capture", derive(Serialize))]
25#[cfg_attr(feature = "replay", derive(Deserialize))]
26#[derive(Debug, Clone, Eq, PartialEq, MallocSizeOf, Hash)]
27pub struct BackdropCapture {
28}
29
30#[cfg_attr(feature = "capture", derive(Serialize))]
31#[cfg_attr(feature = "replay", derive(Deserialize))]
32#[derive(Debug, Clone, Eq, PartialEq, MallocSizeOf, Hash)]
33pub struct BackdropRender {
34}
35
36impl From<BackdropCapture> for BackdropCaptureData {
37 fn from(_backdrop: BackdropCapture) -> Self {
38 BackdropCaptureData {
39 }
40 }
41}
42
43impl From<BackdropRender> for BackdropRenderData {
44 fn from(_backdrop: BackdropRender) -> Self {
45 BackdropRenderData {
46 }
47 }
48}
49
50pub type BackdropCaptureKey = PrimKey<BackdropCapture>;
51pub type BackdropRenderKey = PrimKey<BackdropRender>;
52
53impl BackdropCaptureKey {
54 pub fn new(
55 info: &LayoutPrimitiveInfo,
56 backdrop_capture: BackdropCapture,
57 ) -> Self {
58 BackdropCaptureKey {
59 common: info.into(),
60 kind: backdrop_capture,
61 }
62 }
63}
64
65impl BackdropRenderKey {
66 pub fn new(
67 info: &LayoutPrimitiveInfo,
68 backdrop_render: BackdropRender,
69 ) -> Self {
70 BackdropRenderKey {
71 common: info.into(),
72 kind: backdrop_render,
73 }
74 }
75}
76
77impl InternDebug for BackdropCaptureKey {}
78impl InternDebug for BackdropRenderKey {}
79
80#[cfg_attr(feature = "capture", derive(Serialize))]
81#[cfg_attr(feature = "replay", derive(Deserialize))]
82#[derive(Debug, MallocSizeOf)]
83pub struct BackdropCaptureData {
84}
85
86#[cfg_attr(feature = "capture", derive(Serialize))]
87#[cfg_attr(feature = "replay", derive(Deserialize))]
88#[derive(Debug, MallocSizeOf)]
89pub struct BackdropRenderData {
90}
91
92pub type BackdropCaptureTemplate = PrimTemplate<BackdropCaptureData>;
93pub type BackdropRenderTemplate = PrimTemplate<BackdropRenderData>;
94
95impl From<BackdropCaptureKey> for BackdropCaptureTemplate {
96 fn from(backdrop: BackdropCaptureKey) -> Self {
97 let common = PrimTemplateCommonData::with_key_common(backdrop.common);
98
99 BackdropCaptureTemplate {
100 common,
101 kind: backdrop.kind.into(),
102 }
103 }
104}
105
106impl From<BackdropRenderKey> for BackdropRenderTemplate {
107 fn from(backdrop: BackdropRenderKey) -> Self {
108 let common = PrimTemplateCommonData::with_key_common(backdrop.common);
109
110 BackdropRenderTemplate {
111 common,
112 kind: backdrop.kind.into(),
113 }
114 }
115}
116
117pub type BackdropCaptureDataHandle = InternHandle<BackdropCapture>;
118pub type BackdropRenderDataHandle = InternHandle<BackdropRender>;
119
120impl Internable for BackdropCapture {
121 type Key = BackdropCaptureKey;
122 type StoreData = BackdropCaptureTemplate;
123 type InternData = ();
124 const PROFILE_COUNTER: usize = crate::profiler::INTERNED_BACKDROP_CAPTURES;
125}
126
127impl Internable for BackdropRender {
128 type Key = BackdropRenderKey;
129 type StoreData = BackdropRenderTemplate;
130 type InternData = ();
131 const PROFILE_COUNTER: usize = crate::profiler::INTERNED_BACKDROP_RENDERS;
132}
133
134impl InternablePrimitive for BackdropCapture {
135 fn into_key(
136 self,
137 info: &LayoutPrimitiveInfo,
138 ) -> BackdropCaptureKey {
139 BackdropCaptureKey::new(info, self)
140 }
141
142 fn make_instance_kind(
143 _key: BackdropCaptureKey,
144 data_handle: BackdropCaptureDataHandle,
145 _prim_store: &mut PrimitiveStore,
146 ) -> PrimitiveKind {
147 PrimitiveKind::BackdropCapture {
148 data_handle,
149 }
150 }
151}
152
153impl InternablePrimitive for BackdropRender {
154 fn into_key(
155 self,
156 info: &LayoutPrimitiveInfo,
157 ) -> BackdropRenderKey {
158 BackdropRenderKey::new(info, self)
159 }
160
161 fn make_instance_kind(
162 _key: BackdropRenderKey,
163 data_handle: BackdropRenderDataHandle,
164 _prim_store: &mut PrimitiveStore,
165 ) -> PrimitiveKind {
166 PrimitiveKind::BackdropRender {
167 data_handle,
168 pic_index: PictureIndex::INVALID,
169 }
170 }
171}
172
173impl IsVisible for BackdropCapture {
174 fn is_visible(&self) -> bool {
175 true
176 }
177}
178
179impl IsVisible for BackdropRender {
180 fn is_visible(&self) -> bool {
181 true
182 }
183}