Update rive-cpp to 2.0 version
[platform/core/uifw/rive-tizen.git] / submodule / skia / src / utils / SkBlitterTrace.h
1 /*
2  * Copyright 2022 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  *
7  * This is an experimental (and probably temporary) solution that allows
8  * to compare performance SkVM blitters vs RasterPipeline blitters.
9  * In addition to measuring performance (which is questionable) it also produces
10  * other counts (pixels, scanlines) and more detailed traces that
11  * can explain the current results (SkVM is slower) and help improve it.
12  * The entire code is hidden under build flag skia_compare_vm_vs_rp=true
13  * and will not appear at all without it.
14  *
15  * In order to collect the tracing information SkVM Blitters should run with SKVM_BLITTER_TRACE_ON
16  * and RasterPipeline Blitters with RASTER_PIPELINE_BLITTER_TRACE_ON.
17  */
18
19 #ifndef SkBlitterTrace_DEFINED
20 #define SkBlitterTrace_DEFINED
21
22 #include <inttypes.h>
23 #include <unordered_map>
24 #include "src/utils/SkBlitterTraceCommon.h"
25
26 #ifdef SKIA_COMPARE_VM_VS_RP
27
28 #if !defined(SK_BLITTER_TRACE_IS_SKVM) && !defined(SK_BLITTER_TRACE_IS_RASTER_PIPELINE)
29 #error "One blitter trace type should be defined if we have flag skia_compare_vm_vs_rp flag = true."
30 #endif
31
32 #if defined(SK_BLITTER_TRACE_IS_SKVM) && defined(SK_BLITTER_TRACE_IS_RASTER_PIPELINE)
33 #error "Only one blitter trace type should be defined."
34 #endif
35
36 #ifdef SK_BLITTER_TRACE_IS_SKVM
37 SkBlitterTrace gSkVMBlitterTrace("VM", false);
38 #define SK_BLITTER_TRACE_STEP(name, trace, scanlines, pixels) \
39     SkBlitterTrace::Step name(trace ? &gSkVMBlitterTrace : nullptr, \
40                               #name,     \
41                               scanlines, \
42                               pixels)
43 #endif
44
45 #ifdef SK_BLITTER_TRACE_IS_RASTER_PIPELINE
46 SkBlitterTrace gSkRPBlitterTrace("RP", false);
47 #define SK_BLITTER_TRACE_STEP(name, trace, scanlines, pixels) \
48     SkBlitterTrace::Step name(trace ? &gSkRPBlitterTrace : nullptr, \
49                               #name,     \
50                               scanlines, \
51                               pixels)
52 #endif
53
54 #define SK_BLITTER_TRACE_STEP_ACCUMULATE(step, pixels) \
55         step.add(/*scanlines=*/0, /*pixels=*/run)
56 #else
57 #define INITIATE_BLITTER_TRACE(type) SK_BLITTER_TRACE_NO_CODE
58 #define SK_BLITTER_TRACE_STEP(name, trace, scanlines, pixels) SK_BLITTER_TRACE_NO_CODE
59 #define SK_BLITTER_TRACE_STEP_ACCUMULATE(step, pixels) SK_BLITTER_TRACE_NO_CODE
60 #endif
61
62 #endif // SkBlitterTrace_DEFINED