]> git.cworth.org Git - vogl/blob - src/voglcommon/vogl_display_list_state.h
Initial vogl checkin
[vogl] / src / voglcommon / vogl_display_list_state.h
1 /**************************************************************************
2  *
3  * Copyright 2013-2014 RAD Game Tools and Valve Software
4  * All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  *
24  **************************************************************************/
25
26 // File: vogl_display_list_state.h
27 #ifndef VOGL_DISPLAY_LIST_STATE_H
28 #define VOGL_DISPLAY_LIST_STATE_H
29
30 #include "vogl_core.h"
31 #include "vogl_context_info.h"
32 #include "vogl_general_context_state.h"
33 #include "vogl_blob_manager.h"
34 #include "vogl_trace_file_reader.h"
35
36 //----------------------------------------------------------------------------------------------------------------------
37 // class vogl_display_list
38 //----------------------------------------------------------------------------------------------------------------------
39 class vogl_display_list
40 {
41 public:
42     vogl_display_list();
43
44     void clear();
45
46     GLuint get_handle() const
47     {
48         return m_handle;
49     }
50     void set_handle(GLuint handle)
51     {
52         m_handle = handle;
53     }
54
55     bool is_valid() const
56     {
57         return m_valid;
58     }
59     bool is_generating() const
60     {
61         return m_generating;
62     }
63
64     const dynamic_string &get_xfont_name() const
65     {
66         return m_xfont_name;
67     }
68     int get_xfont_glyph() const
69     {
70         return m_xfont_glyph;
71     }
72     bool is_xfont() const
73     {
74         return m_xfont;
75     }
76
77     const vogl_trace_packet_array &get_packets() const
78     {
79         return m_packets;
80     }
81     vogl_trace_packet_array &get_packets()
82     {
83         return m_packets;
84     }
85
86     void init_xfont(const char *pName, int glyph);
87
88     void begin_gen();
89     void end_gen();
90
91     bool serialize(json_node &node, vogl_blob_manager &blob_manager, const vogl_ctypes *pCtypes) const;
92     bool deserialize(const json_node &node, const vogl_blob_manager &blob_manager, const vogl_ctypes *pCtypes);
93
94 private:
95     GLuint m_handle;
96     vogl_trace_packet_array m_packets;
97
98     dynamic_string m_xfont_name;
99     int m_xfont_glyph;
100     bool m_xfont;
101     bool m_generating;
102     bool m_valid;
103 };
104
105 typedef vogl::map<GLuint, vogl_display_list> vogl_display_list_map;
106
107 //----------------------------------------------------------------------------------------------------------------------
108 // class vogl_display_list_state
109 //----------------------------------------------------------------------------------------------------------------------
110 class vogl_display_list_state
111 {
112 public:
113     vogl_display_list_state();
114     vogl_display_list_state(const vogl_display_list_state &other);
115     ~vogl_display_list_state();
116
117     vogl_display_list_state &operator=(const vogl_display_list_state &rhs);
118
119     void clear();
120
121     uint size() const
122     {
123         return m_display_lists.size();
124     }
125
126     vogl_display_list *find_list(GLuint list)
127     {
128         return m_display_lists.find_value(list);
129     }
130
131     const vogl_display_list_map &get_display_list_map() const
132     {
133         return m_display_lists;
134     }
135     vogl_display_list_map &get_display_list_map()
136     {
137         return m_display_lists;
138     }
139
140     bool remap_handles(vogl_handle_remapper &remapper);
141
142     bool serialize(json_node &node, vogl_blob_manager &blob_manager, const vogl_ctypes *pCtypes) const;
143     bool deserialize(const json_node &node, const vogl_blob_manager &blob_manager, const vogl_ctypes *pCtypes);
144
145     bool define_list(GLuint trace_handle, GLuint replay_handle, const vogl_display_list &list);
146
147     bool gen_lists(GLuint first, GLsizei n, GLuint *pObject_handles = NULL);
148
149     bool del_lists(GLuint first, GLsizei n);
150
151     bool glx_font(const char *pFont, int first, int count, int listBase);
152
153     static bool is_call_listable(gl_entrypoint_id_t func, const vogl_trace_packet &packet);
154
155     void new_list(GLuint trace_handle, GLuint replay_handle);
156
157     bool add_packet_to_list(GLuint handle, gl_entrypoint_id_t func, const vogl_trace_packet &packet);
158
159     bool end_list(GLuint trace_handle);
160
161     typedef void (*pBind_callback_func_ptr)(vogl_namespace_t handle_namespace, GLenum target, GLuint handle, void *pOpaque);
162
163     bool parse_list_and_update_shadows(GLuint handle, pBind_callback_func_ptr pBind_callback, void *pBind_callback_opaque);
164     bool parse_lists_and_update_shadows(GLsizei n, GLenum type, const GLvoid *lists, pBind_callback_func_ptr pBind_callback, void *pBind_callback_opaque);
165
166 private:
167     vogl_display_list_map m_display_lists;
168 };
169
170 #endif // VOGL_DISPLAY_LIST_STATE_H