Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
helpers.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_SKWASM_HELPERS_H_
6#define FLUTTER_SKWASM_HELPERS_H_
7
10#include "third_party/skia/include/core/SkMatrix.h"
11#include "third_party/skia/include/core/SkRRect.h"
12#include "third_party/skia/include/core/SkSamplingOptions.h"
13
14namespace Skwasm {
15
16template <typename T>
18 public:
19 sp_wrapper(std::shared_ptr<T> ptr) : ptr_(std::move(ptr)) {}
20
21 const std::shared_ptr<T>& Shared() { return ptr_; }
22
23 T* Raw() { return ptr_.get(); }
24
25 private:
26 std::shared_ptr<T> ptr_;
27};
28
30 // clang-format off
31 return flutter::DlMatrix(
32 f[0], f[3], 0, f[6],
33 f[1], f[4], 0, f[7],
34 0, 0, 1, 0,
35 f[2], f[5], 0, f[8]
36 );
37 // clang-format on
38}
39
40inline SkMatrix CreateSkMatrix(const SkScalar* f) {
41 return SkMatrix::MakeAll(f[0], f[1], f[2], f[3], f[4], f[5], f[6], f[7],
42 f[8]);
43}
44
45inline flutter::DlRect CreateDlRect(const float* f) {
46 return flutter::DlRect::MakeLTRB(f[0], f[1], f[2], f[3]);
47}
48
50 // Flutter has radii in TL,TR,BR,BL (clockwise) order,
51 // but Impeller uses TL,TR,BL,BR (zig-zag) order
53 .top_left = flutter::DlSize(f[0], f[1]),
54 .top_right = flutter::DlSize(f[2], f[3]),
55 .bottom_left = flutter::DlSize(f[6], f[7]),
56 .bottom_right = flutter::DlSize(f[4], f[5]),
57 };
58 return radii;
59}
60
65
66inline SkRRect CreateSkRRect(const SkScalar* f) {
67 const SkRect* rect = reinterpret_cast<const SkRect*>(f);
68 const SkVector* radiiValues = reinterpret_cast<const SkVector*>(f + 4);
69 SkRRect rr;
70 rr.setRectRadii(*rect, radiiValues);
71 return rr;
72}
73
74// This must be kept in sync with the `ImageByteFormat` enum in dart:ui.
75enum class ImageByteFormat {
76 rawRgba,
79 png,
80};
81
82// This needs to be kept in sync with the "FilterQuality" enum in dart:ui
83enum class FilterQuality {
84 none,
85 low,
86 medium,
87 high,
88};
89
100
114} // namespace Skwasm
115
116#endif // FLUTTER_SKWASM_HELPERS_H_
sp_wrapper(std::shared_ptr< T > ptr)
Definition helpers.h:19
const std::shared_ptr< T > & Shared()
Definition helpers.h:21
flutter::DlFilterMode FilterModeForQuality(FilterQuality quality)
Definition helpers.h:90
flutter::DlMatrix CreateDlMatrixFrom3x3(const flutter::DlScalar *f)
Definition helpers.h:29
flutter::DlRoundRect CreateDlRRect(const float *f)
Definition helpers.h:61
SkRRect CreateSkRRect(const SkScalar *f)
Definition helpers.h:66
flutter::DlImageSampling SamplingOptionsForQuality(FilterQuality quality)
Definition helpers.h:101
FilterQuality
Definition helpers.h:83
flutter::DlRect CreateDlRect(const float *f)
Definition helpers.h:45
SkMatrix CreateSkMatrix(const SkScalar *f)
Definition helpers.h:40
ImageByteFormat
Definition helpers.h:75
flutter::DlRoundingRadii CreateDlRadii(const float *f)
Definition helpers.h:49
impeller::Scalar DlScalar
impeller::Matrix DlMatrix
impeller::Size DlSize
Definition ref_ptr.h:261
A 4x4 matrix using column-major storage.
Definition matrix.h:37
static RoundRect MakeRectRadii(const Rect &rect, const RoundingRadii &radii)
Definition round_rect.cc:9
static constexpr TRect MakeLTRB(Type left, Type top, Type right, Type bottom)
Definition rect.h:129