/* * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System; using ElmSharp; namespace Tizen.Multimedia { internal enum DisplayType { /// /// Overlay surface display. /// Overlay, /// /// Evas image object surface display. /// Surface, /// /// This disposes off buffers. /// None, } internal interface IDisplayable { TError ApplyEvasDisplay(DisplayType type, EvasObject evasObject); TError ApplyEcoreWindow(IntPtr windowHandle); } internal interface IDisplaySetter { TError SetDisplay(IDisplayable target); } internal class EvasDisplaySetter : IDisplaySetter { private readonly DisplayType _type; private readonly EvasObject _target; internal EvasDisplaySetter(DisplayType type, EvasObject target) { if (target == IntPtr.Zero) { throw new ArgumentException("The evas object is not realized."); } _type = type; _target = target; } public TError SetDisplay(IDisplayable target) { return target.ApplyEvasDisplay(_type, _target); } } internal class EcoreDisplaySetter : IDisplaySetter { private readonly IntPtr _windowHandle; internal EcoreDisplaySetter(IntPtr windowHandle) { _windowHandle = windowHandle; } public TError SetDisplay(IDisplayable target) { return target.ApplyEcoreWindow(_windowHandle); } } /// /// Provides a means to wrap various display types. /// /// /// /// public class Display { private readonly IDisplaySetter _setter; /// /// Initializes a new instance of the class with a class. /// /// A to display. /// http://tizen.org/feature/multimedia.raw_video /// The required feature is not supported. public Display(MediaView mediaView) { ValidationUtil.ValidateFeatureSupported(Features.RawVideo); if (mediaView == null) { throw new ArgumentNullException(nameof(mediaView)); } _setter = new EvasDisplaySetter(DisplayType.Surface, mediaView); } /// /// Initializes a new instance of the class with a class. /// /// A to display. public Display(Window window) { if (window == null) { throw new ArgumentNullException(nameof(window)); } _setter = new EvasDisplaySetter(DisplayType.Overlay, window); } /// /// Initializes a new instance of the class with a class. /// /// A to display. /// /// The must be /// for the to be rendered correctly. /// public Display(NUI.Window window) { if (window == null) { throw new ArgumentNullException(nameof(window)); } _setter = new EcoreDisplaySetter(window.GetNativeWindowHandler()); } private EvasObject EvasObject { get; } private DisplayType Type { get; } private object _owner; internal object Owner => _owner; internal void SetOwner(object newOwner) { if (_owner != null && newOwner != null) { throw new ArgumentException("The display has already been assigned to another."); } _owner = newOwner; } internal TError ApplyTo(IDisplayable target) { return _setter.SetDisplay(target); } } }