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 RENDER_SERVICE_WINDOW_KEYFRAME_BUFFER_H 17 #define RENDER_SERVICE_WINDOW_KEYFRAME_BUFFER_H 18 19 #include <memory> 20 #include "draw/canvas.h" 21 #include "drawable/rs_canvas_render_node_drawable.h" 22 #include "params/rs_render_params.h" 23 #include "pipeline/rs_paint_filter_canvas.h" 24 25 namespace OHOS::Rosen { 26 27 class RSWindowKeyframeBuffer { 28 public: 29 explicit RSWindowKeyframeBuffer(DrawableV2::RSCanvasRenderNodeDrawable& drawable); 30 ~RSWindowKeyframeBuffer() = default; 31 32 bool NeedDrawWindowKeyFrame(const std::unique_ptr<RSRenderParams>& params); 33 bool OnDraw(Drawing::Canvas& canvas, const RSRenderParams& params); 34 bool DrawOffscreenBuffer(RSPaintFilterCanvas& canvas, const Drawing::Rect& bounds, float alpha, bool isFreezed); 35 36 private: 37 RSWindowKeyframeBuffer(const RSWindowKeyframeBuffer&) = delete; 38 RSWindowKeyframeBuffer(const RSWindowKeyframeBuffer&&) = delete; 39 RSWindowKeyframeBuffer& operator=(const RSWindowKeyframeBuffer&) = delete; 40 RSWindowKeyframeBuffer& operator=(const RSWindowKeyframeBuffer&&) = delete; 41 42 bool DrawOffscreenImgToBuffer(Drawing::Canvas& canvas, const RSRenderParams& params, 43 const Drawing::Rect& bounds, std::shared_ptr<Drawing::Surface>& surface); 44 45 DrawableV2::RSCanvasRenderNodeDrawable& canvasNodeDrawable_; 46 std::shared_ptr<Drawing::Image> cachedOffscreenImg_ = nullptr; 47 std::shared_ptr<Drawing::Image> preCachedOffscreenImg_ = nullptr; 48 }; 49 50 } // namespace OHOS::Rosen 51 #endif // RENDER_SERVICE_WINDOW_KEYFRAME_BUFFER_H 52