• 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 GrVkDrawAreaManager_DEFINED
17 #define GrVkDrawAreaManager_DEFINED
18 
19 #include <map>
20 #include "include/core/SkSurface.h"
21 #include "include/private/base/SkMutex.h"
22 #include "src/gpu/ganesh/GrRenderTarget.h"
23 
24 class SK_API GrVkDrawAreaManager {
25 public:
getInstance()26     static GrVkDrawAreaManager &getInstance() {
27         static GrVkDrawAreaManager instance;
28         return instance;
29     }
30 
31     GrVkDrawAreaManager(const GrVkDrawAreaManager &) = delete;
32     GrVkDrawAreaManager &operator = (const GrVkDrawAreaManager &) = delete;
33     GrVkDrawAreaManager(GrVkDrawAreaManager &&) = delete;
34     GrVkDrawAreaManager &operator = (GrVkDrawAreaManager &&) = delete;
35 
36     void bindDrawingArea(SkSurface* surface, const std::vector<SkIRect>& skIRects);
37 
38     std::vector<SkIRect>& getDrawingArea(GrRenderTarget* rt);
39 
40     void clearSurface(SkSurface* surface);
41 
42     void clearAll();
43 
44 private:
45     GrVkDrawAreaManager() = default;
46     virtual ~GrVkDrawAreaManager() = default;
47 
48     std::map<GrRenderTarget*, std::vector<SkIRect>> fRtmap;
49 
50     SkMutex fMutex;
51 };
52 #endif