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_UI_CAPTURE_SOLO_TASK_PARALLEL 17 #define RS_UI_CAPTURE_SOLO_TASK_PARALLEL 18 #define EGL_EGLEXT_PROTOTYPES 19 #define GL_GLEXT_PROTOTYPES 20 21 #include "drawable/rs_render_node_drawable.h" 22 #include "feature/capture/rs_surface_capture_task.h" 23 #include "pixel_map.h" 24 #include "system/rs_system_parameters.h" 25 26 #include "system/rs_system_parameters.h" 27 28 namespace OHOS { 29 namespace Rosen { 30 class RSUiCaptureSoloTaskParallel { 31 public: RSUiCaptureSoloTaskParallel(NodeId nodeId,const RSSurfaceCaptureConfig & captureConfig)32 explicit RSUiCaptureSoloTaskParallel(NodeId nodeId, const RSSurfaceCaptureConfig& captureConfig) 33 : nodeId_(nodeId), captureConfig_(captureConfig) {} 34 ~RSUiCaptureSoloTaskParallel() = default; 35 36 /** 37 * @brief Get a list of pixelmap information, each node of the component node tree will have a pixelmap. 38 * @param id Indicates the NodeId of the RSNode. 39 * @param captureConfig Indicates the configuration of snapshot like scale, translation, rotation. 40 * @return Returns a vector of pair, the first element is the NodeId, the second element is the pixelmap. 41 */ 42 static std::vector<std::pair<NodeId, std::shared_ptr<Media::PixelMap>>> CaptureSoloNode( 43 NodeId id, const RSSurfaceCaptureConfig& captureConfig); 44 45 /** 46 * @brief Get a pixelmap, which is the snapshot of the node, only contains the node itself.\n 47 * 48 * Child nodes of the param node will not be included in the snapshot. 49 * Used for scenarios requiring a snapshot of a specific node, such as capturing a specific component. 50 * 51 * @param id Indicates the NodeId of the RSNode. 52 * @param captureConfig Indicates the configuration of snapshot like scale, translation, rotation. 53 * @return Returns a pixelmap. 54 */ 55 static std::unique_ptr<Media::PixelMap> CaptureSoloNodePixelMap( 56 NodeId id, const RSSurfaceCaptureConfig& captureConfig); 57 bool CreateResources(); 58 bool Run(); 59 #ifdef RS_ENABLE_UNI_RENDER 60 static std::function<void()> CreateSurfaceSyncCopyTask(std::shared_ptr<Drawing::Surface> surface, 61 std::unique_ptr<Media::PixelMap>& pixelMap, NodeId id, const RSSurfaceCaptureConfig& captureConfig, 62 int32_t rotation = 0); 63 #endif 64 65 private: 66 std::shared_ptr<Drawing::Surface> CreateSurface(const std::unique_ptr<Media::PixelMap>& pixelmap) const; 67 std::unique_ptr<Media::PixelMap> CreatePixelMapByNode(std::shared_ptr<RSRenderNode> node) const; 68 std::unique_ptr<Media::PixelMap> pixelMap_ = nullptr; 69 std::shared_ptr<DrawableV2::RSRenderNodeDrawable> nodeDrawable_ = nullptr; 70 NodeId nodeId_ = INVALID_NODEID; 71 RSSurfaceCaptureConfig captureConfig_ = {}; 72 }; 73 } // namespace Rosen 74 } // namespace OHOS 75 76 #endif // RS_UI_CAPTURE_SOLO_TASK_PARALLEL 77