// Reallocate uncompressed buffer with or without alpha int VFrame::reallocate( unsigned char *data, int shmid, long y_offset, long u_offset, long v_offset, int w, int h, int color_model, long bytes_per_line) { // if(shmid == 0) printf("VFrame::reallocate %d shmid=%d\n", __LINE__, shmid); clear_objects(0); // reset_parameters(0); allocate_data(data, shmid, y_offset, u_offset, v_offset, w, h, color_model, bytes_per_line); return 0; }
int BC_Bitmap::initialize(BC_WindowBase *parent_window, int w, int h, int color_model, int use_shm) { this->parent_window = parent_window; this->top_level = parent_window->top_level; this->w = w; this->h = h; this->color_model = color_model; this->use_shm = use_shm ? parent_window->get_resources()->use_shm : 0; this->bg_color = parent_window->bg_color; ximage[0] = 0; xv_image[0] = 0; data[0] = 0; last_pixmap_used = 0; last_pixmap = 0; current_ringbuffer = 0; // Set ring buffers based on total memory used. // The program icon must use multiple buffers but larger bitmaps may not fit // in memory. int pixelsize = cmodel_calculate_pixelsize(color_model); int buffer_size = w * h * pixelsize; if(buffer_size < 0x40000) ring_buffers = 4; else ring_buffers = 1; allocate_data(); return 0; }
int BC_Bitmap::initialize(BC_WindowBase *parent_window, int w, int h, int color_model, int use_shm) { BC_Resources *resources = parent_window->get_resources(); this->parent_window = parent_window; this->top_level = parent_window->top_level; this->xv_portid = resources->use_xvideo ? top_level->xvideo_port_id : -1; this->w = w; this->h = h; this->color_model = color_model; this->use_shm = !use_shm ? 0 : need_shm(); this->shm_reply = this->use_shm && resources->shm_reply ? 1 : 0; // dont use shm for less than one page this->bg_color = parent_window->bg_color; if( !this->avail_lock ) this->avail_lock = new Mutex("BC_Bitmap::avail_lock"); else this->avail_lock->reset(); this->buffers = 0; this->last_pixmap_used = 0; this->last_pixmap = 0; this->active_bfr = 0; this->buffer_count = 0; this->max_buffer_count = 0; this->active_buffers = 0; allocate_data(); return 0; }
/****************************************************************************** main --- main routine ******************************************************************************/ int main() { int imax, jmax, kmax; para.geom = &geom; para.outp = &outp1; para.prob = &prob; para.mytime = &mytime; para.bc = &bc; para.solv = &solv; initial(¶); imax = geom.imax, jmax = geom.jmax, kmax = geom.kmax; if(!allocate_data( )) exit ( 1 ); clear_data(¶, var); set_grid(¶, var); set_bnd_vel(¶, var, VY, v); write_data1(¶, var, "grid"); FFD_solver(¶, var); free_data(var); getchar(); exit ( 0 ); } // End of main( )
static void expand_on_mouse_click (void) { int ok_mouse; MEVENT event; ok_mouse = getmouse (&event); if (!conf.mouse_support || ok_mouse != OK) return; if (event.bstate & BUTTON1_CLICKED) { /* ignore header/footer clicks */ if (event.y < MAX_HEIGHT_HEADER || event.y == LINES - 1) return; if (set_module_from_mouse_event (&gscroll, dash, event.y)) return; reset_scroll_offsets (&gscroll); gscroll.expanded = 1; free_holder_by_module (&holder, gscroll.current); free_dashboard (dash); allocate_holder_by_module (gscroll.current); allocate_data (); render_screens (); } }
VFrame::VFrame(int w, int h, int color_model, long bytes_per_line) { reset_parameters(1); params = new BC_Hash; allocate_data(data, -1, 0, 0, 0, w, h, color_model, bytes_per_line); }
int main(int argc, char **argv) { glutInit(&argc, argv); if (argc != 1 && argc != 7) { fprintf(stderr, "usage : %s N dt diff visc force source\n", argv[0]); fprintf(stderr, "where:\n");\ fprintf(stderr, "\t N : grid resolution\n"); fprintf(stderr, "\t dt : time step\n"); fprintf(stderr, "\t diff : diffusion rate of the density\n"); fprintf(stderr, "\t visc : viscosity of the fluid\n"); fprintf(stderr, "\t force : scales the mouse movement that generate a force\n"); fprintf(stderr, "\t source : amount of density that will be deposited\n"); exit(1); } if (argc == 1) { N = 64; dt = 0.1f; diff = 0.0f; visc = 0.0f; force = 5.0f; source = 100.0f; fprintf(stderr, "Using defaults : N=%d dt=%g diff=%g visc=%g force = %g source=%g\n", N, dt, diff, visc, force, source); } else { N = atoi(argv[1]); dt = atof(argv[2]); diff = atof(argv[3]); visc = atof(argv[4]); force = atof(argv[5]); source = atof(argv[6]); } printf("\n\nHow to use this demo:\n\n"); printf("\t Add densities with the right mouse button\n"); printf("\t Add velocities with the left mouse button and dragging the mouse\n"); printf("\t Toggle density/velocity display with the 'v' key\n"); printf("\t Clear the simulation by pressing the 'c' key\n"); printf("\t Toggle particle display with the 'p' key ('P' resets particles)\n"); printf("\t 's' creates a new particle system connected by springs (cloth)\n"); printf("\t 'S' creates a new particle system without springs\n"); printf("\t '@' toggles vorticity confinement (It looks like a swirl :)\n"); printf("\t Space pauses the simulation\n"); printf("\t Quit by pressing the 'q' key\n"); dvel = 0; dpar = 0; if (!allocate_data()) exit(1); clear_data(); win_x = 512; win_y = 512; open_glut_window(); glutMainLoop(); exit(0); }
VFrame::VFrame(unsigned char *data, int shmid, int w, int h, int color_model, long bytes_per_line) { reset_parameters(1); params = new BC_Hash; allocate_data(data, shmid, 0, 0, 0, w, h, color_model, bytes_per_line); }
VFrame::VFrame(VFrame &frame) { reset_parameters(1); params = new BC_Hash; allocate_data(0, 0, 0, 0, frame.w, frame.h, frame.color_model, frame.bytes_per_line); memcpy(data, frame.data, bytes_per_line * h); copy_stacks(&frame); }
void CommSparse::allocate_buffers(const std::vector<int>& send_procs, const std::vector<int>& recv_procs) { m_send.resize(m_size); m_recv.resize(m_size); m_send_procs = send_procs; m_recv_procs = recv_procs; if (m_size > 1) { comm_recv_msg_sizes(m_comm , send_procs, recv_procs, m_send, m_recv); allocate_data(m_send, m_send_data); allocate_data(m_recv, m_recv_data); } else { m_recv = m_send; m_recv_data = m_send_data; } }
BC_Capture::BC_Capture(int w, int h, char *display_path) { this->w = w; this->h = h; data = 0; use_shm = 1; init_window(display_path); allocate_data(); }
/* collapse the current expanded module */ static void collapse_current_module (void) { if (scrolling.expanded) { scrolling.expanded = 0; reset_scroll_offsets (&scrolling); free_dashboard (dash); allocate_data (); render_screens (); } }
/* collapse the current expanded module */ static void collapse_current_module (void) { if (!gscroll.expanded) return; gscroll.expanded = 0; reset_scroll_offsets (&gscroll); free_dashboard (dash); allocate_data (); render_screens (); }
void CommSparse::allocate_buffers() { m_send.resize(m_size); m_recv.resize(m_size); if (m_size > 1) { comm_recv_procs_and_msg_sizes(m_comm, m_send, m_recv, m_send_procs, m_recv_procs); allocate_data(m_send, m_send_data); allocate_data(m_recv, m_recv_data); } else { allocate_data(m_send, m_send_data); m_recv = m_send; m_recv_data = m_send_data; if (m_send[0].capacity() > 0) { m_send_procs.resize(1); m_send_procs[0] = 0; m_recv_procs = m_send_procs; } } }
static void search_next_match (int search) { pthread_mutex_lock (&gdns_thread.mutex); search = perform_next_find (holder, &gscroll); pthread_mutex_unlock (&gdns_thread.mutex); if (search != 0) return; free_dashboard (dash); allocate_data (); render_screens (); }
static void render_sort_dialog (void) { load_sort_win (main_win, gscroll.current, &module_sort[gscroll.current]); pthread_mutex_lock (&gdns_thread.mutex); free_holder (&holder); pthread_cond_broadcast (&gdns_thread.not_empty); pthread_mutex_unlock (&gdns_thread.mutex); free_dashboard (dash); allocate_holder (); allocate_data (); render_screens (); }
static void curses_output (void) { allocate_data (); if (!conf.skip_term_resolver) gdns_thread_create (); render_screens (); get_keys (); /* restore tty modes and reset * terminal into non-visual mode */ endwin (); }
void DiskBackedBlockMap::read_block_from_disk(ServerBlock* block, const BlockId& block_id, size_t block_size) { /** Allocates space for a block, reads block from disk * into newly allocated space, sets the in_memory flag, * inserts into block_map_ if needed */ // block = allocate_block(block_size, false); block->set_data(allocate_data(block->size(), false)); // server_timer_.start_timer(current_line(), ServerTimer::READTIME); disk_backed_arrays_io_.read_block_from_disk(block_id, block); // server_timer_.pause_timer(current_line(), ServerTimer::READTIME); block->disk_state_.set_in_memory(); }
static void render_search_dialog (int search) { if (render_find_dialog (main_win, &gscroll)) return; pthread_mutex_lock (&gdns_thread.mutex); search = perform_next_find (holder, &gscroll); pthread_mutex_unlock (&gdns_thread.mutex); if (search != 0) return; free_dashboard (dash); allocate_data (); render_screens (); }
VFrame::VFrame(int w, int h, int color_model) { reset_parameters(1); params = new BC_Hash; allocate_data(data, /* shmid = -1, */ 0, 0, 0, w, h, color_model, -1); }
VFrame::VFrame(BC_Bitmap *bitmap, int w, int h, int color_model, long bytes_per_line) { reset_parameters(1); params = new BC_Hash; int shmid = 0; unsigned char *data = 0; if( bitmap->is_shared() ) shmid = bitmap->get_shmid(); else data = bitmap->get_data(); allocate_data(data, shmid, bitmap->get_y_offset(), bitmap->get_u_offset(), bitmap->get_v_offset(), w, h, color_model, bytes_per_line); }
// The idea of Dynamic Attach on Windows is to inject a thread into remote JVM // that calls JVM_EnqueueOperation() function exported by HotSpot DLL static int inject_thread(int pid, char* pipeName, int argc, char** argv) { HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, (DWORD)pid); if (hProcess == NULL && GetLastError() == ERROR_ACCESS_DENIED) { if (!enable_debug_privileges()) { print_error("Not enough privileges", GetLastError()); return 0; } hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, (DWORD)pid); } if (hProcess == NULL) { print_error("Could not open process", GetLastError()); return 0; } LPTHREAD_START_ROUTINE code = allocate_code(hProcess); LPVOID data = code != NULL ? allocate_data(hProcess, pipeName, argc, argv) : NULL; if (data == NULL) { print_error("Could not allocate memory in target process", GetLastError()); CloseHandle(hProcess); return 0; } int success = 1; HANDLE hThread = CreateRemoteThread(hProcess, NULL, 0, code, data, 0, NULL); if (hThread == NULL) { print_error("Could not create remote thread", GetLastError()); success = 0; } else { printf("Connected to remote process\n"); WaitForSingleObject(hThread, INFINITE); DWORD exitCode; GetExitCodeThread(hThread, &exitCode); if (exitCode != 0) { print_error("Attach is not supported by the target process", exitCode); success = 0; } CloseHandle(hThread); } VirtualFreeEx(hProcess, code, 0, MEM_RELEASE); VirtualFreeEx(hProcess, data, 0, MEM_RELEASE); CloseHandle(hProcess); return success; }
void setup() { ofSetFrameRate(60); ofSetVerticalSync(true); dw=ofGetScreenWidth(); dh=ofGetScreenHeight(); ofDisableArbTex(); fbo.allocate(dw,dh); shader.load("shaders/fluid.vert","shaders/fluid.frag"); camera.setFarClip(100000); camera.setNearClip(.1); if ( !allocate_data () ){ cout<<"error allocate!"<<endl; exit(); } clear_data (); gui.setup(); gui.setPosition(ofPoint(10,10)); gui.add(size_cube.setup("size box", 100.0f,0.0f,255.0f)); gui.add(dvel.setup("draw velocity", true)); gui.add(dden.setup("draw density", false)); gui.add(TaddSource.setup("add source",false)); gui.add(Bclear.setup("clear source",false)); gui.add(addX.setup("add x",false)); gui.add(addY.setup("add y",false)); gui.add(addZ.setup("add z",false)); gui.add(dt.setup("time delta", 0.9f,0.0f,25.0f)); gui.add(diff.setup("diffuse", 0.0f,0.0f,25.0f)); gui.add(visc.setup("viscosity", 0.0f,0.0f,25.0f)); gui.add(force.setup("add force",30.0f,0.0f,60.0f)); gui.add(source.setup("density", 200.0f,0.0f,600.0f)); gui.add(source_alpha.setup("alpha",0.05,0.0,1.0)); gui.add(drawAbstacle.setup("draw abstacle",false)); gui.add(drawAxis.setup("draw Axis",true)); gui.add(sourcePosX.setup("source posX", 0,-10,SIZE)); gui.add(sourcePosY.setup("source posY", 0,-10,SIZE)); gui.add(sourcePosZ.setup("source posZ", 0,-10,SIZE)); }
static void expand_current_module (void) { if (gscroll.expanded && gscroll.current == HOSTS) { load_ip_agent_list (); return; } if (gscroll.expanded) return; reset_scroll_offsets (&gscroll); gscroll.expanded = 1; free_holder_by_module (&holder, gscroll.current); free_dashboard (dash); allocate_holder_by_module (gscroll.current); allocate_data (); }
VFrame::VFrame(unsigned char *data, long y_offset, long u_offset, long v_offset, int w, int h, int color_model, long bytes_per_line) { reset_parameters(1); params = new BC_Hash; allocate_data(data, y_offset, u_offset, v_offset, w, h, color_model, bytes_per_line); }
// Reallocate uncompressed buffer with or without alpha int VFrame::reallocate(unsigned char *data, long y_offset, long u_offset, long v_offset, int w, int h, int color_model, long bytes_per_line) { clear_objects(0); reset_parameters(0); allocate_data(data, y_offset, u_offset, v_offset, w, h, color_model, bytes_per_line); return 0; }
//----------------------------------------------------------------------------- StamFluidSolver::StamFluidSolver(int nx, int ny, float width, float height, std::string imagename):FluidGrid(nx,ny,width,height,imagename) { dt = mDesiredDT = 0.1f; //diff = 0.0001f; diff = 0.0f; visc = 0.001f; force = 100.0f; source = 1.0f; tempIncrement = 1.0f; dvel = 0; omx = mx = omy = my = 0; leftMouseButtonDown = false; rightMouseButtonDown = false; addVelocities = true; addSources = false; addObstacles = false; drawObstacles = false; drawVelocities = false; drawTemperature = false; mTextureMorph = true; mSimulateTemperature = false; addTemperature = false; mUseVorticityConfinement = true; mTemperatureBlend = 0.8f; display_scale = 100; lastUpdateTime = lastUpdateTimeForFrameRate = (float)-1.0e32; updateRate = mDesiredUpdateRate = 0.06f; mFPSCheckInterval = 0.5f; mAdjustFrameRate = true; mTargetFrameRate = 30; mGoodFPSChecks = 0; mNumFPSChecksRequired = 9; allocate_data(); clear_data(); }
static void perform_tail_follow (uint64_t * size1) { uint64_t size2 = 0; char buf[LINE_BUFFER]; FILE *fp = NULL; if (logger->piping) return; size2 = file_size (conf.ifile); /* file hasn't changed */ if (size2 == *size1) return; if (!(fp = fopen (conf.ifile, "r"))) FATAL ("Unable to read log file %s.", strerror (errno)); if (!fseeko (fp, *size1, SEEK_SET)) while (fgets (buf, LINE_BUFFER, fp) != NULL) parse_log (&logger, buf, -1); fclose (fp); *size1 = size2; pthread_mutex_lock (&gdns_thread.mutex); free_holder (&holder); pthread_cond_broadcast (&gdns_thread.not_empty); pthread_mutex_unlock (&gdns_thread.mutex); free_dashboard (dash); allocate_holder (); allocate_data (); term_size (main_win); render_screens (); usleep (200000); /* 0.2 seconds */ }
/////////////////////////////////////////////////////////////////////////////// ///\brief Main program /// /// Initialize the simualtion and read input data from SCI,run the simulations, /// and write the results /// /// ///\return void No return needed /////////////////////////////////////////////////////////////////////////////// int main() { para.geom = &geom; para.outp = &outp1; para.prob = &prob; para.mytime = &mytime; para.bc = &bc; para.solv = &solv; initial(¶); if(!read_max(¶, var)) { printf("no file"); exit(1); } if(!allocate_data( )) exit ( 1 ); clear_data(¶, var,BINDEX); if(!read_input(¶, var,BINDEX)) { printf("no file"); exit(1); } init_data(¶, var,BINDEX); mark_cell(¶, var,BINDEX); if(para.solv->read_file==1) read_data(¶,var); FFD_solver(¶, var,BINDEX); write_SCI(¶, var, "output"); free_data(var); free_index(BINDEX); //getchar(); exit ( 0 ); } // End of main( )
static void get_keys (void) { int search = 0; int c, quit = 1; uint64_t size1 = 0; if (!logger->piping) size1 = file_size (conf.ifile); while (quit) { c = wgetch (stdscr); switch (c) { case 'q': /* quit */ if (!gscroll.expanded) { quit = 0; break; } collapse_current_module (); break; case KEY_F (1): case '?': case 'h': load_help_popup (main_win); render_screens (); break; case 49: /* 1 */ /* reset expanded module */ set_module_to (&gscroll, VISITORS); break; case 50: /* 2 */ /* reset expanded module */ set_module_to (&gscroll, REQUESTS); break; case 51: /* 3 */ /* reset expanded module */ set_module_to (&gscroll, REQUESTS_STATIC); break; case 52: /* 4 */ /* reset expanded module */ set_module_to (&gscroll, NOT_FOUND); break; case 53: /* 5 */ /* reset expanded module */ set_module_to (&gscroll, HOSTS); break; case 54: /* 6 */ /* reset expanded module */ set_module_to (&gscroll, OS); break; case 55: /* 7 */ /* reset expanded module */ set_module_to (&gscroll, BROWSERS); break; case 56: /* 8 */ /* reset expanded module */ set_module_to (&gscroll, VISIT_TIMES); break; case 57: /* 9 */ /* reset expanded module */ set_module_to (&gscroll, REFERRERS); break; case 48: /* 0 */ /* reset expanded module */ set_module_to (&gscroll, REFERRING_SITES); break; case 33: /* shift + 1 */ /* reset expanded module */ set_module_to (&gscroll, KEYPHRASES); break; case 34: /* Shift + 2 */ /* reset expanded module */ #ifdef HAVE_LIBGEOIP set_module_to (&gscroll, GEO_LOCATION); #else set_module_to (&gscroll, STATUS_CODES); #endif break; #ifdef HAVE_LIBGEOIP case 35: /* Shift + 3 */ /* reset expanded module */ set_module_to (&gscroll, STATUS_CODES); break; #endif case 9: /* TAB */ /* reset expanded module */ collapse_current_module (); if (next_module () == 0) render_screens (); break; case 353: /* Shift TAB */ /* reset expanded module */ collapse_current_module (); if (previous_module () == 0) render_screens (); break; case 'g': /* g = top */ scroll_to_first_line (); display_content (main_win, logger, dash, &gscroll); break; case 'G': /* G = down */ scroll_to_last_line (); display_content (main_win, logger, dash, &gscroll); break; /* expand dashboard module */ case KEY_RIGHT: case 0x0a: case 0x0d: case 32: /* ENTER */ case 79: /* o */ case 111: /* O */ case KEY_ENTER: expand_current_module (); display_content (main_win, logger, dash, &gscroll); break; case KEY_DOWN: /* scroll main dashboard */ if ((gscroll.dash + real_size_y) < (unsigned) dash->total_alloc) { gscroll.dash++; display_content (main_win, logger, dash, &gscroll); } break; case KEY_MOUSE: /* handles mouse events */ expand_on_mouse_click (); break; case 106: /* j - DOWN expanded module */ scroll_down_expanded_module (); display_content (main_win, logger, dash, &gscroll); break; /* scroll up main_win */ case KEY_UP: if (gscroll.dash > 0) { scroll_up_dashboard (); display_content (main_win, logger, dash, &gscroll); } break; case 2: /* ^ b - page up */ case 339: /* ^ PG UP */ page_up_module (); display_content (main_win, logger, dash, &gscroll); break; case 6: /* ^ f - page down */ case 338: /* ^ PG DOWN */ page_down_module (); display_content (main_win, logger, dash, &gscroll); break; case 107: /* k - UP expanded module */ scroll_up_expanded_module (); display_content (main_win, logger, dash, &gscroll); break; case 'n': search_next_match (search); break; case '/': render_search_dialog (search); break; case 99: /* c */ if (conf.no_color) break; load_schemes_win (main_win); free_dashboard (dash); allocate_data (); render_screens (); break; case 115: /* s */ render_sort_dialog (); break; case 269: case KEY_RESIZE: window_resize (); break; default: perform_tail_follow (&size1); break; } } }