1 /* 2 * Copyright (c) 2022-2023 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_NG_MOCK_ROSEN_TEST_TESTING_CANVAS_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_TEST_TESTING_CANVAS_H 18 19 #include "testing_bitmap.h" 20 #include "testing_brush.h" 21 #include "testing_color.h" 22 #include "testing_image.h" 23 #include "testing_path.h" 24 #include "testing_pen.h" 25 #include "testing_point.h" 26 #include "testing_point3.h" 27 #include "testing_rect.h" 28 #include "testing_round_rect.h" 29 #include "testing_sampling_options.h" 30 #include "testing_shadowflags.h" 31 32 namespace OHOS::Ace::Testing { 33 enum class ClipOp { 34 DIFFERENCE, 35 INTERSECT, 36 UNION, 37 XOR, 38 REVERSE_DIFFERENCE, 39 REPLACE, 40 }; 41 42 enum class SrcRectConstraint { 43 STRICT_SRC_RECT_CONSTRAINT, 44 FAST_SRC_RECT_CONSTRAINT, 45 }; 46 47 class TestingCanvas { 48 public: 49 TestingCanvas() = default; TestingCanvas(void * rawCanvas)50 explicit TestingCanvas(void* rawCanvas) {} 51 virtual ~TestingCanvas() = default; 52 DrawLine(const TestingPoint & startPt,const TestingPoint & endPt)53 virtual void DrawLine(const TestingPoint& startPt, const TestingPoint& endPt) {} DrawPath(const TestingPath & path)54 virtual void DrawPath(const TestingPath& path) {} DrawArc(const TestingRect & oval,float startAngle,float sweepAngle)55 virtual void DrawArc(const TestingRect& oval, float startAngle, float sweepAngle) {} DrawRect(const TestingRect & rect)56 virtual void DrawRect(const TestingRect& rect) {} 57 virtual void ClipRoundRect(const TestingRoundRect& roundRect, ClipOp op, bool antiAlias = false) {} Rotate(float deg,float sx,float sy)58 virtual void Rotate(float deg, float sx, float sy) {} Rotate(float deg)59 virtual void Rotate(float deg) {} Translate(float tx,float ty)60 virtual void Translate(float tx, float ty) {} DrawBitmap(const TestingBitmap & bitmap,const float px,const float py)61 virtual void DrawBitmap(const TestingBitmap& bitmap, const float px, const float py) {} DrawShadow(const TestingPath & path,const TestingPoint3 & planeParams,const TestingPoint3 & devLightPos,float lightRadius,TestingColor,TestingColor,TestingShadowFlags flag)62 virtual void DrawShadow(const TestingPath& path, const TestingPoint3& planeParams, const TestingPoint3& devLightPos, 63 float lightRadius, TestingColor /* ambientColor */, TestingColor /* spotColor */, TestingShadowFlags flag) 64 {} 65 AttachPen(const TestingPen & pen)66 virtual TestingCanvas& AttachPen(const TestingPen& pen) 67 { 68 return *this; 69 } 70 AttachBrush(const TestingBrush & brush)71 virtual TestingCanvas& AttachBrush(const TestingBrush& brush) 72 { 73 return *this; 74 } 75 DetachPen()76 virtual TestingCanvas& DetachPen() 77 { 78 return *this; 79 } 80 DetachBrush()81 virtual TestingCanvas& DetachBrush() 82 { 83 return *this; 84 } 85 86 template<typename T> GetImpl()87 const std::shared_ptr<T> GetImpl() const 88 { 89 return std::shared_ptr<T>(); 90 } 91 Save()92 virtual void Save() {} Restore()93 virtual void Restore() {} DrawCircle(const TestingPoint & center,float radius)94 virtual void DrawCircle(const TestingPoint& center, float radius) {} DrawRoundRect(const TestingRoundRect & roundRect)95 virtual void DrawRoundRect(const TestingRoundRect& roundRect) {} DrawBackground(const TestingBrush & brush)96 virtual void DrawBackground(const TestingBrush& brush) {} ClipRect(const TestingRect & rect,ClipOp op)97 virtual void ClipRect(const TestingRect& rect, ClipOp op) {} Scale(float sx,float sy)98 virtual void Scale(float sx, float sy) {} ClipPath(const TestingPath & path,ClipOp op,bool doAntiAlias)99 virtual void ClipPath(const TestingPath& path, ClipOp op, bool doAntiAlias) {} DrawOval(const TestingRect & oval)100 virtual void DrawOval(const TestingRect& oval) {} DrawImageRect(const TestingImage & image,const TestingRect & dst,const TestingSamplingOptions & sampling)101 virtual void DrawImageRect( 102 const TestingImage& image, const TestingRect& dst, const TestingSamplingOptions& sampling) 103 {} 104 virtual void DrawImageRect(const TestingImage& image, const TestingRect& src, const TestingRect& dst, 105 const TestingSamplingOptions& sampling, 106 SrcRectConstraint constraint = SrcRectConstraint::STRICT_SRC_RECT_CONSTRAINT) 107 {} 108 }; 109 } // namespace OHOS::Ace::Testing 110 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_TEST_TESTING_CANVAS_H 111