void AcceptDialog::_update_child_rect() { Size2 label_size=label->get_minimum_size(); if (label->get_text().empty()) { label_size.height = 0; } int margin = get_constant("margin","Dialogs"); Size2 size = get_size(); Size2 hminsize = hbc->get_combined_minimum_size(); Vector2 cpos(margin,margin+label_size.height); Vector2 csize(size.x-margin*2,size.y-margin*3-hminsize.y-label_size.height); if (child) { child->set_pos(cpos); child->set_size(csize); } cpos.y+=csize.y+margin; csize.y=hminsize.y; hbc->set_pos(cpos); hbc->set_size(csize); }
bool CGWIC_Cell::InitLand() { std::cout << "InitLand() called" << std::endl; const float dim = GWIC_METERS_PER_CELL * GWIC_IRRUNITS_PER_METER; vector3df pos(posX*dim,groundLevel,posY*dim); vector3df csize(GWIC_IRRUNITS_PER_METER,maxHeight,GWIC_IRRUNITS_PER_METER); SColor vcolor(255,255,255,255); path flnm = GWIC_TERRAIN_DIR + "cell"; flnm += posX; flnm += '-'; flnm += posY; flnm += ".bmp"; terrain = scManager->addTerrainSceneNode(flnm,NULL,GWIC_PICKABLE_MASK,pos,vector3df(0),csize,vcolor,maxLOD,maxPATCH,terraSmooth); if (!terrain) { std::cerr << "Terrain for cell " << posX << ';' << pos.Y << " not found!"; std::cerr << "Using default terrain mesh." << std::endl; flnm = GWIC_TERRAIN_DIR + "default_terrain.bmp"; terrain = scManager->addTerrainSceneNode(flnm,NULL,GWIC_PICKABLE_MASK,pos,vector3df(0),csize,vcolor,maxLOD,maxPATCH,terraSmooth); visible = false; if (!terrain) { std::cerr << "Unable to create terrain for cell " << posX << ';' << posY << std::endl; return false; } } terrain->setMaterialFlag(EMF_LIGHTING,true); terrain->setMaterialType(EMT_SOLID); groundTex = irDriver->getTexture(GWIC_TEXTURES_DIR+initParams.txdpath); if (!groundTex) return false; terrain->setMaterialTexture(0,groundTex); terrain->scaleTexture(initParams.texrepeats); return true; }
void View::transform( Transformer& t, const Allocation& a, const Allocation& ) const { scene2view(a); const Allotment& ax = a.x_allotment(); const Allotment& ay = a.y_allotment(); csize(ax.begin(), ax.span(), ay.begin(), ay.span()); float sx = ax.span()/XYView::width(); float sy = ay.span()/XYView::height(); // if (sx > sy) sx = sy; t.translate( -x(), -y()); t.scale(sx, sx); View* v = (View*)this; v->x_pick_epsilon_ = pick_epsilon/sx; v->y_pick_epsilon_ = pick_epsilon/sx; t.translate((ax.begin() + ax.end())/2,(ay.begin() + ay.end())/2); //printf("\nx origin=%g span=%g alignment=%g begin=%g end=%g\n", ax.origin(), ax.span(), ax.alignment(), ax.begin(), ax.end()); //printf("\ny origin=%g span=%g alignment=%g begin=%g end=%g\n", ay.origin(), ay.span(), ay.alignment(), ay.begin(), ay.end()); Coord x1,y1; t.transform(x() - x_span_/2, y() - y_span_/2, x1, y1); if (!Math::equal(ax.begin(), x1, 1) || !Math::equal(ay.begin(), y1, 1)) { t.inverse_transform(ax.begin(), ay.begin(), x1, y1); v->x_span_ = 2*(x() - x1); v->y_span_ = 2*(y() - y1); v->size(x1,y1,x1+v->x_span_, y1+v->y_span_); } }
void XYView::transform( Transformer& t, const Allocation& a, const Allocation& n ) const { #if 0 Allotment ax, ay; if (view_margin()) { const Allotment& alx = a.x_allotment(); ax.span(alx.span() - 2*view_margin()); ax.origin(alx.begin() + view_margin()); ax.alignment(0); const Allotment& aly = a.y_allotment(); ay.span(aly.span() - 2*view_margin()); ay.origin(aly.begin() + view_margin()); ay.alignment(0); } else { ax = a.x_allotment(); ay = a.y_allotment(); } Allocation al; al.allot_x(ax); al.allot_y(ay); scene2view(al); #else scene2view(a); const Allotment& ax = a.x_allotment(); const Allotment& ay = a.y_allotment(); #endif const Allotment& nx = n.x_allotment(); const Allotment& ny = n.y_allotment(); XYView* v = (XYView*)this; csize(ax.begin(), ax.span(), ay.begin(), ay.span()); float sx = xsize_/width(); float sy = ysize_/height(); XYView* xv = (XYView*)this; xv->x_pick_epsilon_ = pick_epsilon/sx; xv->y_pick_epsilon_ = pick_epsilon/sy; t.translate( -left(), -bottom()); t.scale(sx, sy); t.translate(ax.begin(), ay.begin()); #if 0 printf("XYView::transform ax origin=%g span=%g alignment=%g begin=%g\n", ax.origin(), ax.span(), ax.alignment(), ax.begin()); printf("XYView::transform ay origin=%g span=%g alignment=%g begin=%g %g\n", ay.origin(), ay.span(), ay.alignment(), ay.begin(), ay.end()); printf("XYView::transform natx origin=%g span=%g alignment=%g begin=%g\n", nx.origin(), nx.span(), nx.alignment(), nx.begin()); printf("XYView::transform naty origin=%g span=%g alignment=%g begin=%g %g\n", ny.origin(), ny.span(), ny.alignment(), ny.begin(), ny.end()); #endif }
unsigned list_cases_on(vm_obj const & o, buffer<vm_obj> & data) { if (is_simple(o)) { return 0; } else if (is_constructor(o)) { data.append(csize(o), cfields(o)); return 1; } else { lean_assert(is_external(o)); if (auto l = dynamic_cast<vm_list<name>*>(to_external(o))) { return list_cases_on_core(l->m_val, data); } else if (auto l = dynamic_cast<vm_list<expr>*>(to_external(o))) { return list_cases_on_core(l->m_val, data); } else if (auto l = dynamic_cast<vm_list<level>*>(to_external(o))) { return list_cases_on_core(l->m_val, data); } else { lean_unreachable(); } } }
void XYView::init(Coord x1, Coord y1, Coord xs, Coord ys, Scene* s, Coord xsize, Coord ysize) { set_pick_epsilon(); xsize_orig_ = xsize; ysize_orig_ = ysize; csize(0., xsize, 0., ysize); origin(x1, y1); x_span(xs); y_span(ys); canvas(NULL); parent_ = NULL; //not reffed append_view(s); #if 0 if (view_margin_ == fil) { Style* style = Session::instance()->style(); if (!style->find_attribute("view_margin", view_margin_)) { view_margin_ = 0; } view_margin_ *= 72; } #endif }
void tBlob::calculateSize() { struct csize { int32_t xmin; int32_t xmax; int32_t ymin; int32_t ymax; csize(): xmin( INT32_MAX ), xmax( 0 ), ymin( INT32_MAX ), ymax( 0 ) {} void operator()( tStreak const& s ) { int32_t lxmin = s.x(); int32_t lxmax = s.last(); if( lxmax > xmax ) { xmax = lxmax; } if( lxmin < xmin ) { xmin = lxmin; } // y int32_t y = s.y(); if( y > ymax ) { ymax = y ; } if( y < ymin ) { ymin = y ; } } }; csize const& s = for_each( _streaks.begin(), _streaks.end(), csize() ); _min = int32_xy( s.xmin, s.ymin ); _max = int32_xy( s.xmax, s.ymax ); }
bpt::ptree& FileSystemTestSetup::make_config_(bpt::ptree& pt, const fs::path& topdir, const vfs::NodeId& vrouter_id) const { be::BackendTestSetup::backend_config().persist_internal(pt, ReportDefault::T); // scocache { vd::MountPointConfigs mp_configs; mp_configs.push_back(vd::MountPointConfig(scocache_mountpoint(topdir).string(), scache_size_)); ip::PARAMETER_TYPE(scocache_mount_points)(mp_configs).persist(pt); ip::PARAMETER_TYPE(trigger_gap)(yt::DimensionedValue(scache_trigger_gap_)).persist(pt); ip::PARAMETER_TYPE(backoff_gap)(yt::DimensionedValue(scache_backoff_gap_)).persist(pt); } // clustercache { std::vector<vd::MountPointConfig> kfgs; yt::DimensionedValue csize("20MiB"); const fs::path kdev(clustercache_mountpoint(topdir)); maybe_setup_clustercache_device(kdev, csize.getBytes()); vd::MountPointConfig mp(kdev, csize.getBytes()); kfgs.push_back(mp); ip::PARAMETER_TYPE(clustercache_mount_points)(kfgs).persist(pt); ip::PARAMETER_TYPE(read_cache_serialization_path)(clustercache_serialization_path(topdir).string()).persist(pt); } // volmanager { ip::PARAMETER_TYPE(tlog_path)(tlog_dir(topdir).string()).persist(pt); ip::PARAMETER_TYPE(metadata_path)(mdstore_dir(topdir).string()).persist(pt); ip::PARAMETER_TYPE(open_scos_per_volume)(open_scos_per_volume_).persist(pt); ip::PARAMETER_TYPE(datastore_throttle_usecs)(dstore_throttle_usecs_).persist(pt); ip::PARAMETER_TYPE(clean_interval)(scache_clean_interval_).persist(pt); ip::PARAMETER_TYPE(number_of_scos_in_tlog)(num_scos_in_tlog_).persist(pt); ip::PARAMETER_TYPE(debug_metadata_path)(dump_on_halt_dir(topdir).string()).persist(pt); // (backend)threadpool ip::PARAMETER_TYPE(num_threads)(num_threads_).persist(pt); } // metadata_server - we run it outside volmanager, hence empty ServerConfigs here. { // not 'const' as clang analyzer 3.8 does not like using the defaulted default ctor: // error: default initialization of an object of const type 'const mds::ServerConfigs' (aka 'const vector<metadata_server::ServerConfig>') without a user-provided default constructor // const mds::ServerConfigs scfgs; // ^ // {} // 1 error generated. mds::ServerConfigs scfgs; mds_test_setup_->make_manager_config(pt, scfgs); } // distributed_lock_store { ip::PARAMETER_TYPE(dls_type)(vd::LockStoreType::Arakoon).persist(pt); ip::PARAMETER_TYPE(dls_arakoon_cluster_id)(arakoon_test_setup_->clusterID().str()).persist(pt); const auto node_configs(arakoon_test_setup_->node_configs()); const ip::PARAMETER_TYPE(dls_arakoon_cluster_nodes)::ValueType node_configv(node_configs.begin(), node_configs.end()); ip::PARAMETER_TYPE(dls_arakoon_cluster_nodes)(node_configv).persist(pt); } // filedriver { ip::PARAMETER_TYPE(fd_cache_path)(fdriver_cache_dir(topdir).string()).persist(pt); ip::PARAMETER_TYPE(fd_namespace)(fdriver_namespace_.str()).persist(pt); } // filesystem { ip::PARAMETER_TYPE(fs_ignore_sync)(false).persist(pt); const std::string backend_dir(source_dir().string()); ip::PARAMETER_TYPE(fs_virtual_disk_format)(vdisk_format_->name()).persist(pt); ip::PARAMETER_TYPE(fs_cache_dentries)(true).persist(pt); ip::PARAMETER_TYPE(fs_enable_shm_interface)(true).persist(pt); ip::PARAMETER_TYPE(fs_enable_network_interface)(true).persist(pt); make_mdstore_config_(pt); make_dtl_config_(vrouter_id, pt); } // volume_router { ip::PARAMETER_TYPE(vrouter_backend_sync_timeout_ms)(backend_sync_timeout_ms_).persist(pt); ip::PARAMETER_TYPE(vrouter_migrate_timeout_ms)(migrate_timeout_ms_).persist(pt); ip::PARAMETER_TYPE(vrouter_redirect_timeout_ms)(redirect_timeout_ms_).persist(pt); ip::PARAMETER_TYPE(vrouter_redirect_retries)(redirect_retries_).persist(pt); ip::PARAMETER_TYPE(vrouter_id)(vrouter_id).persist(pt); ip::PARAMETER_TYPE(scrub_manager_interval)(scrub_manager_interval_secs_).persist(pt); ip::PARAMETER_TYPE(vrouter_use_fencing)(use_fencing_).persist(pt); ip::PARAMETER_TYPE(vrouter_send_sync_response)(send_sync_response_).persist(pt); } // volume_router_cluster { ip::PARAMETER_TYPE(vrouter_cluster_id)(vrouter_cluster_id()).persist(pt); } //failovercache { ip::PARAMETER_TYPE(dtl_path)(failovercache_dir(topdir).string()).persist(pt); ip::PARAMETER_TYPE(dtl_transport)(failovercache_transport()).persist(pt); } // volume_registry make_registry_config_(pt); // event_publisher is not configured for now as it's entirely optional. // stats_collector { ip::PARAMETER_TYPE(stats_collector_interval_secs)(30).persist(pt); } return pt; }
extern "C" void csize_(fint *N, fint *M, fint *NNZJ, fint *NNZH) { csize(N, M, NNZJ, NNZH); }
void GLGSRender::flip(int buffer) { if (skip_frame) { m_frame->flip(m_context, true); rsx::thread::flip(buffer); if (!skip_frame) { m_draw_calls = 0; m_begin_time = 0; m_draw_time = 0; m_vertex_upload_time = 0; m_textures_upload_time = 0; } return; } u32 buffer_width = display_buffers[buffer].width; u32 buffer_height = display_buffers[buffer].height; u32 buffer_pitch = display_buffers[buffer].pitch; // Calculate blit coordinates coordi aspect_ratio; areai screen_area = coordi({}, { (int)buffer_width, (int)buffer_height }); sizei csize(m_frame->client_width(), m_frame->client_height()); sizei new_size = csize; if (!g_cfg.video.stretch_to_display_area) { const double aq = (double)buffer_width / buffer_height; const double rq = (double)new_size.width / new_size.height; const double q = aq / rq; if (q > 1.0) { new_size.height = int(new_size.height / q); aspect_ratio.y = (csize.height - new_size.height) / 2; } else if (q < 1.0) { new_size.width = int(new_size.width * q); aspect_ratio.x = (csize.width - new_size.width) / 2; } } aspect_ratio.size = new_size; // Find the source image rsx::tiled_region buffer_region = get_tiled_address(display_buffers[buffer].offset, CELL_GCM_LOCATION_LOCAL); u32 absolute_address = buffer_region.address + buffer_region.base; gl::texture *render_target_texture = m_rtts.get_texture_from_render_target_if_applicable(absolute_address); m_flip_fbo.recreate(); m_flip_fbo.bind(); if (render_target_texture) { buffer_width = render_target_texture->width(); buffer_height = render_target_texture->height(); __glcheck m_flip_fbo.color = *render_target_texture; __glcheck m_flip_fbo.read_buffer(m_flip_fbo.color); } else { LOG_WARNING(RSX, "Flip texture was not found in cache. Uploading surface from CPU"); if (!m_flip_tex_color || m_flip_tex_color.size() != sizei{ (int)buffer_width, (int)buffer_height }) { m_flip_tex_color.recreate(gl::texture::target::texture2D); __glcheck m_flip_tex_color.config() .size({ (int)buffer_width, (int)buffer_height }) .type(gl::texture::type::uint_8_8_8_8) .format(gl::texture::format::bgra); m_flip_tex_color.pixel_unpack_settings().aligment(1).row_length(buffer_pitch / 4); } if (buffer_region.tile) { std::unique_ptr<u8[]> temp(new u8[buffer_height * buffer_pitch]); buffer_region.read(temp.get(), buffer_width, buffer_height, buffer_pitch); __glcheck m_flip_tex_color.copy_from(temp.get(), gl::texture::format::bgra, gl::texture::type::uint_8_8_8_8); } else { __glcheck m_flip_tex_color.copy_from(buffer_region.ptr, gl::texture::format::bgra, gl::texture::type::uint_8_8_8_8); } m_flip_fbo.color = m_flip_tex_color; __glcheck m_flip_fbo.read_buffer(m_flip_fbo.color); } // Blit source image to the screen // Disable scissor test (affects blit) glDisable(GL_SCISSOR_TEST); gl::screen.clear(gl::buffers::color_depth_stencil); __glcheck m_flip_fbo.blit(gl::screen, screen_area, areai(aspect_ratio).flipped_vertical(), gl::buffers::color, gl::filter::linear); if (g_cfg.video.overlay) { gl::screen.bind(); glViewport(0, 0, m_frame->client_width(), m_frame->client_height()); m_text_printer.print_text(0, 0, m_frame->client_width(), m_frame->client_height(), "draw calls: " + std::to_string(m_draw_calls)); m_text_printer.print_text(0, 18, m_frame->client_width(), m_frame->client_height(), "draw call setup: " + std::to_string(m_begin_time) + "us"); m_text_printer.print_text(0, 36, m_frame->client_width(), m_frame->client_height(), "vertex upload time: " + std::to_string(m_vertex_upload_time) + "us"); m_text_printer.print_text(0, 54, m_frame->client_width(), m_frame->client_height(), "textures upload time: " + std::to_string(m_textures_upload_time) + "us"); m_text_printer.print_text(0, 72, m_frame->client_width(), m_frame->client_height(), "draw call execution: " + std::to_string(m_draw_time) + "us"); } m_frame->flip(m_context); rsx::thread::flip(buffer); // Cleanup m_gl_texture_cache.clear_temporary_surfaces(); for (auto &tex : m_rtts.invalidated_resources) tex->remove(); m_rtts.invalidated_resources.clear(); if (g_cfg.video.invalidate_surface_cache_every_frame) m_rtts.invalidate_surface_cache_data(nullptr); m_vertex_cache->purge(); //If we are skipping the next frame, do not reset perf counters if (skip_frame) return; m_draw_calls = 0; m_begin_time = 0; m_draw_time = 0; m_vertex_upload_time = 0; m_textures_upload_time = 0; }
void GLGSRender::flip(int buffer) { u32 buffer_width = gcm_buffers[buffer].width; u32 buffer_height = gcm_buffers[buffer].height; u32 buffer_pitch = gcm_buffers[buffer].pitch; glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glDisable(GL_SCISSOR_TEST); glDisable(GL_DEPTH_TEST); glDisable(GL_STENCIL_TEST); rsx::tiled_region buffer_region = get_tiled_address(gcm_buffers[buffer].offset, CELL_GCM_LOCATION_LOCAL); u32 absolute_address = buffer_region.address + buffer_region.base; if (0) { LOG_NOTICE(RSX, "flip(%d) -> 0x%x [0x%x]", buffer, absolute_address, rsx::get_address(gcm_buffers[1 - buffer].offset, CELL_GCM_LOCATION_LOCAL)); } gl::texture *render_target_texture = m_rtts.get_texture_from_render_target_if_applicable(absolute_address); /** * Calling read_buffers will overwrite cached content */ __glcheck m_flip_fbo.recreate(); m_flip_fbo.bind(); auto *flip_fbo = &m_flip_fbo; if (render_target_texture) { __glcheck m_flip_fbo.color = *render_target_texture; __glcheck m_flip_fbo.read_buffer(m_flip_fbo.color); } else if (draw_fbo) { //HACK! it's here, because textures cache isn't implemented correctly! flip_fbo = &draw_fbo; } else { if (!m_flip_tex_color || m_flip_tex_color.size() != sizei{ (int)buffer_width, (int)buffer_height }) { m_flip_tex_color.recreate(gl::texture::target::texture2D); __glcheck m_flip_tex_color.config() .size({ (int)buffer_width, (int)buffer_height }) .type(gl::texture::type::uint_8_8_8_8) .format(gl::texture::format::bgra); m_flip_tex_color.pixel_unpack_settings().aligment(1).row_length(buffer_pitch / 4); } if (buffer_region.tile) { std::unique_ptr<u8[]> temp(new u8[buffer_height * buffer_pitch]); buffer_region.read(temp.get(), buffer_width, buffer_height, buffer_pitch); __glcheck m_flip_tex_color.copy_from(temp.get(), gl::texture::format::bgra, gl::texture::type::uint_8_8_8_8); } else { __glcheck m_flip_tex_color.copy_from(buffer_region.ptr, gl::texture::format::bgra, gl::texture::type::uint_8_8_8_8); } m_flip_fbo.color = m_flip_tex_color; __glcheck m_flip_fbo.read_buffer(m_flip_fbo.color); } areai screen_area = coordi({}, { (int)buffer_width, (int)buffer_height }); coordi aspect_ratio; if (1) //enable aspect ratio { sizei csize(m_frame->client_width(), m_frame->client_height()); sizei new_size = csize; const double aq = (double)buffer_width / buffer_height; const double rq = (double)new_size.width / new_size.height; const double q = aq / rq; if (q > 1.0) { new_size.height = int(new_size.height / q); aspect_ratio.y = (csize.height - new_size.height) / 2; } else if (q < 1.0) { new_size.width = int(new_size.width * q); aspect_ratio.x = (csize.width - new_size.width) / 2; } aspect_ratio.size = new_size; } else { aspect_ratio.size = { m_frame->client_width(), m_frame->client_height() }; } gl::screen.clear(gl::buffers::color_depth_stencil); __glcheck flip_fbo->blit(gl::screen, screen_area, areai(aspect_ratio).flipped_vertical()); if (g_cfg_rsx_overlay) { gl::screen.bind(); glViewport(0, 0, m_frame->client_width(), m_frame->client_height()); m_text_printer.print_text(0, 0, m_frame->client_width(), m_frame->client_height(), "draw calls: " + std::to_string(m_draw_calls)); m_text_printer.print_text(0, 18, m_frame->client_width(), m_frame->client_height(), "draw call setup: " + std::to_string(m_begin_time) + "us"); m_text_printer.print_text(0, 36, m_frame->client_width(), m_frame->client_height(), "vertex upload time: " + std::to_string(m_vertex_upload_time) + "us"); m_text_printer.print_text(0, 54, m_frame->client_width(), m_frame->client_height(), "textures upload time: " + std::to_string(m_textures_upload_time) + "us"); m_text_printer.print_text(0, 72, m_frame->client_width(), m_frame->client_height(), "draw call execution: " + std::to_string(m_draw_time) + "us"); } m_frame->flip(m_context); m_draw_calls = 0; m_begin_time = 0; m_draw_time = 0; m_vertex_upload_time = 0; m_textures_upload_time = 0; for (auto &tex : m_rtts.invalidated_resources) { tex->remove(); } m_rtts.invalidated_resources.clear(); }