• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 RS_IMAGE_MANAGER_H
17 #define RS_IMAGE_MANAGER_H
18 
19 #include <memory>
20 #include <mutex>
21 #include <queue>
22 #include <variant>
23 #include <unordered_map>
24 #include <surface.h>
25 
26 #include "render_context/render_context.h"
27 #include "pipeline/render_thread/rs_base_render_util.h"
28 #include "pipeline/rs_paint_filter_canvas.h"
29 
30 namespace OHOS {
31 namespace Rosen {
32 class RSImageManager {
33 public:
34     static std::shared_ptr<RSImageManager> Create(std::shared_ptr<RenderContext>& renderContext);
35 
36     virtual ~RSImageManager() = default;
37 
38     virtual void UnMapImageFromSurfaceBuffer(int32_t seqNum) = 0;
39     virtual std::shared_ptr<Drawing::Image> CreateImageFromBuffer(
40         RSPaintFilterCanvas& canvas, const BufferDrawParam& params,
41         const std::shared_ptr<Drawing::ColorSpace>& drawingColorSpace) = 0;
42     virtual std::shared_ptr<Drawing::Image> GetIntersectImage(Drawing::RectI& imgCutRect,
43         const std::shared_ptr<Drawing::GPUContext>& context, const sptr<OHOS::SurfaceBuffer>& buffer,
44         const sptr<SyncFence>& acquireFence, pid_t threadIndex = 0) = 0;
45 
46     // Vulkan specific functions
DumpVkImageInfo(std::string & dumpString)47     virtual void DumpVkImageInfo(std::string &dumpString) { return; }
48 
49     // EGL specific functions
50     virtual void ShrinkCachesIfNeeded(bool isForUniRedraw = false) { return; }
51 protected:
52     RSImageManager() = default;
53     mutable std::mutex opMutex_;
54 };
55 } // namespace Rosen
56 } // namespace OHOS
57 
58 #endif // RS_IMAGE_MANAGER_H
59