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 16 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SVG_ROSEN_RENDER_SVG_PATTERN_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SVG_ROSEN_RENDER_SVG_PATTERN_H 18 19 #ifndef USE_ROSEN_DRAWING 20 #include "include/core/SkCanvas.h" 21 #include "include/core/SkPaint.h" 22 #else 23 #include "core/components_ng/render/drawing.h" 24 #endif 25 26 #include "frameworks/core/components/svg/render_svg_pattern.h" 27 #include "frameworks/core/pipeline/base/rosen_render_context.h" 28 29 namespace OHOS::Ace { 30 31 class RosenRenderSvgPattern : public RenderSvgPattern { 32 DECLARE_ACE_TYPE(RosenRenderSvgPattern, RenderSvgPattern); 33 34 public: 35 void Paint(RenderContext& context, const Offset& offset) override; 36 #ifndef USE_ROSEN_DRAWING 37 bool OnAsPaint(const Offset& offset, const Rect& paintRect, SkPaint& skPaint); 38 #else 39 bool OnAsPaint(const Offset& offset, const Rect& paintRect, RSPen* rsPen, RSBrush* rsBrush); 40 #endif 41 42 protected: 43 #ifndef USE_ROSEN_DRAWING 44 bool FitAttribute(const Rect& paintRect, Rect& tileRect, SkMatrix& skMatrix4); 45 #else 46 bool FitAttribute(const Rect& paintRect, Rect& tileRect, RSMatrix& matrix4); 47 #endif 48 void FitRenderContext(RosenRenderContext& context, const Rect& patternRect); 49 50 private: 51 void ResetAttrOffset(); 52 const Matrix4 GetTransform(const Rect& patternRect) const; 53 54 float scaleY_ = 1.0f; 55 float scaleX_ = 1.0f; 56 float scale_ = 1.0f; 57 float tx_ = 0.0f; 58 float ty_ = 0.0f; 59 }; 60 61 } // namespace OHOS::Ace 62 63 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_SVG_ROSEN_RENDER_SVG_PATTERN_H 64