1
/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
3
Copyright (C) 2009 Red Hat, Inc.
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Lesser General Public
7
License as published by the Free Software Foundation; either
8
version 2.1 of the License, or (at your option) any later version.
10
This library is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
Lesser General Public License for more details.
15
You should have received a copy of the GNU Lesser General Public
16
License along with this library; if not, see <http://www.gnu.org/licenses/>.
19
#ifndef _H_DISPLAY_CHANNEL
20
#define _H_DISPLAY_CHANNEL
25
#include "red_channel.h"
27
#include "screen_layer.h"
28
#include "process_loop.h"
30
#include "red_pixmap_gl.h"
32
#include "glz_decoder_window.h"
41
class StreamsTrigger: public EventSources::Trigger {
43
StreamsTrigger(DisplayChannel& channel);
45
virtual void on_event();
48
DisplayChannel& _channel;
52
class GLInterruptRecreate: public EventSources::Trigger {
54
GLInterruptRecreate(DisplayChannel& channel);
55
virtual void trigger();
56
virtual void on_event();
59
DisplayChannel& _channel;
65
class InterruptUpdate: public EventSources::Trigger {
67
InterruptUpdate(DisplayChannel& channel);
69
virtual void on_event();
72
DisplayChannel& _channel;
75
class StreamsTimer: public Timer {
77
StreamsTimer(DisplayChannel& channel);
78
virtual void response(AbstractProcessLoop& events_loop);
80
DisplayChannel& _channel;
83
class DisplaySurfacesManger {
85
void add_surface(int surface_id, SpiceCanvas *surface);
86
void del_surface(int surface_id);
87
void add_canvas(int surface_id, Canvas *canvas);
88
void del_canvas(int surface_id);
90
CSurfaces& get_surfaces();
91
bool is_present_canvas(int surface_id);
92
Canvas* get_canvas(int surface_id);
98
class DisplayChannel: public RedChannel, public ScreenLayer {
100
DisplayChannel(RedClient& client, uint32_t id,
101
PixmapCache& pixmap_cache, GlzDecoderWindow& glz_window);
102
virtual ~DisplayChannel();
104
virtual void copy_pixels(const QRegion& dest_region, RedDrawable& dest_dc);
105
virtual void copy_pixels(const QRegion& dest_region, const PixmapHeader &dest);
107
virtual void recreate_ogl_context();
108
virtual void recreate_ogl_context_interrupt();
109
virtual void pre_migrate();
110
virtual void post_migrate();
112
virtual void update_interrupt();
113
void set_cursor(CursorData* cursor);
115
void set_capture_mode(bool on);
117
virtual bool pointer_test(int x, int y);
118
virtual void on_pointer_enter(int x, int y, unsigned int buttons_state);
119
virtual void on_pointer_motion(int x, int y, unsigned int buttons_state);
120
virtual void on_pointer_leave();
121
virtual void on_mouse_button_press(int button, int buttons_state);
122
virtual void on_mouse_button_release(int button, int buttons_state);
124
void attach_inputs(InputsChannel* inputs_channel);
125
void detach_inputs();
127
static ChannelFactory& Factory();
130
virtual void on_connect();
131
virtual void on_disconnect();
134
void set_draw_handlers();
135
void clear_draw_handlers();
136
bool create_sw_canvas(int surface_id, int width, int height, uint32_t format);
138
bool create_ogl_canvas(int surface_id, int width, int height, uint32_t format, bool recreate,
139
RenderType rendertype);
142
bool create_gdi_canvas(int surface_id, int width, int height, uint32_t format);
144
void destroy_canvas(int surface_id);
145
void create_canvas(int surface_id, const std::vector<int>& canvas_type, int width, int height,
147
void destroy_strams();
148
void update_cursor();
150
void create_primary_surface(int width, int height, uint32_t format);
151
void create_surface(int surface_id, int width, int height, uint32_t format);
152
void destroy_primary_surface();
153
void destroy_surface(int surface_id);
155
void handle_mode(RedPeer::InMessage* message);
156
void handle_mark(RedPeer::InMessage* message);
157
void handle_reset(RedPeer::InMessage* message);
159
void handle_inval_list(RedPeer::InMessage* message);
160
void handle_inval_all_pixmaps(RedPeer::InMessage* message);
161
void handle_inval_palette(RedPeer::InMessage* message);
162
void handle_inval_all_palettes(RedPeer::InMessage* message);
163
void handle_copy_bits(RedPeer::InMessage* message);
164
void handle_stream_create(RedPeer::InMessage* message);
165
void handle_stream_data(RedPeer::InMessage* message);
166
void handle_stream_clip(RedPeer::InMessage* message);
167
void handle_stream_destroy(RedPeer::InMessage* message);
168
void handle_stream_destroy_all(RedPeer::InMessage* message);
170
void handle_surface_create(RedPeer::InMessage* message);
171
void handle_surface_destroy(RedPeer::InMessage* message);
173
void handle_draw_fill(RedPeer::InMessage* message);
174
void handle_draw_opaque(RedPeer::InMessage* message);
175
void handle_draw_copy(RedPeer::InMessage* message);
176
void handle_draw_blend(RedPeer::InMessage* message);
177
void handle_draw_blackness(RedPeer::InMessage* message);
178
void handle_draw_whiteness(RedPeer::InMessage* message);
179
void handle_draw_invers(RedPeer::InMessage* message);
180
void handle_draw_rop3(RedPeer::InMessage* message);
181
void handle_draw_stroke(RedPeer::InMessage* message);
182
void handle_draw_text(RedPeer::InMessage* message);
183
void handle_draw_transparent(RedPeer::InMessage* message);
184
void handle_draw_alpha_blend(RedPeer::InMessage* message);
186
void on_streams_trigger();
187
virtual void on_update_completion(uint64_t mark);
189
void activate_streams_timer();
190
void stream_update_request(uint32_t update_time);
193
static void set_clip_rects(const SpiceClip& clip, uint32_t& num_clip_rects, SpiceRect*& clip_rects);
195
DisplaySurfacesManger surfaces_mngr;
196
PixmapCache& _pixmap_cache;
197
PaletteCache _palette_cache;
198
GlzDecoderWindow& _glz_window;
204
RenderType _rendertype;
210
uint64_t _update_mark;
214
AutoRef<StreamsTimer> _streams_timer;
215
uint32_t _next_timer_time;
217
AutoRef<CursorData> _cursor;
218
bool _cursor_visibal;
219
bool _active_pointer;
220
bool _capture_mouse_mode;
221
InputsChannel* _inputs_channel;
223
SpicePoint _pointer_pos;
226
std::vector<VideoStream*> _streams;
227
VideoStream* _active_streams;
228
StreamsTrigger _streams_trigger;
230
GLInterruptRecreate _gl_interrupt_recreate;
232
InterruptUpdate _interrupt_update;
234
friend class SetModeEvent;
235
friend class CreatePrimarySurfaceEvent;
236
friend class DestroyPrimarySurfaceEvent;
237
friend class CreateSurfaceEvent;
238
friend class DestroySurfaceEvent;
239
friend class ActivateTimerEvent;
240
friend class VideoStream;
241
friend class StreamsTrigger;
242
friend class GLInterupt;
243
friend class StreamsTimer;
244
friend class AttachChannelsEvent;
245
friend class DetachChannelsEvent;