• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 #ifndef RS_TAG_TRACKER
16 #define RS_TAG_TRACKER
17 #ifndef USE_ROSEN_DRAWING
18 #ifndef NEW_SKIA
19 #include "include/gpu/GrContext.h"
20 #else
21 #include "include/gpu/GrDirectContext.h"
22 #endif
23 #else
24 #include "image/gpu_context.h"
25 #endif
26 #include "common/rs_common_def.h"
27 #include "common/rs_macros.h"
28 #include "platform/common/rs_system_properties.h"
29 
30 namespace OHOS {
31 namespace Rosen {
32 class RSB_EXPORT RSTagTracker {
33 public:
34     enum TAGTYPE : uint32_t {
35         TAG_DRAW_SURFACENODE = 1, // don't change head and tail, insert the middle if u add data.
36         TAG_SUB_THREAD,
37         TAG_SAVELAYER_DRAW_NODE,
38         TAG_RESTORELAYER_DRAW_NODE,
39         TAG_SAVELAYER_COLOR_FILTER,
40         TAG_ACQUIRE_SURFACE,
41         TAG_FILTER,
42         TAG_RENDER_FRAME,
43         TAG_CAPTURE,
44     };
45 #ifndef USE_ROSEN_DRAWING
46 #if defined(NEW_SKIA)
47     RSTagTracker(GrDirectContext* grContext, RSTagTracker::TAGTYPE tagType);
48     RSTagTracker(GrDirectContext* grContext, NodeId nodeId, RSTagTracker::TAGTYPE tagType);
49     RSTagTracker(GrDirectContext* grContext, GrGpuResourceTag& tag);
50 #else
51     RSTagTracker(GrContext* grContext, RSTagTracker::TAGTYPE tagType);
52     RSTagTracker(GrContext* grContext, NodeId nodeId, RSTagTracker::TAGTYPE tagType);
53     RSTagTracker(GrContext* grContext, GrGpuResourceTag& tag);
54 #endif
55 #else
56     RSTagTracker(Drawing::GPUContext* gpuContext, RSTagTracker::TAGTYPE tagType);
57     RSTagTracker(Drawing::GPUContext* gpuContext, NodeId nodeId, RSTagTracker::TAGTYPE tagType);
58     RSTagTracker(Drawing::GPUContext* gpuContext, Drawing::GPUResourceTag& tag);
59 #endif
60     void SetTagEnd();
61     ~RSTagTracker();
62     static void UpdateReleaseResourceEnabled(bool releaseResEnabled);
63     static std::string TagType2String(TAGTYPE type);
64 private:
65     bool isSetTagEnd_ = false;
66 #ifndef USE_ROSEN_DRAWING
67 #if defined(NEW_SKIA)
68     GrDirectContext* grContext_ = nullptr;
69 #else
70     GrContext* grContext_ = nullptr;
71 #endif
72 #else
73     Drawing::GPUContext* gpuContext_ = nullptr;
74 #endif
75 };
76 } // namespace Rosen
77 } // namespace OHOS
78 #endif