// Copyright © 2020 The CefSharp Authors. All rights reserved. // // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. namespace CefSharp.DevTools.LayerTree { using System.Linq; /// /// LayerTree /// public partial class LayerTree : DevToolsDomainBase { private CefSharp.DevTools.IDevToolsClient _client; public LayerTree(CefSharp.DevTools.IDevToolsClient client) { _client = (client); } partial void ValidateCompositingReasons(string layerId); /// /// Provides the reasons why the given layer was composited. /// /// The id of the layer for which we want to get the reasons it was composited. /// returns System.Threading.Tasks.Task<CompositingReasonsResponse> public async System.Threading.Tasks.Task CompositingReasonsAsync(string layerId) { ValidateCompositingReasons(layerId); var dict = new System.Collections.Generic.Dictionary(); dict.Add("layerId", layerId); var methodResult = await _client.ExecuteDevToolsMethodAsync("LayerTree.compositingReasons", dict); return methodResult.DeserializeJson(); } /// /// Disables compositing tree inspection. /// /// returns System.Threading.Tasks.Task<DevToolsMethodResponse> public async System.Threading.Tasks.Task DisableAsync() { System.Collections.Generic.Dictionary dict = null; var methodResult = await _client.ExecuteDevToolsMethodAsync("LayerTree.disable", dict); return methodResult; } /// /// Enables compositing tree inspection. /// /// returns System.Threading.Tasks.Task<DevToolsMethodResponse> public async System.Threading.Tasks.Task EnableAsync() { System.Collections.Generic.Dictionary dict = null; var methodResult = await _client.ExecuteDevToolsMethodAsync("LayerTree.enable", dict); return methodResult; } partial void ValidateLoadSnapshot(System.Collections.Generic.IList tiles); /// /// Returns the snapshot identifier. /// /// An array of tiles composing the snapshot. /// returns System.Threading.Tasks.Task<LoadSnapshotResponse> public async System.Threading.Tasks.Task LoadSnapshotAsync(System.Collections.Generic.IList tiles) { ValidateLoadSnapshot(tiles); var dict = new System.Collections.Generic.Dictionary(); dict.Add("tiles", tiles.Select(x => x.ToDictionary())); var methodResult = await _client.ExecuteDevToolsMethodAsync("LayerTree.loadSnapshot", dict); return methodResult.DeserializeJson(); } partial void ValidateMakeSnapshot(string layerId); /// /// Returns the layer snapshot identifier. /// /// The id of the layer. /// returns System.Threading.Tasks.Task<MakeSnapshotResponse> public async System.Threading.Tasks.Task MakeSnapshotAsync(string layerId) { ValidateMakeSnapshot(layerId); var dict = new System.Collections.Generic.Dictionary(); dict.Add("layerId", layerId); var methodResult = await _client.ExecuteDevToolsMethodAsync("LayerTree.makeSnapshot", dict); return methodResult.DeserializeJson(); } partial void ValidateProfileSnapshot(string snapshotId, int? minRepeatCount = null, long? minDuration = null, CefSharp.DevTools.DOM.Rect clipRect = null); /// /// ProfileSnapshot /// /// The id of the layer snapshot. /// The maximum number of times to replay the snapshot (1, if not specified). /// The minimum duration (in seconds) to replay the snapshot. /// The clip rectangle to apply when replaying the snapshot. /// returns System.Threading.Tasks.Task<ProfileSnapshotResponse> public async System.Threading.Tasks.Task ProfileSnapshotAsync(string snapshotId, int? minRepeatCount = null, long? minDuration = null, CefSharp.DevTools.DOM.Rect clipRect = null) { ValidateProfileSnapshot(snapshotId, minRepeatCount, minDuration, clipRect); var dict = new System.Collections.Generic.Dictionary(); dict.Add("snapshotId", snapshotId); if (minRepeatCount.HasValue) { dict.Add("minRepeatCount", minRepeatCount.Value); } if (minDuration.HasValue) { dict.Add("minDuration", minDuration.Value); } if ((clipRect) != (null)) { dict.Add("clipRect", clipRect.ToDictionary()); } var methodResult = await _client.ExecuteDevToolsMethodAsync("LayerTree.profileSnapshot", dict); return methodResult.DeserializeJson(); } partial void ValidateReleaseSnapshot(string snapshotId); /// /// Releases layer snapshot captured by the back-end. /// /// The id of the layer snapshot. /// returns System.Threading.Tasks.Task<DevToolsMethodResponse> public async System.Threading.Tasks.Task ReleaseSnapshotAsync(string snapshotId) { ValidateReleaseSnapshot(snapshotId); var dict = new System.Collections.Generic.Dictionary(); dict.Add("snapshotId", snapshotId); var methodResult = await _client.ExecuteDevToolsMethodAsync("LayerTree.releaseSnapshot", dict); return methodResult; } partial void ValidateReplaySnapshot(string snapshotId, int? fromStep = null, int? toStep = null, long? scale = null); /// /// Replays the layer snapshot and returns the resulting bitmap. /// /// The id of the layer snapshot. /// The first step to replay from (replay from the very start if not specified). /// The last step to replay to (replay till the end if not specified). /// The scale to apply while replaying (defaults to 1). /// returns System.Threading.Tasks.Task<ReplaySnapshotResponse> public async System.Threading.Tasks.Task ReplaySnapshotAsync(string snapshotId, int? fromStep = null, int? toStep = null, long? scale = null) { ValidateReplaySnapshot(snapshotId, fromStep, toStep, scale); var dict = new System.Collections.Generic.Dictionary(); dict.Add("snapshotId", snapshotId); if (fromStep.HasValue) { dict.Add("fromStep", fromStep.Value); } if (toStep.HasValue) { dict.Add("toStep", toStep.Value); } if (scale.HasValue) { dict.Add("scale", scale.Value); } var methodResult = await _client.ExecuteDevToolsMethodAsync("LayerTree.replaySnapshot", dict); return methodResult.DeserializeJson(); } partial void ValidateSnapshotCommandLog(string snapshotId); /// /// Replays the layer snapshot and returns canvas log. /// /// The id of the layer snapshot. /// returns System.Threading.Tasks.Task<SnapshotCommandLogResponse> public async System.Threading.Tasks.Task SnapshotCommandLogAsync(string snapshotId) { ValidateSnapshotCommandLog(snapshotId); var dict = new System.Collections.Generic.Dictionary(); dict.Add("snapshotId", snapshotId); var methodResult = await _client.ExecuteDevToolsMethodAsync("LayerTree.snapshotCommandLog", dict); return methodResult.DeserializeJson(); } } }