Пример #1
0
        public bool CloseLayer(long layerId)
        {
            lock (Lock)
            {
                Layer layer = GetLayerByIdLocked(layerId);

                if (layer != null)
                {
                    HOSBinderDriverServer.UnregisterBinderObject(layer.ProducerBinderId);
                }

                bool removed = _layers.Remove(layerId);

                // If the layer was removed and the current in use, we need to change the current layer in use.
                if (removed && RenderLayerId == layerId)
                {
                    // If no layer is availaible, reset to default value.
                    if (_layers.Count == 0)
                    {
                        SetRenderLayer(0);
                    }
                    else
                    {
                        SetRenderLayer(_layers.Last().Key);
                    }
                }

                return(removed);
            }
        }
Пример #2
0
        private void CreateLayerFromId(long pid, long layerId)
        {
            lock (Lock)
            {
                Logger.Info?.Print(LogClass.SurfaceFlinger, $"Creating layer {layerId}");

                BufferQueueCore core = BufferQueue.CreateBufferQueue(_device, pid, out BufferQueueProducer producer, out BufferQueueConsumer consumer);

                core.BufferQueued += () =>
                {
                    _nextFrameEvent.Set();
                };

                _layers.Add(layerId, new Layer
                {
                    ProducerBinderId = HOSBinderDriverServer.RegisterBinderObject(producer),
                    Producer         = producer,
                    Consumer         = new BufferItemConsumer(_device, consumer, 0, -1, false, this),
                    Core             = core,
                    Owner            = pid
                });

                LastId = layerId;
            }
        }
Пример #3
0
        public ResultCode DestroyStrayLayer(long layerId)
        {
            lock (Lock)
            {
                Layer layer = GetLayerByIdLocked(layerId);

                if (layer == null)
                {
                    Logger.Error?.Print(LogClass.SurfaceFlinger, $"Failed to destroy stray layer {layerId} (not found)");

                    return(ResultCode.InvalidValue);
                }

                if (layer.State != LayerState.Stray)
                {
                    Logger.Error?.Print(LogClass.SurfaceFlinger, $"Failed to destroy stray layer {layerId} (permission denied)");

                    return(ResultCode.PermissionDenied);
                }

                HOSBinderDriverServer.UnregisterBinderObject(layer.ProducerBinderId);

                if (_layers.Remove(layerId))
                {
                    CloseLayer(layerId, layer);
                }

                return(ResultCode.Success);
            }
        }
Пример #4
0
        public bool CloseLayer(long layerId)
        {
            lock (Lock)
            {
                Layer layer = GetLayerByIdLocked(layerId);

                if (layer != null)
                {
                    HOSBinderDriverServer.UnregisterBinderObject(layer.ProducerBinderId);
                }

                return(_layers.Remove(layerId));
            }
        }
Пример #5
0
        public void WriteObject <T>(T obj, string serviceName) where T : IBinder
        {
            FlatBinderObject flatBinderObject = new FlatBinderObject
            {
                Type     = 2,
                Flags    = 0,
                BinderId = HOSBinderDriverServer.GetBinderId(obj),
            };

            Encoding.ASCII.GetBytes(serviceName).CopyTo(flatBinderObject.ServiceName);

            WriteUnmanagedType(ref flatBinderObject);

            // TODO: figure out what this value is

            WriteInplaceObject(new byte[4] {
                0, 0, 0, 0
            });
        }
Пример #6
0
        private void CreateLayerFromId(KProcess process, long layerId)
        {
            lock (Lock)
            {
                Logger.PrintInfo(LogClass.SurfaceFlinger, $"Creating layer {layerId}");

                BufferQueue.CreateBufferQueue(_device, process, out BufferQueueProducer producer, out BufferQueueConsumer consumer);

                _layers.Add(layerId, new Layer
                {
                    ProducerBinderId = HOSBinderDriverServer.RegisterBinderObject(producer),
                    Producer         = producer,
                    Consumer         = new BufferItemConsumer(_device, consumer, 0, -1, false, this),
                    Owner            = process
                });

                LastId = layerId;
            }
        }