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 { ColorUtils } from '../../../component/trace/base/ColorUtils'; 17import { drawLoadingFrame, hiPerf, hiPerf2, HiPerfStruct, PerfRender, RequestMessage } from '../ProcedureWorkerCommon'; 18import { TraceRow } from '../../../component/trace/base/TraceRow'; 19 20export class HiperfThreadRender2 extends PerfRender { 21 renderMainThread(req: any, row: TraceRow<HiPerfThreadStruct>): void { 22 let hiperfThreadFilter = row.dataListCache; 23 let groupBy10MS = req.scale > 30_000_000; 24 let textMetrics; 25 if (!groupBy10MS) { 26 req.context.font = 'normal 12px Arial'; 27 textMetrics = req.context.measureText('��'); 28 } 29 hiPerf2(hiperfThreadFilter, TraceRow.range?.startNS ?? 0, TraceRow.range?.endNS ?? 0, row.frame); 30 drawLoadingFrame(req.context, hiperfThreadFilter, row); 31 req.context.beginPath(); 32 req.context.fillStyle = ColorUtils.FUNC_COLOR[0]; 33 req.context.strokeStyle = ColorUtils.FUNC_COLOR[0]; 34 let normalPath = new Path2D(); 35 let specPath = new Path2D(); 36 let offset = groupBy10MS ? 0 : 3; 37 let find = false; 38 for (let re of hiperfThreadFilter) { 39 HiPerfThreadStruct.draw(req.context, normalPath, specPath, re, groupBy10MS, textMetrics); 40 if (row.isHover) { 41 if (re.frame && row.hoverX >= re.frame.x - offset && row.hoverX <= re.frame.x + re.frame.width + offset) { 42 HiPerfThreadStruct.hoverStruct = re; 43 find = true; 44 } 45 } 46 } 47 if (!find && row.isHover) { 48 HiPerfThreadStruct.hoverStruct = undefined; 49 } 50 if (groupBy10MS) { 51 req.context.fill(normalPath); 52 } else { 53 req.context.stroke(normalPath); 54 HiPerfStruct.drawSpecialPath(req.context, specPath); 55 } 56 req.context.closePath(); 57 } 58 59 render(req: RequestMessage, list: Array<any>, filter: Array<any>, dataList2: Array<any>): void {} 60} 61 62export class HiPerfThreadStruct extends HiPerfStruct { 63 static hoverStruct: HiPerfThreadStruct | undefined; 64 static selectStruct: HiPerfThreadStruct | undefined; 65} 66