2 * Copyright(c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.ComponentModel;
25 /// NativeImageQueue is a class for displaying an image resource using queue.
29 /// NativeImageQueue queue = new NativeImageQueue(width,height,ColorDepth.Default);
30 /// if(queue.CanDequeueBuffer())
32 /// var buffer = queue.DequeueBuffer(ref bufferWidth,ref bufferHeight,ref bufferStride);
36 /// queue.EnqueueBuffer(buffer);
40 [EditorBrowsable(EditorBrowsableState.Never)]
41 public class NativeImageQueue : NativeImageInterface
43 private IntPtr handle;
46 /// Creates an initialized NativeImageQueue with size and color depth.
48 /// <param name="width">A Width of queue.</param>
49 /// <param name="height">A Height of queue.</param>
50 /// <param name="depth">A color depth of queue.</param>
51 /// <returns>A NativeImageQueue.</returns>
52 [EditorBrowsable(EditorBrowsableState.Never)]
53 public NativeImageQueue(uint width, uint height, NativeImageSource.ColorDepth depth) : this(Interop.NativeImageQueue.NewHandle(width, height, (int)depth), true)
55 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
58 internal NativeImageQueue(IntPtr cPtr, bool cMemoryOwn) : base(Interop.NativeImageQueue.Get(cPtr), cMemoryOwn)
64 /// Generate Url from native image queue.
66 /// <returns>The ImageUrl of NativeImageQueue.</returns>
67 [EditorBrowsable(EditorBrowsableState.Never)]
68 public ImageUrl GenerateUrl()
70 ImageUrl ret = new ImageUrl(Interop.NativeImageSource.GenerateUrl(this.SwigCPtr.Handle), true);
71 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
75 [EditorBrowsable(EditorBrowsableState.Never)]
76 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
78 Interop.NativeImageQueue.Delete(handle);
79 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
82 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(NativeImageQueue obj)
84 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
88 /// Checks if the buffer can be got from the queue.
90 /// <returns>True if the buffer can be got from the queue.</returns>
91 [EditorBrowsable(EditorBrowsableState.Never)]
92 public bool CanDequeueBuffer()
94 bool ret = Interop.NativeImageQueue.CanDequeueBuffer(this.SwigCPtr.Handle);
95 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
100 /// Dequeue buffer from the queue.
102 /// <param name="width">A reference to the buffer's width.</param>
103 /// <param name="height">A reference to the buffer's height.</param>
104 /// <param name="stride">A reference to the buffer's stride.</param>
105 /// <returns>A handle of buffer.</returns>
106 [EditorBrowsable(EditorBrowsableState.Never)]
107 public IntPtr DequeueBuffer(ref int width, ref int height, ref int stride)
109 IntPtr ret = Interop.NativeImageQueue.DequeueBuffer(this.SwigCPtr.Handle, ref width, ref height, ref stride);
110 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
115 /// Enqueue buffer to the queue.
117 /// <param name="buffer">A Handle of buffer to be enqueued.</param>
118 /// <returns>True if success.</returns>
119 [EditorBrowsable(EditorBrowsableState.Never)]
120 public bool EnqueueBuffer(IntPtr buffer)
122 bool ret = Interop.NativeImageQueue.EnqueueBuffer(this.SwigCPtr.Handle, buffer);
123 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();