Flutter Engine
color_filter.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef FLUTTER_LIB_UI_COLOR_FILTER_H_
6 #define FLUTTER_LIB_UI_COLOR_FILTER_H_
7 
8 #include "flutter/lib/ui/dart_wrapper.h"
9 #include "third_party/skia/include/core/SkColorFilter.h"
11 
13 
14 namespace tonic {
15 class DartLibraryNatives;
16 } // namespace tonic
17 
18 namespace flutter {
19 
20 // A handle to an SkCodec object.
21 //
22 // Doesn't mirror SkCodec's API but provides a simple sequential access API.
23 class ColorFilter : public RefCountedDartWrappable<ColorFilter> {
26 
27  public:
28  static fml::RefPtr<ColorFilter> Create();
29 
30  // Flutter still defines the matrix to be biased by 255 in the last column
31  // (translate). skia is normalized, treating the last column as 0...1, so we
32  // post-scale here before calling the skia factory.
33  static sk_sp<SkColorFilter> MakeColorMatrixFilter255(const float array[20]);
34 
35  void initMode(int color, int blend_mode);
36  void initMatrix(const tonic::Float32List& color_matrix);
37  void initSrgbToLinearGamma();
38  void initLinearToSrgbGamma();
39 
40  ~ColorFilter() override;
41 
42  sk_sp<SkColorFilter> filter() const { return filter_; }
43 
44  static void RegisterNatives(tonic::DartLibraryNatives* natives);
45 
46  private:
47  sk_sp<SkColorFilter> filter_;
48 };
49 
50 } // namespace flutter
51 
52 #endif // FLUTTER_LIB_UI_COLOR_FILTER_H_
#define DEFINE_WRAPPERTYPEINFO()
#define FML_FRIEND_MAKE_REF_COUNTED(T)
Definition: ref_counted.h:131
sk_sp< SkColorFilter > filter() const
Definition: color_filter.h:42