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 NEW_SKIA 18 #include "include/gpu/GrContext.h" 19 #else 20 #include "include/gpu/GrDirectContext.h" 21 #endif 22 #include "common/rs_common_def.h" 23 #include "common/rs_macros.h" 24 #include "platform/common/rs_system_properties.h" 25 26 namespace OHOS { 27 namespace Rosen { 28 class RSB_EXPORT RSTagTracker { 29 public: 30 enum TAGTYPE : uint32_t { 31 TAG_DRAW_SURFACENODE = 1, // don't change head and tail, insert the middle if u add data. 32 TAG_SAVELAYER_DRAW_NODE, 33 TAG_RESTORELAYER_DRAW_NODE, 34 TAG_SAVELAYER_COLOR_FILTER, 35 TAG_COLD_START, 36 TAG_SUB_THREAD, 37 TAG_ACQUIRE_SURFACE, 38 TAG_FILTER, 39 TAG_RENDER_FRAME, 40 TAG_CAPTURE, 41 }; 42 #if defined(NEW_SKIA) 43 RSTagTracker(GrDirectContext* grContext, RSTagTracker::TAGTYPE tagType); 44 RSTagTracker(GrDirectContext* grContext, NodeId nodeId, RSTagTracker::TAGTYPE tagType); 45 RSTagTracker(GrDirectContext* grContext, GrGpuResourceTag& tag); 46 #else 47 RSTagTracker(GrContext* grContext, RSTagTracker::TAGTYPE tagType); 48 RSTagTracker(GrContext* grContext, NodeId nodeId, RSTagTracker::TAGTYPE tagType); 49 RSTagTracker(GrContext* grContext, GrGpuResourceTag& tag); 50 #endif 51 void SetTagEnd(); 52 ~RSTagTracker(); 53 static void UpdateReleaseGpuResourceEnable(ReleaseGpuResourceType releaseResEnable); 54 static std::string TagType2String(TAGTYPE type); 55 private: 56 bool isSetTagEnd_ = false; 57 #if defined(NEW_SKIA) 58 GrDirectContext* grContext_ = nullptr; 59 #else 60 GrContext* grContext_ = nullptr; 61 #endif 62 static ReleaseGpuResourceType releaseGpuResourceEnable_; 63 }; 64 } // namespace Rosen 65 } // namespace OHOS 66 #endif