1 /* 2 * Copyright (c) 2024 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_TASK_PARALLEL 17 #define RS_UI_CAPTURE_TASK_PARALLEL 18 #define EGL_EGLEXT_PROTOTYPES 19 #define GL_GLEXT_PROTOTYPES 20 21 #include "drawable/rs_render_node_drawable.h" 22 #include "pipeline/rs_surface_capture_task.h" 23 #include "pixel_map.h" 24 #include "system/rs_system_parameters.h" 25 26 namespace OHOS { 27 namespace Rosen { 28 class RSUiCaptureTaskParallel { 29 public: RSUiCaptureTaskParallel(NodeId nodeId,const RSSurfaceCaptureConfig & captureConfig)30 explicit RSUiCaptureTaskParallel(NodeId nodeId, const RSSurfaceCaptureConfig& captureConfig) 31 : nodeId_(nodeId), captureConfig_(captureConfig) {} 32 ~RSUiCaptureTaskParallel() = default; 33 34 static void Capture(NodeId id, sptr<RSISurfaceCaptureCallback> callback, 35 const RSSurfaceCaptureConfig& captureConfig); 36 37 bool CreateResources(); 38 bool Run(sptr<RSISurfaceCaptureCallback> callback); 39 40 static void ProcessUiCaptureCallback( 41 sptr<RSISurfaceCaptureCallback> callback, NodeId id, Media::PixelMap* pixelmap); 42 #ifdef RS_ENABLE_UNI_RENDER 43 static std::function<void()> CreateSurfaceSyncCopyTask(std::shared_ptr<Drawing::Surface> surface, 44 std::unique_ptr<Media::PixelMap> pixelMap, NodeId id, sptr<RSISurfaceCaptureCallback> callback, 45 int32_t rotation = 0, bool useDma = false); 46 #endif 47 GetCaptureCount()48 static int32_t GetCaptureCount() 49 { 50 return captureCount_; 51 } 52 53 private: 54 std::shared_ptr<Drawing::Surface> CreateSurface(const std::unique_ptr<Media::PixelMap>& pixelmap) const; 55 std::unique_ptr<Media::PixelMap> CreatePixelMapByNode(std::shared_ptr<RSRenderNode> node) const; 56 57 std::unique_ptr<Media::PixelMap> pixelMap_ = nullptr; 58 std::shared_ptr<DrawableV2::RSRenderNodeDrawable> nodeDrawable_ = nullptr; 59 NodeId nodeId_ = INVALID_NODEID; 60 RSSurfaceCaptureConfig captureConfig_ = {}; 61 static inline std::atomic<int32_t> captureCount_ = 0; 62 }; 63 } // namespace Rosen 64 } // namespace OHOS 65 66 #endif // RS_UI_CAPTURE_TASK_PARALLEL 67