/// <summary> /// 从缓存中加载瓦片 /// </summary> /// <param name="zoom"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="map_mode"></param> /// <returns></returns> private Bitmap TileFromCache(int zoom, int x, int y, MapMode map_mode) { try { string row_Path = Path.Combine(Properties.BMap.Default.MapCachePath, map_mode.ToString(), zoom + "", x + ""); if (Directory.Exists(row_Path)) { //ZYM-20170818:修改瓦片数据保存格式为png string cache_name = Path.Combine(row_Path, zoom + "_" + x + "_" + y + _tile_suffix); if (File.Exists(cache_name)) { return(new Bitmap(cache_name)); } else { return(null); } } else { return(null); } } catch { return(null); } }
/// <summary> /// Changes the effective map mode. Will switch visuals state it changed /// </summary> /// <param name="mode">New map mode</param> private void ChangeMode(MapMode mode) { if (this.Mode != mode) { this.Mode = mode; switch (this.Mode) { case MapMode.Stores: this.ShowStores(true); this.RouteDirectionsPushPin.Visibility = Visibility.Collapsed; if (this.MapRoute != null) { this.Map.RemoveRoute(this.MapRoute); } break; case MapMode.Route: this.ShowStores(false); break; case MapMode.Directions: this.ShowStores(false); if (this.MapRoute != null) { this.Map.RemoveRoute(this.MapRoute); } break; } } }
internal ClientConductor(Aeron.Context ctx) { _clientLock = ctx.ClientLock(); _epochClock = ctx.EpochClock(); _nanoClock = ctx.NanoClock(); _errorHandler = ctx.ErrorHandler(); _counterValuesBuffer = ctx.CountersValuesBuffer(); _driverProxy = ctx.DriverProxy(); _logBuffersFactory = ctx.LogBuffersFactory(); _imageMapMode = ctx.ImageMapMode(); _keepAliveIntervalNs = ctx.KeepAliveInterval(); _driverTimeoutMs = ctx.DriverTimeoutMs(); _driverTimeoutNs = _driverTimeoutMs * 1000000; _interServiceTimeoutNs = ctx.InterServiceTimeout(); _publicationConnectionTimeoutMs = ctx.PublicationConnectionTimeout(); _defaultAvailableImageHandler = ctx.AvailableImageHandler(); _defaultUnavailableImageHandler = ctx.UnavailableImageHandler(); _driverEventsAdapter = new DriverEventsAdapter(ctx.ToClientBuffer(), this); long nowNs = _nanoClock.NanoTime(); _timeOfLastKeepAliveNs = nowNs; _timeOfLastResourcesCheckNs = nowNs; _timeOfLastServiceNs = nowNs; }
public void StartPickLocation(NewReservation.LocationSelectedDelegate pickLocationSelectedDelegate, DateTime date) { _mode = MapMode.PickLocation; dateTimePicker.Value = date; _pickCallBackAction = pickLocationSelectedDelegate; ChangeMode(_mode); }
public MapUserControl(HomeUserControl home) { InitializeComponent(); LoginTools.CheckConnection(); HomeUserControl = home; _db = new DataBase(); _cursorAction = CursorAction.Default; _moving = false; _offsetMoving = new Point(); FillListsControlsDromDb(); LoadLocationsFromDb(); if (!_db.App.Any(m => m.Fond_Image != null)) { _mode = MapMode.LoadImage; } else { MemoryStream ms = new MemoryStream(_db.App.FirstOrDefault().Fond_Image); var imageJpeg = Image.FromStream(ms); _image = new Bitmap(imageJpeg); ms.Close(); pictureBox.Image = _image; _mode = MapMode.Normal; } ChangeMode(_mode); }
protected override void OnStartRunning() { var mapModes = Enum.GetValues(typeof(MapMode)).Cast <MapMode>().ToArray(); _maxMapMode = mapModes.Max(); _minMapMode = mapModes.Min(); _currentMode = MapMode.Political; _surfaceMat = GameObject.Find("Surface").GetComponent <MeshRenderer>().sharedMaterial; _singletonColors = EntityManager.GetComponentData <SingletonColorBlob>( GetSingletonEntity <SingletonColorBlob>()); _singletonUpwards = EntityManager.GetComponentData <SingletonUpwardsIndex>( GetSingletonEntity <SingletonUpwardsIndex>()); _provinceCount = _singletonColors.Provinces.Value.Lookup.Length; _provinceColors = new Texture2D(_provinceCount, 1, TextureFormat.RGBA32, false, false) { filterMode = FilterMode.Point }; // Crashes the game. RIP instant switch. SwitchMaps(_currentMode); }
public unsafe GpuCache( GraphicsDevice graphicsDevice, uint typeSizeInGpuBlocks, uint dimension = 128) { _gd = graphicsDevice; _blocksPerSlot = MathUtil.NearestPowerOfTwo(typeSizeInGpuBlocks); _slots = new FreeList(); //_usingGL = _gd.BackendType == GraphicsBackend.OpenGL // || _gd.BackendType == GraphicsBackend.OpenGLES; _usingGL = false; _mapMode = _usingGL ? MapMode.Write : MapMode.ReadWrite; _dimension = dimension = MathUtil.NearestPowerOfTwo(dimension); _capacity = dimension * dimension / _blocksPerSlot; var desc = TextureDescription.Texture2D( dimension, dimension, mipLevels: 1, arrayLayers: 1, PixelFormat.R32_G32_B32_A32_Float, TextureUsage.Staging ); ResourceFactory rf = _gd.ResourceFactory; _stagingTexture = rf.CreateTexture(ref desc); desc.Usage = TextureUsage.Sampled; _sampledTexture = rf.CreateTexture(ref desc); if (_usingGL) { int dataSize = (int)(dimension * dimension * GpuBlockSize); _glHostMemory = Marshal.AllocHGlobal(dataSize); var span = new Span <byte>(_glHostMemory.ToPointer(), dataSize); span.Clear(); } }
public void Update(IIndexBuffer buffer, DataArray data, int count) { var dxBuffer = graphicsDevice.Cast <IndexBuffer>(buffer, "buffer"); if (dxBuffer.Usage == ResourceUsage.Immutable) { throw new ArgumentException("Can't update immutable resource.", "buffer"); } if (data.Size != buffer.SizeBytes) { throw new ArgumentException("Data does not match IndexBuffer size.", "data"); } if (dxBuffer.Usage == ResourceUsage.Normal) { renderContext.Context.UpdateSubresource(new SharpDX.DataBox(data.Pointer, 0, 0), dxBuffer.Buffer); } else { MapMode mapMode = dxBuffer.Usage == ResourceUsage.Dynamic ? MapMode.WriteDiscard : MapMode.Write; SharpDX.DataBox box = renderContext.Context.MapSubresource(dxBuffer.Buffer, 0, mapMode, MapFlags.None); SharpDX.Utilities.CopyMemory(box.DataPointer, data.Pointer, data.Size); renderContext.Context.UnmapSubresource(dxBuffer.Buffer, 0); } }
public void SetMapMode(MapMode mode) { if (mode == mapMode) { return; } if (mode == MapMode.Terrain) { terrainMat.SetFloat("_TerrainMode", 1); if (!CameraController.showstate) { Trees.gameObject.SetActive(true); foreach (Transform tree in Trees) { MapMetrics.UpdateTree(tree.gameObject); } } } if (mode == MapMode.Politic) { terrainMat.SetTexture("_MainTex", regionMap); terrainMat.SetTexture("_OccupeMap", occupationMap); terrainMat.SetFloat("_TerrainMode", 0); Trees.gameObject.SetActive(false); } mapMode = mode; }
internal ClientConductor(Aeron.Context ctx) { _ctx = ctx; _clientLock = ctx.ClientLock(); _epochClock = ctx.EpochClock(); _nanoClock = ctx.NanoClock(); _errorHandler = ctx.ErrorHandler(); _counterValuesBuffer = ctx.CountersValuesBuffer(); _driverProxy = ctx.DriverProxy(); _logBuffersFactory = ctx.LogBuffersFactory(); _imageMapMode = ctx.ImageMapMode(); _keepAliveIntervalNs = ctx.KeepAliveInterval(); _driverTimeoutMs = ctx.DriverTimeoutMs(); _driverTimeoutNs = _driverTimeoutMs * 1000000; _interServiceTimeoutNs = ctx.InterServiceTimeout(); _publicationConnectionTimeoutMs = ctx.PublicationConnectionTimeout(); _driverListener = new DriverListenerAdapter(ctx.ToClientBuffer(), this); _driverAgentInvoker = ctx.DriverAgentInvoker(); long nowNs = _nanoClock.NanoTime(); _timeOfLastKeepaliveNs = nowNs; _timeOfLastCheckResourcesNs = nowNs; _timeOfLastWorkNs = nowNs; }
public void SetAttackMode() { _mode = MapMode.Attack; _cursorTile = cursorTiles[Marker.Target.GetHashCode()]; _minCoordinate = new Vector3Int(0, Size, 0); _maxCoordinate = new Vector3Int(Size - 1, Size + Size - 1, 0); }
/// <summary> Stop a read or write sequence, release buffer back to use </summary> public void StopReadWrite() { System.Diagnostics.Debug.Assert(context == GLStatics.GetContext(), "Context incorrect"); // safety GL.UnmapNamedBuffer(Id); mapmode = MapMode.None; GLStatics.Check(); }
public static Expression GetExpression(Type openConstructorType, MapMode mapMode, Type targetCollType, Type sourceCollType, Expression listExpr, Expression includeChain, List <Tuple <Type, Type> > usedBuilders) { Type sourceType = sourceCollType.GetElementTypeOrType(); Type targetType = targetCollType.GetElementTypeOrType(); var closedConstructorType = openConstructorType.MakeGenericType(targetType); var resultExpr = Expression.Variable(targetCollType); var itemExpr = Expression.Variable(sourceType); var itemMapExpression = PolymorphismManager.GetMostConcreteExpressionCreator(mapMode, itemExpr, targetType, includeChain, usedBuilders); if (itemMapExpression == null) { return(null); } var loopContent = Expression.Block( Expression.Call( resultExpr, closedConstructorType.GetTypeInfo().GetMethod("Add"), itemMapExpression ) ); var result = Expression.Block( new ParameterExpression[] { resultExpr, itemExpr }, Expression.Assign(resultExpr, Expression.New(closedConstructorType)), loopContent.ForEach( listExpr, itemExpr ), resultExpr ); return(result); }
/// <summary> /// 从缓存中加载瓦片 /// </summary> /// <param name="zoom"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="map_mode"></param> /// <returns></returns> private Bitmap TileFromCache(int zoom, int x, int y, MapMode map_mode) { try { string cache_path = Properties.BMap.Default.MapCachePath; if (Directory.Exists(cache_path + "\\" + map_mode.ToString())) { string cache_name = cache_path + "\\" + map_mode.ToString() + "\\" + zoom + "_" + x + "_" + y + ".bmp"; if (File.Exists(cache_name)) { return(new Bitmap(cache_name)); } else { return(null); } } else { return(null); } } catch { return(null); } }
/// <summary> /// 从服务器上加载瓦片 /// </summary> /// <param name="zoom"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="map_mode"></param> /// <returns></returns> private Bitmap TileFromServer(int zoom, int x, int y, MapMode map_mode) { try { Random r = new Random(DateTime.Now.Millisecond); int server_index = r.Next(0, 10); //随即产生0~9之间的整数 string url = ""; if (map_mode == MapMode.Normal) //地图 { url = String.Format(_road_url, server_index) + "?qt=tile&x=" + x + "&y=" + y + "&z=" + zoom + "&styles=pl"; } if (map_mode == MapMode.Satellite) //卫星图 { url = String.Format(_sate_url, server_index) + "u=x=" + x + ";y=" + y + ";z=" + zoom + ";v=009;type=sate&fm=46"; } if (map_mode == MapMode.RoadNet) //道路网 { url = String.Format(_road_url, server_index) + "?qt=tile&x=" + x + "&y=" + y + "&z=" + zoom + "&styles=sl"; } byte[] bytes = DownloadData(url); Bitmap bitmap = Image.FromStream(new MemoryStream(bytes)) as Bitmap; SaveTile2Cache(zoom, x, y, map_mode, bitmap); return(bitmap); } catch { return(null); } }
/// <summary> /// This Method can be seen as an inverse of Lerp (in Mode Float). Additionally it provides Mapping Modes /// </summary> /// <param name="Input">Input value to convert</param> /// <param name="start">Minimum of input value range</param> /// <param name="end">Maximum of input value range</param> /// <param name="mode">Defines the behavior of the function if the input value exceeds the destination range /// <see cref="MapMode">MapMode</see></param> /// <returns>Input value mapped from input range into destination range</returns> public static Vector4 Ratio(Vector4 Input, Vector4 start, Vector4 end, MapMode mode) => new Vector4( Ratio(Input.X, start.X, end.X, mode), Ratio(Input.Y, start.Y, end.Y, mode), Ratio(Input.Z, start.Z, end.Z, mode), Ratio(Input.W, start.W, end.W, mode) );
/// <summary> /// 从缓存中加载瓦片 /// </summary> /// <param name="zoom"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="map_mode"></param> /// <returns></returns> private Bitmap TileFromCache(int zoom, int x, int y, MapMode map_mode) { try { string cache_path = Properties.BMap.Default.MapCachePath; if (Directory.Exists(cache_path + "\\" + map_mode.ToString())) { string cache_name = cache_path + "\\" + map_mode.ToString() + "\\" + zoom + "_" + x + "_" + y + ".bmp"; if (File.Exists(cache_name)) { return new Bitmap(cache_name); } else { return null; } } else { return null; } } catch { return null; } }
/// <summary> /// Maps a <see cref="Buffer"/> or <see cref="Texture"/> into a CPU-accessible data region. /// </summary> /// <param name="resource">The <see cref="Buffer"/> or <see cref="Texture"/> resource to map.</param> /// <param name="mode">The <see cref="MapMode"/> to use.</param> /// <param name="subresource">The subresource to map. Subresources are indexed first by mip slice, then by array layer. /// For <see cref="Buffer"/> resources, this parameter must be 0.</param> /// <returns>A <see cref="MappedResource"/> structure describing the mapped data region.</returns> public MappedResource Map(MappableResource resource, MapMode mode, uint subresource) { #if VALIDATE_USAGE if (resource is Buffer buffer) { if ((buffer.Usage & BufferUsage.Dynamic) != BufferUsage.Dynamic && (buffer.Usage & BufferUsage.Staging) != BufferUsage.Staging) { throw new VeldridException("Buffers must have the Staging or Dynamic usage flag to be mapped."); } if (subresource != 0) { throw new VeldridException("Subresource must be 0 for Buffer resources."); } } else if (resource is Texture tex) { if ((tex.Usage & TextureUsage.Staging) == 0) { throw new VeldridException("Texture must have the Staging usage flag to be mapped."); } if (subresource >= tex.ArrayLayers * tex.MipLevels) { throw new VeldridException( "Subresource must be less than the number of subresources in the Texture being mapped."); } } #endif return(MapCore(resource, mode, subresource)); }
public GuiMap(int x, int y, MDRParty party = null) : base(x, y) { Util.Assert((CoM.Instance != null) && CoM.GraphicsLoaded, "GUI graphics must be loaded in order to create a GuiMap component."); MapIcons = CoM.Instance.MapIconSprites.GetSprites().ToArray(); this.Party = party; if (party != null) { this.Map = Party.ExploredMap; } Background.Color = Color.white; Background.Sprite = ResourceManager.GetSprite("Backgrounds/DarkMap"); if (!STATIC_BACKGROUND) { Background.Align = GuiAlignment.None; Background.Width = (32 + (BACKGROUND_BORDER * 2)) * TILE_SIZE; Background.Height = (32 + (BACKGROUND_BORDER * 2)) * TILE_SIZE; } else { Background.Align = GuiAlignment.Full; } Mode = MapMode.Full; }
/// <summary> /// Maps the data contained in a subresource to a memory pointer, and denies the GPU access to that subresource. /// </summary> /// <param name="resource">The resource.</param> /// <param name="mode">The mode.</param> /// <param name="flags">The flags.</param> /// <param name="stream">The output stream containing the pointer.</param> /// <returns> /// The locked <see cref="SharpDX.DataBox"/> /// </returns> /// <unmanaged>HRESULT ID3D11DeviceContext::Map([In] ID3D11Resource* pResource,[In] unsigned int Subresource,[In] D3D11_MAP MapType,[In] D3D11_MAP_FLAG MapFlags,[Out] D3D11_MAPPED_SUBRESOURCE* pMappedResource)</unmanaged> public DataBox MapSubresource(Buffer resource, MapMode mode, MapFlags flags, out DataStream stream) { var box = MapSubresource(resource, 0, mode, flags); stream = new DataStream(box.DataPointer, resource.Description.SizeInBytes, true, true); return(box); }
internal DataBox MapSubresource(IResource resourceRef, int subresource, MapMode mapType, MapFlags mapFlags) { return(m_deviceContext.MapSubresource(resourceRef.Resource, subresource, mapType, mapFlags)); CheckErrors(); }
public void Awake() { m_bg = component as UIScrollablePanel; PublicTransportWorldInfoPanel ptwip = UVMPublicTransportWorldInfoPanel.m_obj.origInstance; AddNewStopTemplate(); ptwip.component.width = 800; BindComponents(ptwip); AdjustLineStopsPanel(ptwip); KlyteMonoUtils.CreateUIElement(out m_panelModeSelector, m_bg.parent.transform); m_panelModeSelector.autoFitChildrenHorizontally = true; m_panelModeSelector.autoFitChildrenVertically = true; m_panelModeSelector.autoLayout = true; m_panelModeSelector.autoLayoutDirection = LayoutDirection.Horizontal; m_mapModeDropDown = UIHelperExtension.CloneBasicDropDownNoLabel(Enum.GetNames(typeof(MapMode)).Select(x => Locale.Get("K45_TLM_LINEAR_MAP_VIEW_MODE", x)).ToArray(), (int idx) => { m_currentMode = (MapMode)idx; RefreshVehicleButtons(GetLineID()); }, m_panelModeSelector); m_mapModeDropDown.textScale = 0.75f; m_mapModeDropDown.size = new Vector2(200, 25); m_mapModeDropDown.itemHeight = 16; UICheckBox unscaledCheck = UIHelperExtension.AddCheckboxLocale(m_panelModeSelector, "K45_TLM_LINEAR_MAP_SHOW_UNSCALED", m_unscaledMode, (val) => m_unscaledMode = val); KlyteMonoUtils.LimitWidthAndBox(unscaledCheck.label, 165); InstanceManagerOverrides.EventOnBuildingRenamed += (x) => m_dirtyNames = true; }
public static extern int GdipEmfToWmfBits ( IntPtr hEmf, int bufferSize, byte[] buffer, MapMode mappingMode, EmfToWmfBitsFlags flags );
public void Map <T>(DeviceContext4 context4, T[] data, MapMode mapMode = MapMode.WriteDiscard, MapFlags mapFlags = MapFlags.None) where T : unmanaged { Map(context4, 0, data, 0, data.Length, mapMode, mapFlags); }
public void SetWorldScaleMapActive() { overheadMap.gameObject.SetActive(false); worldScaleMap.gameObject.SetActive(true); overheadCamera.SetActive(false); mainCamera.orthographic = false; currentMapMode = MapMode.WorldScale; }
/// <summary> /// 构造方法 /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="z"></param> /// <param name="parent"></param> /// <param name="mode"></param> /// <param name="loadmode"></param> public BTile(int x, int y, int z, Control parent, MapMode mode, LoadMapMode loadmode) { X = x; Y = y; Zoom = z; BMapControl = parent; Mode = mode; LoadMode = loadmode; }
public ChangeViewUserControl() { CurrentMapMode = MapMode.Standard; ShowTrafficIsOn = SettingsSetters.GetShowTrafficOnLaunch(); AllowOverstretch = SettingsSetters.GetAllowOverstretch(); FadeAnimationEnabled = SettingsSetters.GetFadeAnimationEnabled(); this.InitializeComponent(); Map = MapView.MapControl; }
public void Move(Point2D delta, RenderOption option, FillMode fill, MapMode effect) { double dx = Math.Abs(delta.X); double dy = Math.Abs(delta.Y); // use delta.X / |delta.X| = delta.X / dx = +/-1 to keep the sign of delta.X if (dx > dy) { for (ushort x = 0; x < dx; x++) { // to exclude x = 0 if (x % AUTO_REBOX_TRIG == (ushort)(AUTO_REBOX_TRIG / (x + 1))) { Render(ALLOW_REBOXING | option, fill, effect); Rebox(); } // prevent artifacts Render(option, fill, effect); Translate(new Point2D(X_MOTION_SCALE * delta.X / dx, ((x % (dx / dy) > 0) && (x % (dx / dy) <= 1)) ? Y_MOTION_SCALE * delta.Y / dy : NO_MOTION)); } } else if (dy > dx) { for (ushort y = 0; y < dy; y++) { // to exclude y = 0 if (y % AUTO_REBOX_TRIG == (ushort)(AUTO_REBOX_TRIG / (y + 1))) { Render(ALLOW_REBOXING | option, fill, effect); Rebox(); } // prevent artifacts Render(option, fill, effect); Translate(new Point2D(((y % (dy / dx) > 0) && (y % (dy / dx) <= 1)) ? X_MOTION_SCALE * delta.X / dx : NO_MOTION, Y_MOTION_SCALE * delta.Y / dy)); } } // dx == dy else { for (ushort i = 0; i < dx; i++) { // to exclude i = 0 if (i % AUTO_REBOX_TRIG == (ushort)(AUTO_REBOX_TRIG / (i + 1))) { Render(ALLOW_REBOXING | option, fill, effect); Rebox(); } // prevent artifacts Render(option, fill, effect); Translate(new Point2D(delta.X / dx, delta.Y / dy)); } } // really this should just be Render(ALLOW_REBOXING, effect); Render(ALLOW_REBOXING | option, fill, effect); }
/// <summary> /// Get the most concrete creator delegate. /// </summary> /// <param name="mapMode"></param> /// <returns></returns> private static Func <TSource, IncludeChain, TTarget> GetMostConcreteCreator(MapMode mapMode) { Type sourceType = typeof(TSource); Type targetType = typeof(TTarget); ParameterExpression paramSource = Expression.Parameter(sourceType); ParameterExpression paramInclude = Expression.Parameter(typeof(IncludeChain)); var body = PolymorphismManager.GetMostConcreteExpressionCreator(mapMode, paramSource, targetType, paramInclude, new List <Tuple <Type, Type> >()); return(GetCreateDelegate(paramSource, paramInclude, body)); }
internal MapNode(string JSON) : base(JSON) { Mode = GetEnum <MapMode>("mode"); Name = GetString("name"); Phase = GetEnum <MapPhase>("phase"); Round = GetInt32("round"); TeamCT = new MapTeamNode(_Data["team_ct"]?.ToString() ?? ""); TeamT = new MapTeamNode(_Data["team_t"]?.ToString() ?? ""); }
internal MapNode(string JSON) : base(JSON) { Mode = GetEnum<MapMode>("mode"); Name = GetString("name"); Phase = GetEnum<MapPhase>("phase"); Round = GetInt32("round"); TeamCT = new MapTeamNode(_Data["team_ct"]?.ToString() ?? ""); TeamT = new MapTeamNode(_Data["team_t"]?.ToString() ?? ""); }
/// <summary> /// Maps the texture, providing CPU access to its contents. /// </summary> /// <param name="mipSlice">The mip slice to map.</param> /// <param name="mode">The IO operations to enable on the CPU.</param> /// <param name="flags">Flags indicating how the CPU should respond when the GPU is busy.</param> /// <returns>A data rectangle containing the mapped data. This data stream is invalidated when the buffer is unmapped.</returns> public DataRectangle Map(int mipSlice, MapMode mode, MapFlags flags) { var desc = Description; int subresource = CalculateSubResourceIndex(mipSlice, 0, desc.MipLevels); DataRectangle mappedTexture2D; Map(subresource, mode, flags, out mappedTexture2D); return(mappedTexture2D); }
/// <summary> /// Maps the texture, providing CPU access to its contents. /// </summary> /// <param name="mipSlice">The mip slice to map.</param> /// <param name="mode">The IO operations to enable on the CPU.</param> /// <param name="flags">Flags indicating how the CPU should respond when the GPU is busy.</param> /// <returns> /// A databox containing the mapped data. This data stream is invalidated when the buffer is unmapped. /// </returns> public DataBox Map(int mipSlice, MapMode mode, MapFlags flags) { var desc = Description; int subresource = CalculateSubResourceIndex(mipSlice, 0, desc.MipLevels); DataBox mappedTexture3D; Map(subresource, mode, flags, out mappedTexture3D); return mappedTexture3D; }
public static int RAMToPhysical(int address, MapMode mode) { switch(mode) { case MapMode.LoROM: return ((address & 0x7F0000) >> 1) | (address & 0x7FFF); case MapMode.HiROM: return address & 0x3FFFFF; } return address; }
/// <summary> /// Maps the texture, providing CPU access to its contents. /// </summary> /// <param name="mipSlice">The mip slice to map.</param> /// <param name="mode">The IO operations to enable on the CPU.</param> /// <param name="flags">Flags indicating how the CPU should respond when the GPU is busy.</param> /// <returns>A data stream containing the mapped data. This data stream is invalidated /// when the buffer is unmapped.</returns> public DataStream Map(int mipSlice, MapMode mode, MapFlags flags) { var desc = Description; int subresource = CalculateSubResourceIndex( mipSlice, 0, desc.MipLevels ); int mipWidth = GetMipSize( mipSlice, desc.Width ); int bufferSize = (int)(mipWidth * FormatHelper.SizeOfInBytes(desc.Format)); IntPtr dataPointer; Map(subresource, mode, flags, out dataPointer); bool canRead = mode == MapMode.Read || mode == MapMode.ReadWrite; bool canWrite = mode != MapMode.Read; return new DataStream(dataPointer, bufferSize, canRead, canWrite); }
public static int PhysicalToRAM(int address, MapMode mode, RomSpeed romSpeed) { int bank = 0; switch(mode) { case MapMode.LoROM: { switch (romSpeed) { case RomSpeed.SlowROM: bank = 0x00; break; case RomSpeed.FastROM: bank = 0x80; break; } int result = (bank << 16) | ((address & 0xFF8000) << 1) | (address & 0xFFFF) | 0x8000 ; return result; } case MapMode.HiROM: { switch (romSpeed) { case RomSpeed.SlowROM: case RomSpeed.FastROM: bank = 0xC0; break; } return (bank << 16) | (address & 0xFFFFFF); } } return address; }
private static string _sate_url = "http://shangetu{0}.map.bdimg.com/it/"; //卫星图切片URL /* http://online9.map.bdimg.com/onlinelabel/?qt=tile&x=796&y=287&z=12&styles=pl */ /* http://shangetu9.map.bdimg.com/it/u=x=796;y=287;z=13;v=009;type=sate&fm=46 */ /// <summary> /// 下载地图瓦片 /// </summary> /// <param name="x">瓦片方块横坐标</param> /// <param name="y">瓦片方块纵坐标</param> /// <param name="zoom">当前地图缩放级别(1-18)</param> /// <param name="map_mode">地图模式</param> /// <param name="load_mode">加载瓦片方式</param> /// <returns></returns> public Bitmap LoadMapTile(int x, int y, int zoom, MapMode map_mode, LoadMapMode load_mode) { if (load_mode == LoadMapMode.Server) //直接从服务器下载图片 { return TileFromServer(zoom, x, y, map_mode); } else if (load_mode == LoadMapMode.Cache) //从本地缓存中下载图片 { return TileFromCache(zoom, x, y, map_mode); } else if (load_mode == LoadMapMode.CacheServer) //先从本地缓存中找,如果没有则从服务器上下载 { Bitmap bitmap = TileFromCache(zoom, x, y, map_mode); if (bitmap == null) { bitmap = TileFromServer(zoom, x, y, map_mode); } return bitmap; } else { return null; } }
public MainWindow(Mutex mut, WelcomeWindow welWin, INetProto netJungleProto, MapMode selectedMapMode) { this.m = mut; this.currentMapMode = selectedMapMode; InitializeComponent(); rowDefs = new Dictionary<MapMode, RowDefinition> { { MapMode.SUMMONERS_RIFT, summonersRiftRowDefinition } }; this.welWin = welWin; this.netJungleProto = netJungleProto; netJungleProto.NewNetworkMessage += new NewNetworkMessageHandler(this.OnNetworkMessage); KeyboardManager.Instance.HotKeyPressed += new HotKeyPressedEventHandler(OnHotKeyHandlerWrapper); ResetState(); if (netJungleProto is MockupNetProto) { nowPlayingRowDefinition.Height = new GridLength(0); statusRowDefinition.Height = new GridLength(0); } // okay, here goes nothing foreach (KeyValuePair<MapMode, RowDefinition> rowDefKvp in rowDefs) { if (rowDefKvp.Key != selectedMapMode) { rowDefKvp.Value.Height = new GridLength(0); } } }
// TODO GRAPHICS REFACTOR what should we do with this? /// <summary> /// Maps a subresource. /// </summary> /// <param name="resource">The resource.</param> /// <param name="subResourceIndex">Index of the sub resource.</param> /// <param name="mapMode">The map mode.</param> /// <param name="doNotWait">if set to <c>true</c> this method will return immediately if the resource is still being used by the GPU for writing. Default is false</param> /// <param name="offsetInBytes">The offset information in bytes.</param> /// <param name="lengthInBytes">The length information in bytes.</param> /// <returns>Pointer to the sub resource to map.</returns> public MappedResource MapSubresource(GraphicsResource resource, int subResourceIndex, MapMode mapMode, bool doNotWait = false, int offsetInBytes = 0, int lengthInBytes = 0) { if (resource == null) throw new ArgumentNullException("resource"); var rowPitch = 0; var depthStride = 0; var usage = GraphicsResourceUsage.Default; var texture = resource as Texture; if (texture != null) { usage = texture.Usage; if (lengthInBytes == 0) lengthInBytes = texture.ComputeSubresourceSize(subResourceIndex); rowPitch = texture.ComputeRowPitch(subResourceIndex % texture.MipLevels); depthStride = texture.ComputeSlicePitch(subResourceIndex % texture.MipLevels); if (texture.Usage == GraphicsResourceUsage.Staging) { // Internally it's a buffer, so adapt resource index and offset offsetInBytes = texture.ComputeBufferOffset(subResourceIndex, 0); subResourceIndex = 0; } } else { var buffer = resource as Buffer; if (buffer != null) { usage = buffer.Usage; if (lengthInBytes == 0) lengthInBytes = buffer.SizeInBytes; } } // TODO D3D12 WriteDiscard should just reallocate new buffer, and WriteNoOverwrite shouldn't use that path (for now we defer to upload buffer) if (mapMode == MapMode.WriteDiscard || mapMode == MapMode.WriteNoOverwrite) { SharpDX.Direct3D12.Resource uploadResource; int uploadOffset; var uploadMemory = GraphicsDevice.AllocateUploadBuffer(lengthInBytes, out uploadResource, out uploadOffset); return new MappedResource(resource, subResourceIndex, new DataBox(uploadMemory, rowPitch, depthStride), offsetInBytes, lengthInBytes) { UploadResource = uploadResource, UploadOffset = uploadOffset, }; } else if (mapMode == MapMode.Read || mapMode == MapMode.ReadWrite || mapMode == MapMode.Write) { // Is non-staging ever possible? if (usage != GraphicsResourceUsage.Staging) throw new InvalidOperationException(); if (mapMode != MapMode.WriteNoOverwrite) { // Need to wait? if (!GraphicsDevice.IsFenceCompleteInternal(resource.StagingFenceValue)) { if (doNotWait) { return new MappedResource(resource, subResourceIndex, new DataBox(IntPtr.Zero, 0, 0)); } // Need to flush (part of current command list) if (resource.StagingFenceValue == GraphicsDevice.NextFenceValue) FlushInternal(false); GraphicsDevice.WaitForFenceInternal(resource.StagingFenceValue); } } var mappedMemory = resource.NativeResource.Map(subResourceIndex) + offsetInBytes; return new MappedResource(resource, subResourceIndex, new DataBox(mappedMemory, rowPitch, depthStride), offsetInBytes, lengthInBytes); } else { throw new NotImplementedException(); } }
/// <summary> /// 将从服务器上下载的瓦片保存到缓存 /// </summary> /// <param name="zoom"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="map_mode"></param> /// <param name="tile"></param> private void SaveTile2Cache(int zoom, int x, int y, MapMode map_mode, Bitmap tile) { try { string cache_path = Properties.BMap.Default.MapCachePath; if (!Directory.Exists(cache_path + "\\" + map_mode.ToString())) { Directory.CreateDirectory(cache_path + "\\" + map_mode.ToString()); } tile.Save(cache_path + "\\" + map_mode.ToString() + "\\" + zoom + "_" + x + "_" + y + ".bmp"); } catch { } }
private void ChangeMapMode(MapMode mode) { Mode = mode; }
public MappedResource MapSubresource(GraphicsResource resource, int subResourceIndex, MapMode mapMode, bool doNotWait = false, int offsetInBytes = 0, int lengthInBytes = 0) { #if DEBUG GraphicsDevice.EnsureContextActive(); #endif // This resource has just been recycled by the GraphicsResourceAllocator, we force a rename to avoid GPU=>GPU sync point if (resource.DiscardNextMap && mapMode == MapMode.WriteNoOverwrite) mapMode = MapMode.WriteDiscard; var buffer = resource as Buffer; if (buffer != null) { if (lengthInBytes == 0) lengthInBytes = buffer.Description.SizeInBytes; if (buffer.StagingData != IntPtr.Zero) { // Specific case for constant buffers return new MappedResource(resource, subResourceIndex, new DataBox { DataPointer = buffer.StagingData + offsetInBytes, SlicePitch = 0, RowPitch = 0 }, offsetInBytes, lengthInBytes); } #if SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGLES // OpenGL ES 2 needs Staging Data if (GraphicsDevice.IsOpenGLES2) { Internal.Refactor.ThrowNotImplementedException(); } #endif IntPtr mapResult = IntPtr.Zero; //UnbindVertexArrayObject(); GL.BindBuffer(buffer.BufferTarget, buffer.BufferId); #if !SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGLES //if (mapMode != MapMode.WriteDiscard && mapMode != MapMode.WriteNoOverwrite) // mapResult = GL.MapBuffer(buffer.bufferTarget, mapMode.ToOpenGL()); //else #endif { // Orphan the buffer (let driver knows we don't need it anymore) if (mapMode == MapMode.WriteDiscard) { doNotWait = true; GL.BufferData(buffer.BufferTarget, (IntPtr)buffer.Description.SizeInBytes, IntPtr.Zero, buffer.BufferUsageHint); } var unsynchronized = doNotWait && mapMode != MapMode.Read && mapMode != MapMode.ReadWrite; mapResult = GL.MapBufferRange(buffer.BufferTarget, (IntPtr)offsetInBytes, (IntPtr)lengthInBytes, mapMode.ToOpenGLMask() | (unsynchronized ? BufferAccessMask.MapUnsynchronizedBit : 0)); } return new MappedResource(resource, subResourceIndex, new DataBox { DataPointer = mapResult, SlicePitch = 0, RowPitch = 0 }); } var texture = resource as Texture; if (texture != null) { if (lengthInBytes == 0) lengthInBytes = texture.ComputeSubresourceSize(subResourceIndex); if (mapMode == MapMode.Read) { if (texture.Description.Usage != GraphicsResourceUsage.Staging) throw new NotSupportedException("Only staging textures can be mapped."); var mipLevel = subResourceIndex % texture.MipLevels; #if SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGLES if (GraphicsDevice.IsOpenGLES2 || texture.StagingData != IntPtr.Zero) { return new MappedResource(resource, subResourceIndex, new DataBox { DataPointer = texture.StagingData + offsetInBytes + texture.ComputeBufferOffset(subResourceIndex, 0), SlicePitch = texture.ComputeSlicePitch(mipLevel), RowPitch = texture.ComputeRowPitch(mipLevel) }, offsetInBytes, lengthInBytes); } else #endif { if (doNotWait) { // Wait at least 2 frames after last operation if (GraphicsDevice.FrameCounter < texture.PixelBufferFrame + ReadbackFrameDelay) { return new MappedResource(resource, subResourceIndex, new DataBox(), offsetInBytes, lengthInBytes); } } return MapTexture(texture, true, BufferTarget.PixelPackBuffer, texture.PixelBufferObjectId, subResourceIndex, mapMode, offsetInBytes, lengthInBytes); } } else if (mapMode == MapMode.WriteDiscard) { #if SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGLES if (GraphicsDevice.IsOpenGLES2) { Internal.Refactor.ThrowNotImplementedException(); } #endif if (texture.Description.Usage != GraphicsResourceUsage.Dynamic) throw new NotSupportedException("Only dynamic texture can be mapped."); // Create a temporary unpack pixel buffer // TODO: Pool/allocator? (it's an upload buffer basically) var pixelBufferObjectId = texture.GeneratePixelBufferObject(BufferTarget.PixelUnpackBuffer, PixelStoreParameter.UnpackAlignment, BufferUsageHint.DynamicCopy, texture.ComputeSubresourceSize(subResourceIndex)); return MapTexture(texture, false, BufferTarget.PixelUnpackBuffer, pixelBufferObjectId, subResourceIndex, mapMode, offsetInBytes, lengthInBytes); } } throw Internal.Refactor.NewNotImplementedException("MapSubresource not implemented for type " + resource.GetType()); }
public override void OnInspectorGUI() { DrawDefaultInspector (); if (GUILayout.Button ("Clean Map")) { cleanMap (); } if (GUILayout.Button ("Generate Backgrounds")) { var map = (TileMap)this.target; var backgrounds = new GameObject (map.nameForBgObject); backgrounds.tag = "Backgrounds"; backgrounds.transform.parent = map.transform; for (int i = 0; i < map.backgrounds.Count; i++) { var newBG = Instantiate (map.backgrounds [i]) as GameObject; newBG.transform.parent = backgrounds.transform; newBG.transform.position = backgrounds.transform.position; newBG.GetComponent<Renderer> ().sortingOrder = (i * -1) - 1; } } if (GUILayout.Button ("Delete Backgrounds")) { var map = (TileMap)this.target; foreach (Transform child in map.transform) { if (child.gameObject.tag == "Backgrounds") { DestroyImmediate (map.transform.Find ("Backgrounds").gameObject); } } } lastTileSize = EditorGUILayout.Vector2Field("Last Tile Size", lastTileSize); newTileSize = EditorGUILayout.Vector2Field("New Tile Size", newTileSize); if (GUILayout.Button("Re align map")) { ReAlignMap(); } enabledMode = (MapMode)EditorGUILayout.EnumPopup (enabledMode); isEditing = EditorGUILayout.Toggle ("Is Editing", isEditing); replaceTiles = EditorGUILayout.Toggle ("Should Replace Tiles", replaceTiles); if (isEditing) { OnEnable (); state = (StateEditor)EditorGUILayout.EnumPopup ("Editing Mode", state); if (state == StateEditor.Mutli) { overrideBottom = EditorGUILayout.Toggle ("Override Bottom", overrideBottom); } } // Tilesets DrawTilesetsPopup(); }
public void map(MapMode mode, byte bank_lo, byte bank_hi, ushort addr_lo, ushort addr_hi, Memory access, uint offset) { map(mode, bank_lo, bank_hi, addr_lo, addr_hi, access, offset, 0); }
public void map(MapMode mode, byte bank_lo, byte bank_hi, ushort addr_lo, ushort addr_hi, Memory access, uint offset, uint size) { Debug.Assert(bank_lo <= bank_hi); Debug.Assert(addr_lo <= addr_hi); if (access.size() == Bit.ToUint32(-1)) { return; } byte page_lo = (byte)(addr_lo >> 8); byte page_hi = (byte)(addr_hi >> 8); uint index = 0; switch (mode) { case MapMode.Direct: { for (uint bank = bank_lo; bank <= bank_hi; bank++) { for (uint page = page_lo; page <= page_hi; page++) { map((bank << 16) + (page << 8), access, (bank << 16) + (page << 8)); } } } break; case MapMode.Linear: { for (uint bank = bank_lo; bank <= bank_hi; bank++) { for (uint page = page_lo; page <= page_hi; page++) { map((bank << 16) + (page << 8), access, mirror(offset + index, access.size())); index += 256; if (Convert.ToBoolean(size)) { index %= size; } } } } break; case MapMode.Shadow: { for (uint bank = bank_lo; bank <= bank_hi; bank++) { index += (uint)(page_lo * 256); if (Convert.ToBoolean(size)) { index %= size; } for (uint page = page_lo; page <= page_hi; page++) { map((bank << 16) + (page << 8), access, mirror(offset + index, access.size())); index += 256; if (Convert.ToBoolean(size)) { index %= size; } } index += (uint)((255 - page_hi) * 256); if (Convert.ToBoolean(size)) { index %= size; } } } break; } }
public YahooMapsProvider(MapMode mode) { var source = new YahooMapsSource(mode); this.MapSources.Add(source.UniqueId, source); }
private BingMapProvider InitializeBingMapProvider(MapMode providerMode, bool isLabelVisible) { if (string.IsNullOrEmpty(BingMapHelper.VEKey)) return null; BingMapProvider provider = new BingMapProvider(providerMode, isLabelVisible, BingMapHelper.VEKey); provider.IsTileCachingEnabled = true; return provider; }
// TODO GRAPHICS REFACTOR what should we do with this? /// <summary> /// Maps a subresource. /// </summary> /// <param name="resource">The resource.</param> /// <param name="subResourceIndex">Index of the sub resource.</param> /// <param name="mapMode">The map mode.</param> /// <param name="doNotWait">if set to <c>true</c> this method will return immediately if the resource is still being used by the GPU for writing. Default is false</param> /// <param name="offsetInBytes">The offset information in bytes.</param> /// <param name="lengthInBytes">The length information in bytes.</param> /// <returns>Pointer to the sub resource to map.</returns> public unsafe MappedResource MapSubresource(GraphicsResource resource, int subResourceIndex, MapMode mapMode, bool doNotWait = false, int offsetInBytes = 0, int lengthInBytes = 0) { if (resource == null) throw new ArgumentNullException("resource"); SharpDX.DataBox dataBox = NativeDeviceContext.MapSubresource(resource.NativeResource, subResourceIndex, (SharpDX.Direct3D11.MapMode)mapMode, doNotWait ? SharpDX.Direct3D11.MapFlags.DoNotWait : SharpDX.Direct3D11.MapFlags.None); var databox = *(DataBox*)Interop.Cast(ref dataBox); if (!dataBox.IsEmpty) { databox.DataPointer = (IntPtr)((byte*)databox.DataPointer + offsetInBytes); } return new MappedResource(resource, subResourceIndex, databox); }
/// <summary> /// Maps the texture, providing CPU access to its contents. /// </summary> /// <param name="mipSlice">The mip slice to map.</param> /// <param name="mode">The IO operations to enable on the CPU.</param> /// <param name="flags">Flags indicating how the CPU should respond when the GPU is busy.</param> /// <param name="dataStream">The data stream.</param> /// <returns> /// A data rectangle containing the mapped data. This data stream is invalidated when the buffer is unmapped. /// </returns> public DataRectangle Map(int mipSlice, MapMode mode, MapFlags flags, out DataStream dataStream) { var desc = Description; int subresource = CalculateSubResourceIndex(mipSlice, 0, desc.MipLevels); int mipHeight = GetMipSize(mipSlice, desc.Height); DataRectangle mappedTexture2D; Map(subresource, mode, flags, out mappedTexture2D); bool canRead = mode == MapMode.Read || mode == MapMode.ReadWrite; bool canWrite = mode != MapMode.Read; dataStream = new DataStream(mappedTexture2D.DataPointer, mipHeight * mappedTexture2D.Pitch, canRead, canWrite); return mappedTexture2D; }
public TileLayer(MapMode mode) { MapMode = mode; }
public YahooMapsSource(MapMode mode) : base(1, 20, 256, 256) { _mapMode = mode; }
public MappedByteBuffer Map (MapMode mode, long pos, int size) { throw new NotImplementedException (); }
/// <summary> /// 获取地图显示模式文本 /// </summary> /// <param name="mode"></param> /// <returns></returns> public static string GetMapModeTitle(MapMode mode) { if (mode == MapMode.Normal) { return "地图"; } if (mode == MapMode.Satellite) { return "卫星图"; } if (mode == MapMode.RoadNet) { return "道路网"; } if (mode == MapMode.Sate_RoadNet) { return "卫星图(路网)"; } return ""; }
/// <summary> /// Maps the texture, providing CPU access to its contents. /// </summary> /// <param name="mipSlice">The mip slice to map.</param> /// <param name="mode">The IO operations to enable on the CPU.</param> /// <param name="flags">Flags indicating how the CPU should respond when the GPU is busy.</param> /// <param name="dataStream">The data stream.</param> /// <returns> /// A databox containing the mapped data. This data stream is invalidated when the buffer is unmapped. /// </returns> public DataBox Map(int mipSlice, MapMode mode, MapFlags flags, out DataStream dataStream) { var desc = Description; int subresource = CalculateSubResourceIndex(mipSlice, 0, desc.MipLevels); DataBox mappedTexture3D; Map(subresource, mode, flags, out mappedTexture3D); bool canRead = mode == MapMode.Read || mode == MapMode.ReadWrite; bool canWrite = mode != MapMode.Read; int mipDepth = GetMipSize(mipSlice, desc.Depth); dataStream = new DataStream(mappedTexture3D.DataPointer, mipDepth * mappedTexture3D.SlicePitch, canRead, canWrite); return mappedTexture3D; }
public void SetMapMode(MapMode mapMode) { _currentState.MapMode = mapMode; }
private MappedResource MapTexture(Texture texture, bool adjustOffsetForSubresource, BufferTarget bufferTarget, int pixelBufferObjectId, int subResourceIndex, MapMode mapMode, int offsetInBytes, int lengthInBytes) { int mipLevel = subResourceIndex % texture.MipLevels; GL.BindBuffer(bufferTarget, pixelBufferObjectId); var mapResult = GL.MapBufferRange(bufferTarget, (IntPtr)offsetInBytes + (adjustOffsetForSubresource ? texture.ComputeBufferOffset(subResourceIndex, 0) : 0), (IntPtr)lengthInBytes, mapMode.ToOpenGLMask()); GL.BindBuffer(bufferTarget, 0); return new MappedResource(texture, subResourceIndex, new DataBox { DataPointer = mapResult, SlicePitch = texture.ComputeSlicePitch(mipLevel), RowPitch = texture.ComputeRowPitch(mipLevel) }, offsetInBytes, lengthInBytes) { PixelBufferObjectId = pixelBufferObjectId, }; }
/// <summary> /// 从服务器上加载瓦片 /// </summary> /// <param name="zoom"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="map_mode"></param> /// <returns></returns> private Bitmap TileFromServer(int zoom, int x, int y, MapMode map_mode) { try { Random r = new Random(DateTime.Now.Millisecond); int server_index = r.Next(0, 10); //随即产生0~9之间的整数 string url = ""; if (map_mode == MapMode.Normal) //地图 { url = String.Format(_road_url, server_index) + "?qt=tile&x=" + x + "&y=" + y + "&z=" + zoom + "&styles=pl"; } if (map_mode == MapMode.Satellite) //卫星图 { url = String.Format(_sate_url, server_index) + "u=x=" + x + ";y=" + y + ";z=" + zoom + ";v=009;type=sate&fm=46"; } if (map_mode == MapMode.RoadNet) //道路网 { url = String.Format(_road_url, server_index) + "?qt=tile&x=" + x + "&y=" + y + "&z=" + zoom + "&styles=sl"; } byte[] bytes = DownloadData(url); Bitmap bitmap = Image.FromStream(new MemoryStream(bytes)) as Bitmap; SaveTile2Cache(zoom, x, y, map_mode, bitmap); return bitmap; } catch { return null; } }
private BingMapProvider InitializeBingMapProvider(MapMode providerMode, bool isLabelVisible) { if (string.IsNullOrEmpty(this.VEKey1)) return null; return new BingMapProvider(providerMode, isLabelVisible, this.VEKey1); }
public DataBox MapSubresource(GraphicsResource resource, int subResourceIndex, MapMode mapMode) { throw new NotImplementedException(); }