1/* 2 * Copyright (C) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import {BaseStruct} from "./BaseStruct.js"; 17import {ColorUtils} from "../component/trace/base/ColorUtils.js"; 18 19export class ProcessMemStruct extends BaseStruct { 20 trackId: number | undefined 21 processName: string | undefined 22 pid: number | undefined 23 upid: number | undefined 24 trackName: string | undefined 25 26 type: string | undefined 27 track_id: string | undefined 28 value: number | undefined 29 startTime: number | undefined 30 duration: number | undefined 31 maxValue: number | undefined 32 delta: number | undefined; 33 34 static draw(ctx: CanvasRenderingContext2D, data: ProcessMemStruct) { 35 if (data.frame) { 36 let width = data.frame.width || 0; 37 ctx.fillStyle = ColorUtils.colorForTid(data.maxValue || 0) 38 ctx.strokeStyle = ColorUtils.colorForTid(data.maxValue || 0) 39 ctx.globalAlpha = 0.6; 40 ctx.lineWidth = 1; 41 let drawHeight: number = ((data.value || 0) * (data.frame.height || 0) * 1.0) / (data.maxValue || 1); 42 ctx.fillRect(data.frame.x, data.frame.y + data.frame.height - drawHeight, width, drawHeight) 43 } 44 ctx.globalAlpha = 1.0; 45 ctx.lineWidth = 1; 46 } 47} 48