protected sealed override void CreateDrawingSurface() { if (glSurface == IntPtr.Zero) { // create the surface glSurface = Evas.evas_gl_surface_create(glEvas, glConfigPtr, surfaceSize.Width, surfaceSize.Height); // copy the native surface to the image Evas.evas_gl_native_surface_get(glEvas, glSurface, out var nativeSurface); Evas.evas_object_image_native_surface_set(evasImage, ref nativeSurface); // switch to the current OpenGL context Evas.evas_gl_make_current(glEvas, glSurface, glContext); // resize the viewport Gles.glViewport(0, 0, surfaceSize.Width, surfaceSize.Height); // create the interface using the function pointers provided by the EFL var glInterface = GRGlInterface.CreateNativeEvasInterface(glEvas); context?.Dispose(); context = GRContext.Create(GRBackend.OpenGL, glInterface); // create the render target renderTarget?.Dispose(); Gles.glGetIntegerv(Gles.GL_FRAMEBUFFER_BINDING, out var framebuffer); Gles.glGetIntegerv(Gles.GL_STENCIL_BITS, out var stencil); var glInfo = new GRGlFramebufferInfo((uint)framebuffer, colorType.ToGlSizedFormat()); renderTarget = new GRBackendRenderTarget(surfaceSize.Width, surfaceSize.Height, context.GetMaxSurfaceSampleCount(colorType), stencil, glInfo); // create the surface surface?.Dispose(); surface = SKSurface.Create(context, renderTarget, surfaceOrigin, colorType); } }
private void CreateSurface() { if (glSurface == IntPtr.Zero) { // create the surface glSurface = Evas.evas_gl_surface_create(glEvas, glConfigPtr, renderTarget.Width, renderTarget.Height); // copy the native surface to the image Evas.NativeSurfaceOpenGL nativeSurface; Evas.evas_gl_native_surface_get(glEvas, glSurface, out nativeSurface); Evas.evas_object_image_native_surface_set(evasImage, ref nativeSurface); // switch to the current OpenGL context Evas.evas_gl_make_current(glEvas, glSurface, glContext); // resize the viewport Gles.glViewport(0, 0, renderTarget.Width, renderTarget.Height); // initialize the Skia's context CreateContext(); // copy the properties of the current surface var currentRenderTarget = SKGLDrawable.CreateRenderTarget(); renderTarget.SampleCount = currentRenderTarget.SampleCount; renderTarget.StencilBits = currentRenderTarget.StencilBits; renderTarget.RenderTargetHandle = currentRenderTarget.RenderTargetHandle; } }
protected sealed override void CreateDrawingSurface() { if (glSurface == IntPtr.Zero) { // create the surface glSurface = Evas.evas_gl_surface_create(glEvas, glConfigPtr, surfaceSize.Width, surfaceSize.Height); // copy the native surface to the image Evas.evas_gl_native_surface_get(glEvas, glSurface, out var nativeSurface); Evas.evas_object_image_native_surface_set(evasImage, ref nativeSurface); // switch to the current OpenGL context Evas.evas_gl_make_current(glEvas, glSurface, glContext); // resize the viewport Gles.glViewport(0, 0, surfaceSize.Width, surfaceSize.Height); // create the interface using the function pointers provided by the EFL var glInterface = GRGlInterface.CreateNativeEvasInterface(glEvas); context?.Dispose(); context = GRContext.Create(GRBackend.OpenGL, glInterface); // create the render target renderTarget?.Dispose(); renderTarget = SKGLDrawable.CreateRenderTarget(surfaceSize.Width, surfaceSize.Height); // create the surface surface?.Dispose(); surface = SKSurface.Create(context, renderTarget, GRSurfaceOrigin.BottomLeft, SKImageInfo.PlatformColorType); } }
protected void OnResized() { var geometry = Geometry; // control is not yet fully initialized if (geometry.Width <= 0 || geometry.Height <= 0) { return; } if (UpdateSurfaceSize(geometry)) { // disconnect the callback Evas.evas_object_image_native_surface_set(evasImage, IntPtr.Zero); // recreate the drawing surface to match the new size DestroyDrawingSurface(); var size = GetSurfaceSize(); Evas.evas_object_image_size_set(evasImage, size.Width, size.Height); CreateDrawingSurface(); // set the image callback; will be invoked when image is marked as dirty Evas.evas_object_image_pixels_get_callback_set(evasImage, redrawCallback, IntPtr.Zero); // repaint Invalidate(); } }
public void Invalidate() { if (RenderingMode == RenderingMode.WhenDirty) { Evas.evas_object_image_pixels_dirty_set(evasImage, true); } }
protected sealed override void CreateNativeResources(EvasObject parent) { if (glEvas == IntPtr.Zero) { // initialize the OpenGL (the EFL way) glEvas = Evas.evas_gl_new(Evas.evas_object_evas_get(parent)); // copy the configuration to the native side glConfigPtr = Marshal.AllocHGlobal(Marshal.SizeOf(glConfig)); Marshal.StructureToPtr(glConfig, glConfigPtr, false); // try initialize the context with Open GL ES 3.x first glContext = Evas.evas_gl_context_version_create(glEvas, IntPtr.Zero, Evas.GLContextVersion.EVAS_GL_GLES_3_X); // if we could not get 3.x, try 2.x if (glContext == IntPtr.Zero) { Log.Debug("SKGLSurfaceView", "OpenGL ES 3.x was not available, trying 2.x."); glContext = Evas.evas_gl_context_version_create(glEvas, IntPtr.Zero, Evas.GLContextVersion.EVAS_GL_GLES_2_X); } // if that is not available, the default if (glContext == IntPtr.Zero) { Log.Debug("SKGLSurfaceView", "OpenGL ES 2.x was not available, trying the default."); glContext = Evas.evas_gl_context_create(glEvas, IntPtr.Zero); } } }
protected sealed override void OnDrawFrame() { // draw directly into the EFL image data using (var surface = SKSurface.Create(info, Evas.evas_object_image_data_get(evasImage, true), info.RowBytes)) { // draw using SkiaSharp OnDrawFrame(new SKPaintSurfaceEventArgs(surface, info)); surface.Canvas.Flush(); } }
private void CreateAnimator() { if (animator == IntPtr.Zero) { animator = EcoreAnimator.AddAnimator(() => { Evas.evas_object_image_pixels_dirty_set(evasImage, true); return(true); }); } }
protected sealed override void CreateDrawingSurface() { if (glSurface == IntPtr.Zero) { // create the surface glSurface = Evas.evas_gl_surface_create(glEvas, glConfigPtr, surfaceSize.Width, surfaceSize.Height); // copy the native surface to the image Evas.evas_gl_native_surface_get(glEvas, glSurface, out var nativeSurface); Evas.evas_object_image_native_surface_set(evasImage, ref nativeSurface); // switch to the current OpenGL context Evas.evas_gl_make_current(glEvas, glSurface, glContext); // resize the viewport Gles.glViewport(0, 0, surfaceSize.Width, surfaceSize.Height); // create the interface using the function pointers provided by the EFL var glInterface = GRGlInterface.CreateEvas(glEvas); if (glInterface == null) { Log.Error("SKGLSurfaceView", "Unable to create GRGlInterface."); } if (!glInterface.Validate()) { Log.Error("SKGLSurfaceView", "The created GRGlInterface was not valid."); } context?.Dispose(); context = GRContext.CreateGl(glInterface); if (context == null) { Log.Error("SKGLSurfaceView", "Unable to create the GRContext."); } // create the render target renderTarget?.Dispose(); Gles.glGetIntegerv(Gles.GL_FRAMEBUFFER_BINDING, out var framebuffer); Gles.glGetIntegerv(Gles.GL_STENCIL_BITS, out var stencil); Gles.glGetIntegerv(Gles.GL_SAMPLES, out var samples); var maxSamples = context.GetMaxSurfaceSampleCount(colorType); if (samples > maxSamples) { samples = maxSamples; } glInfo = new GRGlFramebufferInfo((uint)framebuffer, colorType.ToGlSizedFormat()); renderTarget = new GRBackendRenderTarget(surfaceSize.Width, surfaceSize.Height, samples, stencil, glInfo); // create the surface surface?.Dispose(); surface = SKSurface.Create(context, renderTarget, surfaceOrigin, colorType); canvas = surface.Canvas; } }
protected sealed override void CreateNativeResources(EvasObject parent) { if (glEvas == IntPtr.Zero) { // initialize the OpenGL (the EFL way) glEvas = Evas.evas_gl_new(Evas.evas_object_evas_get(parent)); // copy the configuration to the native side glConfigPtr = Marshal.AllocHGlobal(Marshal.SizeOf(glConfig)); Marshal.StructureToPtr(glConfig, glConfigPtr, false); // initialize the context glContext = Evas.evas_gl_context_create(glEvas, IntPtr.Zero); } }
private void DestroySurface() { if (glSurface != IntPtr.Zero) { // finalize the Skia's context DestroyContext(); // disconnect the surface from the image Evas.evas_object_image_native_surface_set(evasImage, IntPtr.Zero); // destroy the surface Evas.evas_gl_surface_destroy(glEvas, glSurface); glSurface = IntPtr.Zero; } }
private void DestroyGL() { if (glEvas != IntPtr.Zero) { // destroy the context Evas.evas_gl_context_destroy(glEvas, glContext); glContext = IntPtr.Zero; // release the unmanaged memory Marshal.FreeHGlobal(glConfigPtr); glConfigPtr = IntPtr.Zero; // destroy the EFL wrapper Evas.evas_gl_free(glEvas); glEvas = IntPtr.Zero; } }
protected sealed override IntPtr CreateHandle(EvasObject parent) { var handle = Interop.Elementary.elm_layout_add(parent); Interop.Elementary.elm_layout_theme_set(handle, "layout", "background", "default"); evasImage = Evas.evas_object_image_filled_add(Interop.Evas.evas_object_evas_get(handle)); Evas.evas_object_image_colorspace_set(evasImage, Evas.Colorspace.ARGB8888); Evas.evas_object_image_smooth_scale_set(evasImage, true); Evas.evas_object_image_alpha_set(evasImage, true); Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", evasImage); CreateNativeResources(parent); return(handle); }
protected sealed override void DestroyNativeResources() { if (glEvas != IntPtr.Zero) { // destroy the context Evas.evas_gl_context_destroy(glEvas, glContext); glContext = IntPtr.Zero; // release the unmanaged memory Marshal.FreeHGlobal(glConfigPtr); glConfigPtr = IntPtr.Zero; // destroy the EFL wrapper Evas.evas_gl_free(glEvas); glEvas = IntPtr.Zero; } }
internal static void elm_object_focused_clear(IntPtr handle) { if (elm_widget_is(handle)) { efl_ui_widget_focused_object_clear(handle); } else { Evas.evas_object_focus_set(handle, false); } IntPtr win = elm_widget_top_get(handle); if (win != IntPtr.Zero && Eo.efl_class_name_get(Eo.efl_class_get(win)) == "Efl.Ui.Win") { Evas.evas_object_focus_set(win, true); } }
protected sealed override void DestroyDrawingSurface() { if (glSurface != IntPtr.Zero) { // dispose the unmanaged memory surface?.Dispose(); surface = null; renderTarget?.Dispose(); renderTarget = null; context?.Dispose(); context = null; // disconnect the surface from the image Evas.evas_object_image_native_surface_set(evasImage, IntPtr.Zero); // destroy the surface Evas.evas_gl_surface_destroy(glEvas, glSurface); glSurface = IntPtr.Zero; } }
protected static extern ListItemPtr elm_list_item_sorted_insert(IntPtr obj, string label, IntPtr icon, IntPtr end, Evas.EvasSmartCallback func, IntPtr data);
public static Evas.EvasObject AddEvas(Evas.Evas evas) { return new Evas.EvasObject( new Evas.EvasObjectPtr( edje_object_add(evas.Raw))); }
protected static extern IntPtr edje_object_add(Evas.EvasPtr evasPtr);
public Button(Evas.EvasObject parent, string label) : this(parent) { Text = label; }
public Image(Evas.EvasObject parent) { this.Raw.Pointer = elm_image_add(parent.Raw.Pointer); }
public Entry(Evas.EvasObject parent) { Raw.Pointer = elm_entry_add (parent.Raw.Pointer); }
public Hoversel(Evas.EvasObject parent) { Raw.Pointer = elm_hoversel_add (parent.Raw.Pointer); }
public void ExternObjectMaxSizeSet(Evas.Item o, int maxw, int maxh) { edje_extern_object_max_size_set(o.Raw, maxw, maxh); }
public void PackStart(Evas.EvasObject child) { elm_box_pack_start(this.Raw.Pointer, child.Raw.Pointer); }
public Frame(Evas.EvasObject parent) { Raw.Pointer = elm_frame_add (parent.Raw.Pointer); }
public Label(Evas.EvasObject parent, string text) : this(parent) { this.Text = text; }
public ListItemPtr SortedInsert(string label, IntPtr iconLeft, IntPtr iconRight, Evas.EvasSmartCallback onClicked, object data) { return elm_list_item_sorted_insert (this.Raw.Pointer, label, iconLeft, iconRight, onClicked, GetPtrToObject (data)); }
public List(Evas.EvasObject parent) { this.Raw.Pointer = elm_list_add (parent.Raw.Pointer); }
public void PartUnswallow(Evas.Item obj_swallow) { edje_object_part_unswallow(Raw, obj_swallow.Raw); }
public ListItemPtr InsertBefore(string label, ListItemPtr before, IntPtr iconLeft, IntPtr iconRight, Evas.EvasSmartCallback onClicked, object data) { return elm_list_item_insert_before (this.Raw.Pointer, before, label, iconLeft, iconRight, onClicked, GetPtrToObject (data)); }
public void PartSwallow(string part, Evas.Item obj_swallow) { edje_object_part_swallow(Raw, part, obj_swallow.Raw); }
public Check(Evas.EvasObject parent) { Raw.Pointer = elm_check_add (parent.Raw.Pointer); }
public void ExternObjectMinSizeSet(Evas.Item o, int minw, int minh) { edje_extern_object_min_size_set(o.Raw, minw, minh); }
private static extern IntPtr edje_object_add(Evas.EvasPtr evasPtr);
public void ResizeObjectAdd(Evas.EvasObject subobj) { elm_win_resize_object_add (this.Raw.Pointer, subobj.Raw.Pointer); }
public Button(Evas.EvasObject parent) { Raw.Pointer = elm_button_add (parent.Raw.Pointer); }
public Box(Evas.EvasObject parent) { Raw.Pointer = elm_box_add (parent.Raw.Pointer); }
public ScrolledEntry(Evas.EvasObject parent) { Raw.Pointer = elm_scrolled_entry_add (parent.Raw.Pointer); }
public void PackEnd(Evas.EvasObject child) { elm_box_pack_end(this.Raw.Pointer, child.Raw.Pointer); }
public Label(Evas.EvasObject parent) { Raw.Pointer = elm_label_add (parent.Raw.Pointer); }