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 KNUCKLE_GLOW_POINT_H 17 #define KNUCKLE_GLOW_POINT_H 18 19 #include "draw/canvas.h" 20 #include "image/bitmap.h" 21 #include "include/core/SkCanvas.h" 22 #include "include/core/SkPaint.h" 23 #include "pipeline/rs_recording_canvas.h" 24 #include "render/rs_pixel_map_util.h" 25 #include "utils/matrix.h" 26 27 namespace OHOS { 28 namespace MMI { 29 class KnuckleGlowPoint { 30 public: 31 explicit KnuckleGlowPoint(std::shared_ptr<OHOS::Media::PixelMap> pixelMap); 32 ~KnuckleGlowPoint() = default; 33 void Update(); 34 void Draw(Rosen::ExtendRecordingCanvas* canvas); 35 void Reset(double pointX, double pointY, float lifespanOffset); 36 bool IsEnded() const; 37 38 private: 39 void UpdateMatrix(); 40 int64_t GetNanoTime() const; 41 42 double lifespan_ { -1.0 }; 43 double pointX_ { 0.0 }; 44 double pointY_ { 0.0 }; 45 int64_t lastUpdateTimeMillis_ { 0 }; 46 float traceSize_ { 0.f }; 47 48 Rosen::Drawing::Matrix traceMatrix_; 49 std::shared_ptr<OHOS::Media::PixelMap> traceShadow_ { nullptr }; 50 OHOS::Rosen::Drawing::Brush brush_; 51 }; 52 } // namespace MMI 53 } // namespace OHOS 54 #endif // KNUCKLE_GLOW_POINT_H 55