• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_RENDER_SKIA_RS_SKIA_FILTER_H
16 #define RENDER_SERVICE_CLIENT_CORE_RENDER_SKIA_RS_SKIA_FILTER_H
17 
18 #ifndef USE_ROSEN_DRAWING
19 #include "include/core/SkCanvas.h"
20 #include "include/core/SkImageFilter.h"
21 #include "include/core/SkPaint.h"
22 #include "include/effects/SkImageFilters.h"
23 #else
24 #include "draw/brush.h"
25 #include "draw/canvas.h"
26 #include "effect/image_filter.h"
27 #endif
28 
29 #include "render/rs_filter.h"
30 
31 namespace OHOS {
32 namespace Rosen {
33 class RSPaintFilterCanvas;
34 #ifndef USE_ROSEN_DRAWING
35 class RSSkiaFilter : public RSFilter {
36 public:
37     RSSkiaFilter(sk_sp<SkImageFilter> imagefilter);
38     RSSkiaFilter(const RSSkiaFilter&) = delete;
39     ~RSSkiaFilter() override;
40     SkPaint GetPaint() const;
41     virtual void DrawImageRect(
42         SkCanvas& canvas, const sk_sp<SkImage>& image, const SkRect& src, const SkRect& dst) const;
43     sk_sp<SkImageFilter> GetImageFilter() const;
44     virtual std::shared_ptr<RSSkiaFilter> Compose(const std::shared_ptr<RSSkiaFilter>& other) const = 0;
PreProcess(sk_sp<SkImage> image)45     virtual void PreProcess(sk_sp<SkImage> image) {};
PostProcess(RSPaintFilterCanvas & canvas)46     virtual void PostProcess(RSPaintFilterCanvas& canvas) {};
CanSkipFrame()47     virtual bool CanSkipFrame() const { return false; };
48 
49 protected:
50     sk_sp<SkImageFilter> imageFilter_ = nullptr;
51 };
52 #else
53 class RSDrawingFilter : public RSFilter {
54 public:
55     RSDrawingFilter(std::shared_ptr<Drawing::ImageFilter> imagefilter);
56     ~RSDrawingFilter() override;
57     Drawing::Brush GetBrush() const;
58     virtual void DrawImageRect(Drawing::Canvas& canvas, const std::shared_ptr<Drawing::Image>& image,
59         const Drawing::Rect& src, const Drawing::Rect& dst) const;
60     std::shared_ptr<Drawing::ImageFilter> GetImageFilter() const;
61     virtual std::shared_ptr<RSDrawingFilter> Compose(const std::shared_ptr<RSDrawingFilter>& other) const = 0;
PreProcess(std::shared_ptr<Drawing::Image> image)62     virtual void PreProcess(std::shared_ptr<Drawing::Image> image) {};
PostProcess(RSPaintFilterCanvas & canvas)63     virtual void PostProcess(RSPaintFilterCanvas& canvas) {};
CanSkipFrame()64     virtual bool CanSkipFrame() const { return false; };
65 
66 protected:
67     std::shared_ptr<Drawing::ImageFilter> imageFilter_ = nullptr;
68 };
69 #endif
70 } // namespace Rosen
71 } // namespace OHOS
72 
73 #endif // RENDER_SERVICE_CLIENT_CORE_RENDER_SKIA_RS_SKIA_FILTER_H