Flutter Engine
The Flutter Engine
dl_geometry_types.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_DISPLAY_LIST_GEOMETRY_DL_GEOMETRY_TYPES_H_
6#define FLUTTER_DISPLAY_LIST_GEOMETRY_DL_GEOMETRY_TYPES_H_
7
8#include "flutter/impeller/geometry/matrix.h"
9#include "flutter/impeller/geometry/rect.h"
10#include "flutter/impeller/geometry/scalar.h"
11
12#include "flutter/third_party/skia/include/core/SkM44.h"
13#include "flutter/third_party/skia/include/core/SkMatrix.h"
14#include "flutter/third_party/skia/include/core/SkRect.h"
15#include "flutter/third_party/skia/include/core/SkSize.h"
16
17namespace flutter {
18
22
30
31static_assert(sizeof(SkPoint) == sizeof(DlPoint));
32static_assert(sizeof(SkIPoint) == sizeof(DlIPoint));
33static_assert(sizeof(SkSize) == sizeof(DlSize));
34static_assert(sizeof(SkISize) == sizeof(DlISize));
35static_assert(sizeof(SkRect) == sizeof(DlRect));
36static_assert(sizeof(SkIRect) == sizeof(DlIRect));
37
38inline const DlPoint& ToDlPoint(const SkPoint& point) {
39 return *reinterpret_cast<const DlPoint*>(&point);
40}
41
42inline const DlRect& ToDlRect(const SkRect& rect) {
43 return *reinterpret_cast<const DlRect*>(&rect);
44}
45
46inline const DlISize& ToDlISize(const SkISize& size) {
47 return *reinterpret_cast<const DlISize*>(&size);
48}
49
50inline constexpr DlMatrix ToDlMatrix(const SkMatrix& matrix) {
51 // clang-format off
55 0.0f, 0.0f, 1.0f, 0.0f,
57 );
58 // clang-format on
59}
60
61inline constexpr DlMatrix ToDlMatrix(const SkM44& matrix) {
62 DlMatrix dl_matrix;
63 matrix.getColMajor(dl_matrix.m);
64 return dl_matrix;
65}
66
67inline const SkPoint& ToSkPoint(const DlPoint& point) {
68 return *reinterpret_cast<const SkPoint*>(&point);
69}
70
71inline const SkRect& ToSkRect(const DlRect& rect) {
72 return *reinterpret_cast<const SkRect*>(&rect);
73}
74
75inline const SkISize& ToSkISize(const DlISize& size) {
76 return *reinterpret_cast<const SkISize*>(&size);
77}
78
79inline constexpr SkMatrix ToSkMatrix(const DlMatrix& matrix) {
80 return SkMatrix::MakeAll(matrix.m[0], matrix.m[4], matrix.m[12], //
81 matrix.m[1], matrix.m[5], matrix.m[13], //
82 matrix.m[3], matrix.m[7], matrix.m[15]);
83}
84
85inline constexpr SkM44 ToSkM44(const DlMatrix& matrix) {
86 return SkM44::ColMajor(matrix.m);
87}
88
89} // namespace flutter
90
91#endif // FLUTTER_DISPLAY_LIST_GEOMETRY_DL_GEOMETRY_TYPES_H_
Definition: SkM44.h:150
static SkM44 ColMajor(const SkScalar c[16])
Definition: SkM44.h:218
static constexpr int kMScaleX
horizontal scale factor
Definition: SkMatrix.h:353
static constexpr int kMTransY
vertical translation
Definition: SkMatrix.h:358
static constexpr int kMPersp1
input y perspective factor
Definition: SkMatrix.h:360
static SkMatrix MakeAll(SkScalar scaleX, SkScalar skewX, SkScalar transX, SkScalar skewY, SkScalar scaleY, SkScalar transY, SkScalar pers0, SkScalar pers1, SkScalar pers2)
Definition: SkMatrix.h:179
static constexpr int kMPersp0
input x perspective factor
Definition: SkMatrix.h:359
static constexpr int kMPersp2
perspective bias
Definition: SkMatrix.h:361
static constexpr int kMTransX
horizontal translation
Definition: SkMatrix.h:355
static constexpr int kMSkewY
vertical skew factor
Definition: SkMatrix.h:356
static constexpr int kMScaleY
vertical scale factor
Definition: SkMatrix.h:357
static constexpr int kMSkewX
horizontal skew factor
Definition: SkMatrix.h:354
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
impeller::Scalar DlScalar
constexpr DlMatrix ToDlMatrix(const SkMatrix &matrix)
const SkPoint & ToSkPoint(const DlPoint &point)
const DlISize & ToDlISize(const SkISize &size)
const DlPoint & ToDlPoint(const SkPoint &point)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
constexpr SkM44 ToSkM44(const DlMatrix &matrix)
const DlRect & ToDlRect(const SkRect &rect)
constexpr SkMatrix ToSkMatrix(const DlMatrix &matrix)
const SkRect & ToSkRect(const DlRect &rect)
const SkISize & ToSkISize(const DlISize &size)
TRect< int32_t > IRect32
Definition: rect.h:770
float Scalar
Definition: scalar.h:18
TRect< Scalar > Rect
Definition: rect.h:769
TPoint< Scalar > Point
Definition: point.h:322
TPoint< int32_t > IPoint32
Definition: point.h:324
TSize< int32_t > ISize32
Definition: size.h:138
TSize< Scalar > Size
Definition: size.h:137
SK_API sk_sp< PrecompileColorFilter > Matrix()
Definition: SkRect.h:32
Definition: SkSize.h:16
Definition: SkSize.h:52
A 4x4 matrix using column-major storage.
Definition: matrix.h:37
Scalar m[16]
Definition: matrix.h:39
static constexpr Matrix MakeColumn(Scalar m0, Scalar m1, Scalar m2, Scalar m3, Scalar m4, Scalar m5, Scalar m6, Scalar m7, Scalar m8, Scalar m9, Scalar m10, Scalar m11, Scalar m12, Scalar m13, Scalar m14, Scalar m15)
Definition: matrix.h:69