// Dequeue a job public DequedJob dequeue() { Debug.Assert(Monitor.IsEntered(syncRoot)); var e = pending.GetEnumerator(); if (e.MoveNext()) { Meshes res = e.Current; e.Dispose(); pending.Remove(res); res.state = eState.Running; return(new DequedJob(res)); } e.Dispose(); return(new DequedJob()); }
iTessellatedMeshes postJob(iPathGeometry path, int instance, ref Matrix3x2 tform, eBuildFilledMesh filled, float pixel, sStrokeInfo?stroke) { if (null == path) { throw new ArgumentNullException(); } // We use MD4 to detect changes in re-tessellated polylines. To make that more efficient for small changes of scaling, rounding the precision and pixel values. float precision = pixel.floorBitwise(); Options options = new Options(ref tform, precision, pixel, filled, stroke, false); Meshes meshes; Table table; if (0 == instance) { table = zeroInstances; } else if (1 == instance) { table = oneInstances; } else { var dict = multiTable.GetOrCreateValue(path); if (dict.TryGetValue(instance, out meshes)) { return(updateOldJob(meshes, ref options)); } meshes = new Meshes(path, factory); dict.Add(instance, meshes); return(createNewJob(meshes, ref options)); } if (table.TryGetValue(path, out meshes)) { return(updateOldJob(meshes, ref options)); } meshes = new Meshes(path, factory); table.Add(path, meshes); return(createNewJob(meshes, ref options)); }
iTessellatedMeshes createNewJob(Meshes meshes, ref Options options) { Debug.Assert(!options.separateStrokeMesh); meshes.options = options; lock (queues.syncRoot) { queues.enqueue(meshes); if (threadsRunning >= countThreads) { return(meshes); } threadsRunning++; } ThreadPool.QueueUserWorkItem(postJobCallback); return(meshes); }
iTessellatedMeshes updateOldJob(Meshes meshes, ref Options options) { Debug.Assert(!options.separateStrokeMesh); lock (queues.syncRoot) { Options prevOptions = meshes.options; if (prevOptions.isGoodEnough(ref options) && meshes.hasPolylines) { return(meshes); } meshes.options = options; queues.enqueue(meshes); if (threadsRunning >= countThreads) { return(meshes); } threadsRunning++; } ThreadPool.QueueUserWorkItem(postJobCallback); return(meshes); }
public ExtraStrokeMesh(Meshes owner, iVrmacDraw factory) { this.owner = owner; frontBuffer = factory.createTriangleMesh(); backBuffer = factory.createTriangleMesh(); }
public DequedJob(Meshes meshes) { this.meshes = meshes; options = meshes.options; hash = meshes.hashFront; }