~ubuntu-branches/ubuntu/raring/virtualbox-ose/raring

« back to all changes in this revision

Viewing changes to src/VBox/GuestHost/OpenGL/include/cr_pack.h

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2011-01-30 23:27:25 UTC
  • mfrom: (0.3.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20110130232725-2ouajjd2ggdet0zd
Tags: 4.0.2-dfsg-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Add Apport hook.
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Drop *-source packages.
* Drop ubuntu-01-fix-build-gcc45.patch, fixed upstream.
* Drop ubuntu-02-as-needed.patch, added to the Debian package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
    int updateBBOX;
67
67
    int swapping;
68
68
    CRPackBuffer *currentBuffer;
 
69
    CRmutex mutex;
69
70
    char *file;  /**< for debugging only */
70
71
    int line;    /**< for debugging only */
71
72
};
72
73
 
73
74
 
74
75
extern DECLEXPORT(CRPackContext *) crPackNewContext(int swapping);
 
76
extern DECLEXPORT(void) crPackDeleteContext(CRPackContext *pc);
75
77
extern DECLEXPORT(void) crPackSetContext( CRPackContext *pc );
76
78
extern DECLEXPORT(CRPackContext *) crPackGetContext( void );
77
79
 
137
139
 
138
140
#ifdef CHROMIUM_THREADSAFE
139
141
extern CRtsd _PackerTSD;
140
 
#define GET_PACKER_CONTEXT(C) CRPackContext *C = (CRPackContext *) crGetTSD(&_PackerTSD)
 
142
#define CR_GET_PACKER_CONTEXT(C) CRPackContext *C = (CRPackContext *) crGetTSD(&_PackerTSD)
 
143
#define CR_LOCK_PACKER_CONTEXT(PC) crLockMutex(&((PC)->mutex))
 
144
#define CR_UNLOCK_PACKER_CONTEXT(PC) crUnlockMutex(&((PC)->mutex))
141
145
#else
142
146
extern DLLDATA(CRPackContext) cr_packer_globals;
143
 
#define GET_PACKER_CONTEXT(C) CRPackContext *C = &cr_packer_globals
 
147
#define CR_GET_PACKER_CONTEXT(C) CRPackContext *C = &cr_packer_globals
 
148
#define CR_LOCK_PACKER_CONTEXT(PC)
 
149
#define CR_UNLOCK_PACKER_CONTEXT(PC)
144
150
#endif
145
151
 
146
152
 
188
194
 * Alloc space for a message of 'len' bytes (plus 1 opcode).
189
195
 * Only flush if buffer is full.
190
196
 */
191
 
#define GET_BUFFERED_POINTER_NO_BEGINEND_FLUSH( pc, len )   \
192
 
  do {                              \
193
 
    THREADASSERT( pc );                     \
194
 
    CRASSERT( pc->currentBuffer );              \
195
 
    if ( !crPackCanHoldOpcode( pc, 1, (len) ) ) {       \
196
 
      pc->Flush( pc->flush_arg );               \
197
 
      CRASSERT(crPackCanHoldOpcode( pc, 1, (len) ) );       \
198
 
    }                               \
199
 
    data_ptr = pc->buffer.data_current;             \
200
 
    pc->buffer.data_current += (len);               \
 
197
#define CR_GET_BUFFERED_POINTER_NO_BEGINEND_FLUSH(pc, len, lock)    \
 
198
  do {                                                              \
 
199
    THREADASSERT( pc );                                             \
 
200
    if (lock) CR_LOCK_PACKER_CONTEXT(pc);                           \
 
201
    CRASSERT( pc->currentBuffer );                                  \
 
202
    if ( !crPackCanHoldOpcode( pc, 1, (len) ) ) {                   \
 
203
      pc->Flush( pc->flush_arg );                                   \
 
204
      CRASSERT(crPackCanHoldOpcode( pc, 1, (len) ) );               \
 
205
    }                                                               \
 
206
    data_ptr = pc->buffer.data_current;                             \
 
207
    pc->buffer.data_current += (len);                               \
201
208
  } while (0)
202
209
 
203
210
 
205
212
 * As above, flush if the buffer contains vertex data and we're
206
213
 * no longer inside glBegin/glEnd.
207
214
 */
208
 
#define GET_BUFFERED_POINTER( pc, len )                 \
209
 
  do {                                  \
210
 
    CRASSERT( pc->currentBuffer );                  \
211
 
    if ( pc->buffer.holds_BeginEnd && !pc->buffer.in_BeginEnd ) {   \
212
 
      pc->Flush( pc->flush_arg );                   \
213
 
      pc->buffer.holds_BeginEnd = 0;                    \
214
 
    }                                   \
215
 
    GET_BUFFERED_POINTER_NO_BEGINEND_FLUSH( pc, len );          \
 
215
#define CR_GET_BUFFERED_POINTER( pc, len )                          \
 
216
  do {                                                              \
 
217
    CR_LOCK_PACKER_CONTEXT(pc);                                     \
 
218
    CRASSERT( pc->currentBuffer );                                  \
 
219
    if ( pc->buffer.holds_BeginEnd && !pc->buffer.in_BeginEnd ) {   \
 
220
      pc->Flush( pc->flush_arg );                                   \
 
221
      pc->buffer.holds_BeginEnd = 0;                                \
 
222
    }                                                               \
 
223
    CR_GET_BUFFERED_POINTER_NO_BEGINEND_FLUSH( pc, len, GL_FALSE ); \
 
224
  } while (0)
 
225
 
 
226
/**
 
227
 * As above, but without lock.
 
228
 */
 
229
#define CR_GET_BUFFERED_POINTER_NOLOCK( pc, len )                   \
 
230
  do {                                                              \
 
231
    CRASSERT( pc->currentBuffer );                                  \
 
232
    if ( pc->buffer.holds_BeginEnd && !pc->buffer.in_BeginEnd ) {   \
 
233
      pc->Flush( pc->flush_arg );                                   \
 
234
      pc->buffer.holds_BeginEnd = 0;                                \
 
235
    }                                                               \
 
236
    CR_GET_BUFFERED_POINTER_NO_BEGINEND_FLUSH( pc, len, GL_FALSE ); \
216
237
  } while (0)
217
238
 
218
239
 
219
240
/**
220
241
 * As above, but for vertex data between glBegin/End (counts vertices).
221
242
 */
222
 
#define GET_BUFFERED_COUNT_POINTER( pc, len )       \
223
 
  do {                          \
224
 
    CRASSERT( pc->currentBuffer );          \
225
 
    if ( !crPackCanHoldOpcode( pc, 1, (len) ) ) {   \
226
 
      pc->Flush( pc->flush_arg );           \
 
243
#define CR_GET_BUFFERED_COUNT_POINTER( pc, len )        \
 
244
  do {                                                  \
 
245
    CR_LOCK_PACKER_CONTEXT(pc);                         \
 
246
    CRASSERT( pc->currentBuffer );                      \
 
247
    if ( !crPackCanHoldOpcode( pc, 1, (len) ) ) {       \
 
248
      pc->Flush( pc->flush_arg );                       \
227
249
      CRASSERT( crPackCanHoldOpcode( pc, 1, (len) ) );  \
228
 
    }                           \
229
 
    data_ptr = pc->buffer.data_current;         \
230
 
    pc->current.vtx_count++;                \
231
 
    pc->buffer.data_current += (len);           \
 
250
    }                                                   \
 
251
    data_ptr = pc->buffer.data_current;                 \
 
252
    pc->current.vtx_count++;                            \
 
253
    pc->buffer.data_current += (len);                   \
232
254
  } while (0)
233
255
 
234
256
 
236
258
 * Allocate space for a msg/command that has no arguments, such
237
259
 * as glFinish().
238
260
 */
239
 
#define GET_BUFFERED_POINTER_NO_ARGS( pc ) \
240
 
  GET_BUFFERED_POINTER( pc, 4 );  \
 
261
#define CR_GET_BUFFERED_POINTER_NO_ARGS( pc )  \
 
262
  CR_GET_BUFFERED_POINTER( pc, 4 );            \
241
263
  WRITE_DATA( 0, GLuint, 0xdeadbeef )
242
264
 
243
265
#define WRITE_DATA( offset, type, data ) \