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
use std::cell::RefMut;
use super::font::FontCache;
use super::primitive_canvas::{
CachedColorDraw,
CachedTexDraw,
DrawParamModifier,
StencilState
};
use glium;
use poison_pool;
pub trait HasDisplay {
fn borrow_display(&self) -> &glium::Display;
fn clone_display(&self) -> glium::Display {
self.borrow_display().clone()
}
}
impl HasDisplay for glium::Display {
fn borrow_display(&self) -> &glium::Display {
self
}
}
pub trait DrawParamMod {
fn draw_param_mod(&self) -> &DrawParamModifier;
fn draw_param_mod_mut(&mut self) -> &mut DrawParamModifier;
fn scissor(&self) -> Option<(u32, u32, u32, u32)> {
self.draw_param_mod().scissor.clone()
}
fn take_scissor(&mut self) -> Option<(u32, u32, u32, u32)> {
self.draw_param_mod_mut().scissor.take()
}
fn set_scissor(&mut self, s: Option<(u32, u32, u32, u32)>) {
*(&mut self.draw_param_mod_mut().scissor) = s
}
fn stencil_state(&self) -> StencilState {
self.draw_param_mod().stencil_state
}
fn set_stencil_state(&mut self, stencil_state: StencilState) {
(*self.draw_param_mod_mut()).stencil_state = stencil_state;
}
}
pub trait HasPrograms {
fn texture_shader(&self) -> &glium::Program;
fn color_shader(&self) -> &glium::Program;
}
pub trait HasFontCache {
fn font_cache(&self) -> RefMut<FontCache>;
}
pub trait HasSurface {
type Out: glium::Surface;
fn surface(&mut self) -> &mut Self::Out;
fn surface_and_texture_shader(&mut self) -> (&mut Self::Out, &glium::Program);
fn surface_and_color_shader(&mut self) -> (&mut Self::Out, &glium::Program);
}
pub trait HasDrawCache {
fn color_draw_cache(&self) -> &Option<CachedColorDraw>;
fn tex_draw_cache(&self) -> &Option<CachedTexDraw>;
fn color_draw_cache_mut(&mut self) -> &mut Option<CachedColorDraw>;
fn tex_draw_cache_mut(&mut self) -> &mut Option<CachedTexDraw>;
}
pub trait Fetch<T> {
fn fetch(&self) -> poison_pool::Item<T>;
}