• 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 
16 #ifndef RS_RESOURCE_MANAGER
17 #define RS_RESOURCE_MANAGER
18 
19 #include "platform/common/rs_log.h"
20 
21 #ifndef USE_ROSEN_DRAWING
22 #include "include/core/SkImage.h"
23 #else
24 #include "image/image.h"
25 #endif
26 #include "render/rs_pixel_map_util.h"
27 
28 #include "draw/surface.h"
29 #include "draw/canvas.h"
30 #include "image/gpu_context.h"
31 #include "image/image.h"
32 
33 namespace OHOS::Rosen {
34 
35 class RSB_EXPORT RSResourceManager final {
36 public:
37 #ifndef USE_ROSEN_DRAWING
38     typedef void (*TextureUpload)(bool, const sk_sp<SkImage>&,
39     const std::shared_ptr<Media::PixelMap>&, uint64_t);
40 #else
41     typedef void (*TextureUpload)(bool, const std::shared_ptr<Drawing::Image>&,
42     const std::shared_ptr<Media::PixelMap>&, uint64_t);
43 #endif
44 
45     static RSResourceManager& Instance();
46 
47 #ifndef USE_ROSEN_DRAWING
48     void UploadTexture(bool paraUpload, const sk_sp<SkImage>&,
49     const std::shared_ptr<Media::PixelMap>& pixelMap, uint64_t uniqueId);
50 #else
51     void UploadTexture(bool paraUpload, const std::shared_ptr<Drawing::Image>& image,
52     const std::shared_ptr<Media::PixelMap>& pixelMap, uint64_t uniqueId);
53 #endif
54 
55 private:
56     friend class RSUploadResourceThread;
57 
58     void SetUploadTextureFunction(TextureUpload hook);
59 
60 private:
61     RSResourceManager() = default;
62     ~RSResourceManager() = default;
63     RSResourceManager(const RSResourceManager&) = delete;
64     RSResourceManager(const RSResourceManager&&)= delete;
65     RSResourceManager& operator=(const RSResourceManager&) = delete;
66     RSResourceManager& operator=(const RSResourceManager&&) = delete;
67 
68     TextureUpload hookFunction_ = nullptr;
69 };
70 
71 }
72 #endif