Beispiel #1
0
        private static object OnNewInlayRequest(NewInlayRequest request)
        {
            var size = new Size(request.Width, request.Height);
            BaseRenderHandler renderHandler = request.FrameTransportMode switch
            {
                FrameTransportMode.SharedTexture => new TextureRenderHandler(size),
                FrameTransportMode.BitmapBuffer => new BitmapBufferRenderHandler(size),
                _ => throw new Exception($"Unhandled frame transport mode {request.FrameTransportMode}"),
            };

            var inlay = new Inlay(request.Url, renderHandler);

            inlay.Initialise();
            inlays.Add(request.Guid, inlay);

            renderHandler.CursorChanged += (sender, cursor) =>
            {
                ipcBuffer.RemoteRequest <object>(new SetCursorRequest()
                {
                    Guid   = request.Guid,
                    Cursor = cursor
                });
            };

            return(BuildRenderHandlerResponse(renderHandler));
        }
Beispiel #2
0
        private static void Run(RenderProcessArguments args)
        {
            waitHandle = new EventWaitHandle(false, EventResetMode.ManualReset, args.KeepAliveHandleName);

            // Boot up a thread to make sure we shut down if parent dies
            parentWatchThread = new Thread(WatchParentStatus);
            parentWatchThread.Start(args.ParentPid);

#if DEBUG
            AppDomain.CurrentDomain.FirstChanceException += (obj, e) => Console.Error.WriteLine(e.Exception.ToString());
#endif

            var dxRunning = DxHandler.Initialise(args.DxgiAdapterLuid);
            CefHandler.Initialise(cefAssemblyDir, args.CefCacheDir);

            ipcBuffer = new IpcBuffer <DownstreamIpcRequest, UpstreamIpcRequest>(args.IpcChannelName, HandleIpcRequest);

            Console.WriteLine("Notifiying on ready state.");

            // We always support bitmap buffer transport
            var availableTransports = FrameTransportMode.BitmapBuffer;
            if (dxRunning)
            {
                availableTransports |= FrameTransportMode.SharedTexture;
            }

            ipcBuffer.RemoteRequest <object>(new ReadyNotificationRequest()
            {
                availableTransports = availableTransports,
            });

            Console.WriteLine("Waiting...");

            waitHandle.WaitOne();
            waitHandle.Dispose();

            Console.WriteLine("Render process shutting down.");

            ipcBuffer.Dispose();

            DxHandler.Shutdown();
            CefHandler.Shutdown();

            parentWatchThread.Abort();
        }