コード例 #1
0
            public void StartTask(ImageToProcessItem imageToProcess)
            {
                currentTask = imageToProcess;

                try
                {
                    CreatePreviewGeneratorForResource(imageToProcess.virtualFileName, out var objectOfPreview, out generator);

                    if (generator != null)
                    {
                        generator.Init(viewport, objectOfPreview);

                        viewport.Update(true);

                        //clear temp data
                        viewport.RenderingContext.MultiRenderTarget_DestroyAll();
                        viewport.RenderingContext.DynamicTexture_DestroyAll();

                        texture.Result.GetRealObject(true).BlitTo(viewport.RenderingContext.CurrentViewNumber, textureRead.Result.GetRealObject(true), 0, 0);

                        demandedFrame = textureRead.Result.GetRealObject(true).Read(imageData, 0);
                    }
                    else
                    {
                        ClearTask();
                    }
                }
                catch (Exception e)
                {
                    Log.Warning(e.Message);
                }
            }
コード例 #2
0
            public void ClearTask()
            {
                if (viewport != null)
                {
                    viewport.AttachedScene = null;
                }

                generator?.DetachAndOrDestroyScene();

                currentTask   = null;
                generator     = null;
                demandedFrame = -1;
            }
コード例 #3
0
        public static void AddResourceToProcess(string realFileName)
        {
            try
            {
                var resourceType = ResourceManager.GetTypeByFileExtension(Path.GetExtension(realFileName));
                if (resourceType != null && IsResourceTypeSupported(resourceType))
                {
                    var virtualFileName = VirtualPathUtility.GetVirtualPathByReal(realFileName);
                    if (!string.IsNullOrEmpty(virtualFileName))
                    {
                        //reload already loaded preview
                        var loadedItem = GetLoadedPreview(virtualFileName);
                        if (loadedItem != null)
                        {
                            loadedItem.needReload = true;
                        }

                        //check already added
                        if (GetImageToProcessItemInQueue(virtualFileName) == null)
                        {
                            //too much in queue
                            if (imagesToProcess.Count < maxQueueOfImagesToProcess)
                            {
                                //was added
                                var item = new ImageToProcessItem();
                                item.virtualFileName = virtualFileName;
                                imagesToProcess.Enqueue(item);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Log.Warning("PreviewImagesManager: NeedRefreshResource: " + e.Message);
            }
        }