1 /* 2 * Copyright (c) 2021 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 #ifndef RENDER_SERVICE_CLIENT_CORE_UI_RS_CANVAS_NODE_H 16 #define RENDER_SERVICE_CLIENT_CORE_UI_RS_CANVAS_NODE_H 17 18 #include "ui/rs_node.h" 19 20 class SkCanvas; 21 22 namespace OHOS { 23 namespace Rosen { 24 class RSNodeMap; 25 26 class RS_EXPORT RSCanvasNode : public RSNode { 27 public: 28 using WeakPtr = std::weak_ptr<RSCanvasNode>; 29 using SharedPtr = std::shared_ptr<RSCanvasNode>; 30 static inline constexpr RSUINodeType Type = RSUINodeType::CANVAS_NODE; 31 32 virtual ~RSCanvasNode(); 33 34 static SharedPtr Create(bool isRenderServiceNode = false); 35 36 SkCanvas* BeginRecording(int width, int height); 37 bool IsRecording() const; 38 void FinishRecording(); 39 GetType()40 RSUINodeType GetType() const override 41 { 42 return RSUINodeType::CANVAS_NODE; 43 } 44 45 protected: 46 RSCanvasNode(bool isRenderServiceNode); 47 RSCanvasNode(const RSCanvasNode&) = delete; 48 RSCanvasNode(const RSCanvasNode&&) = delete; 49 RSCanvasNode& operator=(const RSCanvasNode&) = delete; 50 RSCanvasNode& operator=(const RSCanvasNode&&) = delete; 51 52 private: 53 SkCanvas* recordingCanvas_ = nullptr; 54 55 friend class RSUIDirector; 56 friend class RSAnimation; 57 friend class RSPathAnimation; 58 template<typename T> 59 friend class RSPropertyAnimation; 60 friend class RSNodeMap; 61 }; 62 } // namespace Rosen 63 } // namespace OHOS 64 65 #endif // RENDER_SERVICE_CLIENT_CORE_UI_RS_CANVAS_NODE_H 66