1 /*
2  * Copyright 2006 The Android Open Source Project
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  * 2023.4.26 log adapt ohos.
7  * Copyright (c) 2023 Huawei Device Co., Ltd. All rights reserved.
8  */
9 
10 #include "include/core/SkTypes.h"
11 #include <stdio.h>
12 
13 #ifdef SKIA_OHOS_SHADER_REDUCE
14 #include <parameters.h>
15 #endif
16 
17 #define LOG_TAG "skia"
18 #include "hilog/log.h"
19 
20 extern "C" {
21     int HiLogPrintArgs(LogType type, LogLevel level, unsigned int domain, const char* tag, const char* fmt, va_list ap);
22 }
23 
24 // Print debug output to stdout as well.  This is useful for command line
25 // applications (e.g. skia_launcher).
26 bool gSkDebugToStdOut = false;
27 
SkDebugf(const char format[], ...)28 void SkDebugf(const char format[], ...) {
29     va_list args1, args2;
30     va_start(args1, format);
31 
32     if (gSkDebugToStdOut) {
33         va_copy(args2, args1);
34         vprintf(format, args2);
35         va_end(args2);
36     }
37 
38     HiLogPrintArgs(LOG_CORE, LogLevel::LOG_DEBUG, 0xD001406, LOG_TAG, format, args1);
39 
40     va_end(args1);
41 }
42 
43 #ifdef SKIA_OHOS_SHADER_REDUCE
SkShaderReduceProperty()44 bool SkShaderReduceProperty()
45 {
46     static bool debugProp = std::atoi(OHOS::system::GetParameter("persist.sys.skia.shader.reduce", "1").c_str()) != 0;
47     return debugProp;
48 }
49 #endif