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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use api::units::*;
use crate::intern::{Internable, InternDebug, Handle as InternHandle};
use crate::internal_types::LayoutPrimitiveInfo;
use crate::prim_store::{
    InternablePrimitive, PrimitiveInstanceKind, PrimKey, PrimTemplate,
    PrimTemplateCommonData, PrimitiveStore, PictureIndex,
};
use crate::scene_building::IsVisible;

#[cfg_attr(feature = "capture", derive(Serialize))]
#[cfg_attr(feature = "replay", derive(Deserialize))]
#[derive(Debug, Clone, Eq, PartialEq, MallocSizeOf, Hash)]
pub struct BackdropCapture {
}

#[cfg_attr(feature = "capture", derive(Serialize))]
#[cfg_attr(feature = "replay", derive(Deserialize))]
#[derive(Debug, Clone, Eq, PartialEq, MallocSizeOf, Hash)]
pub struct BackdropRender {
}

impl From<BackdropCapture> for BackdropCaptureData {
    fn from(_backdrop: BackdropCapture) -> Self {
        BackdropCaptureData {
        }
    }
}

impl From<BackdropRender> for BackdropRenderData {
    fn from(_backdrop: BackdropRender) -> Self {
        BackdropRenderData {
        }
    }
}

pub type BackdropCaptureKey = PrimKey<BackdropCapture>;
pub type BackdropRenderKey = PrimKey<BackdropRender>;

impl BackdropCaptureKey {
    pub fn new(
        info: &LayoutPrimitiveInfo,
        backdrop_capture: BackdropCapture,
    ) -> Self {
        BackdropCaptureKey {
            common: info.into(),
            kind: backdrop_capture,
        }
    }
}

impl BackdropRenderKey {
    pub fn new(
        info: &LayoutPrimitiveInfo,
        backdrop_render: BackdropRender,
    ) -> Self {
        BackdropRenderKey {
            common: info.into(),
            kind: backdrop_render,
        }
    }
}

impl InternDebug for BackdropCaptureKey {}
impl InternDebug for BackdropRenderKey {}

#[cfg_attr(feature = "capture", derive(Serialize))]
#[cfg_attr(feature = "replay", derive(Deserialize))]
#[derive(Debug, MallocSizeOf)]
pub struct BackdropCaptureData {
}

#[cfg_attr(feature = "capture", derive(Serialize))]
#[cfg_attr(feature = "replay", derive(Deserialize))]
#[derive(Debug, MallocSizeOf)]
pub struct BackdropRenderData {
}

pub type BackdropCaptureTemplate = PrimTemplate<BackdropCaptureData>;
pub type BackdropRenderTemplate = PrimTemplate<BackdropRenderData>;

impl From<BackdropCaptureKey> for BackdropCaptureTemplate {
    fn from(backdrop: BackdropCaptureKey) -> Self {
        let common = PrimTemplateCommonData::with_key_common(backdrop.common);

        BackdropCaptureTemplate {
            common,
            kind: backdrop.kind.into(),
        }
    }
}

impl From<BackdropRenderKey> for BackdropRenderTemplate {
    fn from(backdrop: BackdropRenderKey) -> Self {
        let common = PrimTemplateCommonData::with_key_common(backdrop.common);

        BackdropRenderTemplate {
            common,
            kind: backdrop.kind.into(),
        }
    }
}

pub type BackdropCaptureDataHandle = InternHandle<BackdropCapture>;
pub type BackdropRenderDataHandle = InternHandle<BackdropRender>;

impl Internable for BackdropCapture {
    type Key = BackdropCaptureKey;
    type StoreData = BackdropCaptureTemplate;
    type InternData = ();
    const PROFILE_COUNTER: usize = crate::profiler::INTERNED_BACKDROP_CAPTURES;
}

impl Internable for BackdropRender {
    type Key = BackdropRenderKey;
    type StoreData = BackdropRenderTemplate;
    type InternData = ();
    const PROFILE_COUNTER: usize = crate::profiler::INTERNED_BACKDROP_RENDERS;
}

impl InternablePrimitive for BackdropCapture {
    fn into_key(
        self,
        info: &LayoutPrimitiveInfo,
    ) -> BackdropCaptureKey {
        BackdropCaptureKey::new(info, self)
    }

    fn make_instance_kind(
        _key: BackdropCaptureKey,
        data_handle: BackdropCaptureDataHandle,
        _prim_store: &mut PrimitiveStore,
        _reference_frame_relative_offset: LayoutVector2D,
    ) -> PrimitiveInstanceKind {
        PrimitiveInstanceKind::BackdropCapture {
            data_handle,
        }
    }
}

impl InternablePrimitive for BackdropRender {
    fn into_key(
        self,
        info: &LayoutPrimitiveInfo,
    ) -> BackdropRenderKey {
        BackdropRenderKey::new(info, self)
    }

    fn make_instance_kind(
        _key: BackdropRenderKey,
        data_handle: BackdropRenderDataHandle,
        _prim_store: &mut PrimitiveStore,
        _reference_frame_relative_offset: LayoutVector2D,
    ) -> PrimitiveInstanceKind {
        PrimitiveInstanceKind::BackdropRender {
            data_handle,
            pic_index: PictureIndex::INVALID,
        }
    }
}

impl IsVisible for BackdropCapture {
    fn is_visible(&self) -> bool {
        true
    }
}

impl IsVisible for BackdropRender {
    fn is_visible(&self) -> bool {
        true
    }
}