~freenx-team/nx-x11/nxcomp-upstream

« back to all changes in this revision

Viewing changes to SetClipRectangles.h

  • Committer: Marcelo Boveto Shima
  • Date: 2009-03-28 22:24:56 UTC
  • Revision ID: mshima@ufserv-20090328222456-rdtaq3oedfyq890c
Import nxcomp 3.3.0-3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**************************************************************************/
 
2
/*                                                                        */
 
3
/* Copyright (c) 2001, 2007 NoMachine, http://www.nomachine.com/.         */
 
4
/*                                                                        */
 
5
/* NXCOMP, NX protocol compression and NX extensions to this software     */
 
6
/* are copyright of NoMachine. Redistribution and use of the present      */
 
7
/* software is allowed according to terms specified in the file LICENSE   */
 
8
/* which comes in the source distribution.                                */
 
9
/*                                                                        */
 
10
/* Check http://www.nomachine.com/licensing.html for applicability.       */
 
11
/*                                                                        */
 
12
/* NX and NoMachine are trademarks of NoMachine S.r.l.                    */
 
13
/*                                                                        */
 
14
/* All rights reserved.                                                   */
 
15
/*                                                                        */
 
16
/**************************************************************************/
 
17
 
 
18
#ifndef SetClipRectangles_H
 
19
#define SetClipRectangles_H
 
20
 
 
21
#include "Message.h"
 
22
 
 
23
//
 
24
// Set the verbosity level.
 
25
//
 
26
 
 
27
#define PANIC
 
28
#define WARNING
 
29
#undef  TEST
 
30
#undef  DEBUG
 
31
#undef  DUMP
 
32
 
 
33
//
 
34
// Set default values.
 
35
//
 
36
 
 
37
#define SETCLIPRECTANGLES_ENABLE_CACHE               1
 
38
#define SETCLIPRECTANGLES_ENABLE_DATA                0
 
39
#define SETCLIPRECTANGLES_ENABLE_SPLIT               0
 
40
#define SETCLIPRECTANGLES_ENABLE_COMPRESS            0
 
41
 
 
42
#define SETCLIPRECTANGLES_DATA_LIMIT                 2048
 
43
#define SETCLIPRECTANGLES_DATA_OFFSET                12
 
44
 
 
45
#define SETCLIPRECTANGLES_CACHE_SLOTS                3000
 
46
#define SETCLIPRECTANGLES_CACHE_THRESHOLD            3
 
47
#define SETCLIPRECTANGLES_CACHE_LOWER_THRESHOLD      1
 
48
 
 
49
//
 
50
// The message class.
 
51
//
 
52
 
 
53
class SetClipRectanglesMessage : public Message
 
54
{
 
55
  friend class SetClipRectanglesStore;
 
56
 
 
57
  public:
 
58
 
 
59
  SetClipRectanglesMessage()
 
60
  {
 
61
  }
 
62
 
 
63
  ~SetClipRectanglesMessage()
 
64
  {
 
65
  }
 
66
 
 
67
  //
 
68
  // Put here the fields which constitute 
 
69
  // the 'identity' part of the message.
 
70
  //
 
71
 
 
72
  private:
 
73
 
 
74
  unsigned char  ordering;
 
75
  unsigned int   gcontext;
 
76
  unsigned short x_origin;
 
77
  unsigned short y_origin;
 
78
};
 
79
 
 
80
class SetClipRectanglesStore : public MessageStore
 
81
{
 
82
  //
 
83
  // Constructors and destructors.
 
84
  //
 
85
 
 
86
  public:
 
87
 
 
88
  SetClipRectanglesStore() : MessageStore()
 
89
  {
 
90
    enableCache    = SETCLIPRECTANGLES_ENABLE_CACHE;
 
91
    enableData     = SETCLIPRECTANGLES_ENABLE_DATA;
 
92
    enableSplit    = SETCLIPRECTANGLES_ENABLE_SPLIT;
 
93
    enableCompress = SETCLIPRECTANGLES_ENABLE_COMPRESS;
 
94
 
 
95
    dataLimit  = SETCLIPRECTANGLES_DATA_LIMIT;
 
96
    dataOffset = SETCLIPRECTANGLES_DATA_OFFSET;
 
97
 
 
98
    cacheSlots          = SETCLIPRECTANGLES_CACHE_SLOTS;
 
99
    cacheThreshold      = SETCLIPRECTANGLES_CACHE_THRESHOLD;
 
100
    cacheLowerThreshold = SETCLIPRECTANGLES_CACHE_LOWER_THRESHOLD;
 
101
 
 
102
    messages_ -> resize(cacheSlots);
 
103
 
 
104
    for (T_messages::iterator i = messages_ -> begin();
 
105
             i < messages_ -> end(); i++)
 
106
    {
 
107
      *i = NULL;
 
108
    }
 
109
 
 
110
    temporary_ = NULL;
 
111
  }
 
112
 
 
113
  virtual ~SetClipRectanglesStore()
 
114
  {
 
115
    for (T_messages::iterator i = messages_ -> begin();
 
116
             i < messages_ -> end(); i++)
 
117
    {
 
118
      destroy(*i);
 
119
    }
 
120
 
 
121
    destroy(temporary_);
 
122
  }
 
123
 
 
124
  virtual const char *name() const
 
125
  {
 
126
    return "SetClipRectangles";
 
127
  }
 
128
 
 
129
  virtual unsigned char opcode() const
 
130
  {
 
131
    return X_SetClipRectangles;
 
132
  }
 
133
 
 
134
  virtual unsigned int storage() const
 
135
  {
 
136
    return sizeof(SetClipRectanglesMessage);
 
137
  }
 
138
 
 
139
  //
 
140
  // Message handling methods.
 
141
  //
 
142
 
 
143
  public:
 
144
 
 
145
  virtual Message *create() const
 
146
  {
 
147
    return new SetClipRectanglesMessage();
 
148
  }
 
149
 
 
150
  virtual Message *create(const Message &message) const
 
151
  {
 
152
    return new SetClipRectanglesMessage((const SetClipRectanglesMessage &) message);
 
153
  }
 
154
 
 
155
  virtual void destroy(Message *message) const
 
156
  {
 
157
    delete (SetClipRectanglesMessage *) message;
 
158
  }
 
159
 
 
160
  virtual int parseIdentity(Message *message, const unsigned char *buffer,
 
161
                                unsigned int size, int bigEndian) const;
 
162
 
 
163
  virtual int unparseIdentity(const Message *message, unsigned char *buffer,
 
164
                                  unsigned int size, int bigEndian) const;
 
165
 
 
166
  virtual void updateIdentity(EncodeBuffer &encodeBuffer, const Message *message,
 
167
                                  const Message *cachedMessage,
 
168
                                      ChannelCache *channelCache) const;
 
169
 
 
170
  virtual void updateIdentity(DecodeBuffer &decodeBuffer, const Message *message,
 
171
                                  ChannelCache *channelCache) const;
 
172
 
 
173
  virtual void identityChecksum(const Message *message, const unsigned char *buffer,
 
174
                                    unsigned int size, int bigEndian) const;
 
175
 
 
176
  virtual void dumpIdentity(const Message *message) const;
 
177
};
 
178
 
 
179
#endif /* SetClipRectangles_H */