예제 #1
0
            public void WriteToParcel(Parcel parcel)
            {
                parcel.WriteUInt32(Width);
                parcel.WriteUInt32(Height);
                parcel.WriteUnmanagedType(ref TransformHint);
                parcel.WriteUInt32(NumPendingBuffers);

                if (TransformHint.HasFlag(NativeWindowTransform.ReturnFrameNumber))
                {
                    parcel.WriteUInt64(FrameNumber);
                }
            }
예제 #2
0
 public void Flattern(Parcel parcel)
 {
     parcel.WriteUnmanagedType(ref Header);
     parcel.WriteUnmanagedType(ref Buffer);
 }
예제 #3
0
 public void Flatten(Parcel parcel)
 {
     parcel.WriteUnmanagedType(ref this);
 }
        public void OnTransact(uint code, uint flags, Parcel inputParcel, Parcel outputParcel)
        {
            Status            status = Status.Success;
            int               slot;
            AndroidFence      fence;
            QueueBufferInput  queueInput;
            QueueBufferOutput queueOutput;
            NativeWindowApi   api;

            AndroidStrongPointer <GraphicBuffer> graphicBuffer;
            AndroidStrongPointer <AndroidFence>  strongFence;

            switch ((TransactionCode)code)
            {
            case TransactionCode.RequestBuffer:
                slot = inputParcel.ReadInt32();

                status = RequestBuffer(slot, out graphicBuffer);

                outputParcel.WriteStrongPointer(ref graphicBuffer);

                outputParcel.WriteStatus(status);

                break;

            case TransactionCode.SetBufferCount:
                int bufferCount = inputParcel.ReadInt32();

                status = SetBufferCount(bufferCount);

                outputParcel.WriteStatus(status);

                break;

            case TransactionCode.DequeueBuffer:
                bool        async  = inputParcel.ReadBoolean();
                uint        width  = inputParcel.ReadUInt32();
                uint        height = inputParcel.ReadUInt32();
                PixelFormat format = inputParcel.ReadUnmanagedType <PixelFormat>();
                uint        usage  = inputParcel.ReadUInt32();

                status      = DequeueBuffer(out int dequeueSlot, out fence, async, width, height, format, usage);
                strongFence = new AndroidStrongPointer <AndroidFence>(fence);

                outputParcel.WriteInt32(dequeueSlot);
                outputParcel.WriteStrongPointer(ref strongFence);

                outputParcel.WriteStatus(status);

                break;

            case TransactionCode.DetachBuffer:
                slot = inputParcel.ReadInt32();

                status = DetachBuffer(slot);

                outputParcel.WriteStatus(status);

                break;

            case TransactionCode.DetachNextBuffer:
                status      = DetachNextBuffer(out graphicBuffer, out fence);
                strongFence = new AndroidStrongPointer <AndroidFence>(fence);

                outputParcel.WriteStrongPointer(ref graphicBuffer);
                outputParcel.WriteStrongPointer(ref strongFence);

                outputParcel.WriteStatus(status);

                break;

            case TransactionCode.AttachBuffer:
                graphicBuffer = inputParcel.ReadStrongPointer <GraphicBuffer>();

                status = AttachBuffer(out slot, graphicBuffer);

                outputParcel.WriteInt32(slot);

                outputParcel.WriteStatus(status);

                break;

            case TransactionCode.QueueBuffer:
                slot       = inputParcel.ReadInt32();
                queueInput = inputParcel.ReadFlattenable <QueueBufferInput>();

                status = QueueBuffer(slot, ref queueInput, out queueOutput);

                outputParcel.WriteUnmanagedType(ref queueOutput);

                outputParcel.WriteStatus(status);

                break;

            case TransactionCode.CancelBuffer:
                slot  = inputParcel.ReadInt32();
                fence = inputParcel.ReadFlattenable <AndroidFence>();

                CancelBuffer(slot, ref fence);

                outputParcel.WriteStatus(Status.Success);

                break;

            case TransactionCode.Query:
                NativeWindowAttribute what = inputParcel.ReadUnmanagedType <NativeWindowAttribute>();

                status = Query(what, out int outValue);

                outputParcel.WriteInt32(outValue);

                outputParcel.WriteStatus(status);

                break;

            case TransactionCode.Connect:
                bool hasListener = inputParcel.ReadBoolean();

                IProducerListener listener = null;

                if (hasListener)
                {
                    throw new NotImplementedException("Connect with a strong binder listener isn't implemented");
                }

                api = inputParcel.ReadUnmanagedType <NativeWindowApi>();

                bool producerControlledByApp = inputParcel.ReadBoolean();

                status = Connect(listener, api, producerControlledByApp, out queueOutput);

                outputParcel.WriteUnmanagedType(ref queueOutput);

                outputParcel.WriteStatus(status);

                break;

            case TransactionCode.Disconnect:
                api = inputParcel.ReadUnmanagedType <NativeWindowApi>();

                status = Disconnect(api);

                outputParcel.WriteStatus(status);

                break;

            case TransactionCode.SetPreallocatedBuffer:
                slot = inputParcel.ReadInt32();

                graphicBuffer = inputParcel.ReadStrongPointer <GraphicBuffer>();

                status = SetPreallocatedBuffer(slot, graphicBuffer);

                outputParcel.WriteStatus(status);

                break;

            default:
                throw new NotImplementedException($"Transaction {(TransactionCode)code} not implemented");
            }

            if (status != Status.Success)
            {
                Logger.PrintError(LogClass.SurfaceFlinger, $"Error returned by transaction {(TransactionCode)code}: {status}");
            }
        }