+void gRC::submit(const gOpcode &o)
+{
+ while(1)
+ {
+#ifndef SYNC_PAINT
+ pthread_mutex_lock(&mutex);
+#endif
+ int tmp=wp+1;
+ if ( tmp == MAXSIZE )
+ tmp=0;
+ if ( tmp == rp )
+ {
+#ifndef SYNC_PAINT
+ pthread_mutex_unlock(&mutex);
+#else
+ thread();
+#endif
+ //printf("render buffer full...\n");
+ //fflush(stdout);
+ usleep(1000); // wait 1 msec
+ continue;
+ }
+ int free=rp-wp;
+ if ( free <= 0 )
+ free+=MAXSIZE;
+ queue[wp++]=o;
+ if ( wp == MAXSIZE )
+ wp = 0;
+ if (o.opcode==gOpcode::flush||o.opcode==gOpcode::shutdown||o.opcode==gOpcode::notify)
+#ifndef SYNC_PAINT
+ pthread_cond_signal(&cond); // wakeup gdi thread
+ pthread_mutex_unlock(&mutex);
+#else
+ thread(); // paint
+#endif
+ break;
+ }
+}
+