1 /* 2 * Copyright (c) 2022 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 16 #ifndef OHOS_MEMORY_HANDLER_H 17 #define OHOS_MEMORY_HANDLER_H 18 19 #ifndef USE_ROSEN_DRAWING 20 #include <include/core/SkSurface.h> 21 #if defined(NEW_SKIA) 22 #include <include/gpu/GrDirectContext.h> 23 #else 24 #include <include/gpu/GrContext.h> 25 #endif 26 #else 27 #include "image/gpu_context.h" 28 #endif 29 #include "cache_data.h" 30 #include "shader_cache.h" 31 32 namespace OHOS { 33 namespace Rosen { 34 class MemoryHandler { 35 public: 36 #ifndef USE_ROSEN_DRAWING 37 static void ConfigureContext(GrContextOptions* context, const char* identity, const size_t size, 38 const std::string& cacheFilePath, bool isUni); 39 #else 40 static void ConfigureContext(Drawing::GPUContextOptions* context, const char* identity, const size_t size, 41 const std::string& cacheFilePath, bool isUni); 42 #endif 43 MemoryHandler() = default; 44 #ifndef USE_ROSEN_DRAWING 45 #if defined(NEW_SKIA) 46 static void ClearRedundantResources(GrDirectContext* grContext); 47 #else 48 static void ClearRedundantResources(GrContext* grContext); 49 #endif 50 #else 51 static void ClearRedundantResources(Drawing::GPUContext* gpuContext); 52 #endif 53 static std::string QuerryShader(); 54 static std::string ClearShader(); 55 }; 56 } // namespace Rosen 57 } // namespace OHOS 58 #endif // OHOS_MEMORY_HANDLER_H 59