• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 HiperfProcessRender2 extends PerfRender {
21  renderMainThread(req: unknown, row: TraceRow<HiPerfProcessStruct>): void {
22    //@ts-ignore
23    const ctx = req.context as CanvasRenderingContext2D;
24    let hiperfProcessFilter = row.dataListCache;
25    //@ts-ignore
26    let groupBy10MS = req.scale > 30_000_000;
27    let textMetrics;
28    if (!groupBy10MS) {
29      ctx.font = 'normal 12px Arial';
30      textMetrics = ctx.measureText('��');
31    }
32    hiPerf2(hiperfProcessFilter, TraceRow.range?.startNS ?? 0, TraceRow.range?.endNS ?? 0, row.frame);
33    drawLoadingFrame(ctx, hiperfProcessFilter, row);
34    ctx.beginPath();
35    ctx.fillStyle = ColorUtils.FUNC_COLOR[0];
36    ctx.strokeStyle = ColorUtils.FUNC_COLOR[0];
37    let normalPath = new Path2D();
38    let specPath = new Path2D();
39    let offset = groupBy10MS ? 0 : 3;
40    let find = false;
41    for (let it of hiperfProcessFilter) {
42      HiPerfProcessStruct.draw(ctx, normalPath, specPath, it, groupBy10MS, textMetrics);
43      if (row.isHover) {
44        if (it.frame && row.hoverX >= it.frame.x - offset && row.hoverX <= it.frame.x + it.frame.width + offset) {
45          HiPerfProcessStruct.hoverStruct = it;
46          find = true;
47        }
48      }
49    }
50    if (!find && row.isHover) {
51      HiPerfProcessStruct.hoverStruct = undefined;
52    }
53    if (groupBy10MS) {
54      ctx.fill(normalPath);
55    } else {
56      ctx.stroke(normalPath);
57      HiPerfStruct.drawSpecialPath(ctx, specPath);
58    }
59    ctx.closePath();
60  }
61
62  render(
63    hiPerfProcessRequest: RequestMessage,
64    list: Array<unknown>,
65    filter: Array<unknown>,
66    dataList2: Array<unknown>
67  ): void {}
68}
69
70export class HiPerfProcessStruct extends HiPerfStruct {
71  static hoverStruct: HiPerfProcessStruct | undefined;
72  static selectStruct: HiPerfProcessStruct | undefined;
73}
74