public void RenderTaskSetClearEnabled() { tlog.Debug(tag, $"RenderTaskSetClearEnabled START"); using (Animatable ani = new Animatable()) { var testingTarget = new RenderTask(ani.SwigCPtr.Handle, false); Assert.IsNotNull(testingTarget, "Can't create success object RenderTask."); Assert.IsInstanceOf <RenderTask>(testingTarget, "Should return RenderTask instance."); using (Vector4 color = new Vector4(0.3f, 0.5f, 0.4f, 0.6f)) { try { testingTarget.SetClearEnabled(true); var result = testingTarget.GetClearEnabled(); tlog.Debug(tag, "ClearEnabled : " + result); } catch (Exception e) { tlog.Debug(tag, e.Message.ToString()); Assert.Fail("Caught Exception : Failed!"); } } testingTarget.Dispose(); } tlog.Debug(tag, $"RenderTaskSetClearEnabled END (OK)"); }
/// <summary> /// View which is clipping image and applying mask /// </summary> /// <param name="resourceImageUrl">Image which will be cripped</param> /// <param name="maskImageUrl">Image for masking</param> public ClippingMaskView(string resourceImageUrl, string maskImageUrl) { // Load mask image file and make PixelData PixelData pixelData = PixelBuffer.Convert( ImageLoading.LoadImageFromFile( maskImageUrl, new Size2D(), FittingModeType.ScaleToFill ) ); // Make mask image texture and upload. Texture maskTexture = new Texture( TextureType.TEXTURE_2D, pixelData.GetPixelFormat(), pixelData.GetWidth(), pixelData.GetHeight() ); maskTexture.Upload(pixelData); Size maskImageSize = new Size(maskTexture.GetWidth(), maskTexture.GetHeight()); // Background Image will be clipped BackgroundImage = new ImageView() { PositionUsesPivotPoint = true, PivotPoint = Tizen.NUI.PivotPoint.Center, ParentOrigin = Tizen.NUI.ParentOrigin.Center, Size = maskImageSize, ResourceUrl = resourceImageUrl, }; Add(BackgroundImage); // Set properties for render task Camera camera = new Camera(new Vector2(maskImageSize.Width, maskImageSize.Height)) { PositionUsesPivotPoint = true, PivotPoint = Tizen.NUI.PivotPoint.Center, ParentOrigin = Tizen.NUI.ParentOrigin.Center, }; camera.SetInvertYAxis(true); Add(camera); RenderTask task = NUIApplication.GetDefaultWindow().GetRenderTaskList().CreateTask(); task.SetRefreshRate((uint)RenderTask.RefreshRate.REFRESH_ALWAYS); task.SetSourceView(BackgroundImage); task.SetExclusive(true); task.SetInputEnabled(false); task.SetClearColor(new Vector4(1.0f, 1.0f, 1.0f, 1.0f)); task.SetClearEnabled(true); task.SetCamera(camera); // Clipped Texture Texture clippedTexture = new Texture( TextureType.TEXTURE_2D, PixelFormat.RGBA8888, (uint)maskImageSize.Width, (uint)maskImageSize.Height ); FrameBuffer frameBuffer = new FrameBuffer( (uint)maskImageSize.Width, (uint)maskImageSize.Height, (uint)FrameBuffer.Attachment.Mask.NONE ); frameBuffer.AttachColorTexture(clippedTexture); task.SetFrameBuffer(frameBuffer); /* Create Renderer to apply mask */ PropertyMap vertexFormat = new PropertyMap(); vertexFormat.Add("aPosition", new PropertyValue((int)PropertyType.Vector2)); PropertyBuffer vertexBuffer = new PropertyBuffer(vertexFormat); vertexBuffer.SetData(RectangleDataPtr(), 4); /* Create geometry */ Geometry geometry = new Geometry(); geometry.AddVertexBuffer(vertexBuffer); geometry.SetType(Geometry.Type.TRIANGLE_STRIP); /* Create Shader */ Shader shader = new Shader(VERTEX_SHADER, FRAGMENT_SHADER); TextureSet textureSet = new TextureSet(); textureSet.SetTexture(0u, clippedTexture); textureSet.SetTexture(1u, maskTexture); Renderer renderer = new Renderer(geometry, shader); renderer.SetTextures(textureSet); AddRenderer(renderer); }