• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-2024 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 #include "sec_comp_tool.h"
16 
17 #include <cmath>
18 #include <cstdint>
19 #include "sec_comp_log.h"
20 
21 namespace OHOS {
22 namespace Security {
23 namespace SecurityComponent {
24 namespace {
25 static constexpr uint8_t MAX_TRANSPARENT = 0x99; // 60%
26 
27 constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, SECURITY_DOMAIN_SECURITY_COMPONENT, "SecCompTool"};
28 }
29 
IsColorTransparent(const SecCompColor & color)30 bool IsColorTransparent(const SecCompColor& color)
31 {
32     SC_LOG_DEBUG(LABEL, "Color %{public}x alpha %{public}x", color.value, color.argb.alpha);
33     return color.argb.alpha < MAX_TRANSPARENT;
34 }
35 
IsColorFullTransparent(const SecCompColor & color)36 bool IsColorFullTransparent(const SecCompColor& color)
37 {
38     return color.argb.alpha == 0;
39 }
40 }  // namespace SecurityComponent
41 }  // namespace Security
42 }  // namespace OHOS
43