Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit fb208b4

Browse files
authored
Convert semantics_node from SkMatrix44 to SkM44 (#17763)
* Convert semantics_node from SkMatrix44 to SkM44
1 parent 99f8d00 commit fb208b4

File tree

10 files changed

+21
-36
lines changed

10 files changed

+21
-36
lines changed

lib/ui/semantics/semantics_node.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <unordered_map>
1212
#include <vector>
1313

14-
#include "third_party/skia/include/core/SkMatrix44.h"
14+
#include "third_party/skia/include/core/SkM44.h"
1515
#include "third_party/skia/include/core/SkRect.h"
1616

1717
namespace flutter {
@@ -115,7 +115,7 @@ struct SemanticsNode {
115115
int32_t textDirection = 0; // 0=unknown, 1=rtl, 2=ltr
116116

117117
SkRect rect = SkRect::MakeEmpty();
118-
SkMatrix44 transform = SkMatrix44(SkMatrix44::kIdentity_Constructor);
118+
SkM44 transform = SkM44{}; // Identity
119119
std::vector<int32_t> childrenInTraversalOrder;
120120
std::vector<int32_t> childrenInHitTestOrder;
121121
std::vector<int32_t> customAccessibilityActions;

lib/ui/semantics/semantics_update_builder.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@ void SemanticsUpdateBuilder::updateNode(
9595
node.increasedValue = increasedValue;
9696
node.decreasedValue = decreasedValue;
9797
node.textDirection = textDirection;
98-
node.transform.setColMajord(transform.data());
98+
SkScalar scalarTransform[16];
99+
for (int i = 0; i < 16; ++i) {
100+
scalarTransform[i] = transform.data()[i];
101+
}
102+
node.transform = SkM44::ColMajor(scalarTransform);
99103
node.childrenInTraversalOrder =
100104
std::vector<int32_t>(childrenInTraversalOrder.data(),
101105
childrenInTraversalOrder.data() +

shell/platform/android/platform_view_android.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ void PlatformViewAndroid::UpdateSemantics(
314314
buffer_float32[position++] = node.rect.top();
315315
buffer_float32[position++] = node.rect.right();
316316
buffer_float32[position++] = node.rect.bottom();
317-
node.transform.asColMajorf(&buffer_float32[position]);
317+
node.transform.getColMajor(&buffer_float32[position]);
318318
position += 16;
319319

320320
buffer_int32[position++] = node.childrenInTraversalOrder.size();

shell/platform/darwin/ios/framework/Source/SemanticsObject.mm

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -378,17 +378,16 @@ - (CGRect)accessibilityFrame {
378378
}
379379

380380
- (CGRect)globalRect {
381-
SkMatrix44 globalTransform = [self node].transform;
381+
SkM44 globalTransform = [self node].transform;
382382
for (SemanticsObject* parent = [self parent]; parent; parent = parent.parent) {
383383
globalTransform = parent.node.transform * globalTransform;
384384
}
385385

386386
SkPoint quad[4];
387387
[self node].rect.toQuad(quad);
388388
for (auto& point : quad) {
389-
SkScalar vector[4] = {point.x(), point.y(), 0, 1};
390-
globalTransform.mapScalars(vector);
391-
point.set(vector[0] / vector[3], vector[1] / vector[3]);
389+
SkV4 vector = globalTransform.map(point.x(), point.y(), 0, 1);
390+
point.set(vector.x / vector.w, vector.y / vector.w);
392391
}
393392
SkRect rect;
394393
rect.setBounds(quad, 4);

shell/platform/darwin/ios/framework/Source/accessibility_bridge.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "flutter/shell/platform/darwin/ios/framework/Source/FlutterView.h"
2323
#include "flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.h"
2424
#include "flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge_ios.h"
25-
#include "third_party/skia/include/core/SkMatrix44.h"
2625
#include "third_party/skia/include/core/SkRect.h"
2726

2827
namespace flutter {

shell/platform/embedder/embedder.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ FlutterEngineResult FlutterEngineInitialize(size_t version,
701701
user_data](flutter::SemanticsNodeUpdates update) {
702702
for (const auto& value : update) {
703703
const auto& node = value.second;
704-
SkMatrix transform = static_cast<SkMatrix>(node.transform);
704+
SkMatrix transform = node.transform.asM33();
705705
FlutterTransformation flutter_transform{
706706
transform.get(SkMatrix::kMScaleX),
707707
transform.get(SkMatrix::kMSkewX),

shell/platform/fuchsia/flutter/accessibility_bridge.cc

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ fuchsia::ui::gfx::mat4 AccessibilityBridge::GetNodeTransform(
5858
const flutter::SemanticsNode& node) const {
5959
fuchsia::ui::gfx::mat4 value;
6060
float* m = value.matrix.data();
61-
node.transform.asColMajorf(m);
61+
node.transform.getColMajor(m);
6262
return value;
6363
}
6464

@@ -266,12 +266,12 @@ void AccessibilityBridge::AddSemanticsNodeUpdate(
266266

267267
void AccessibilityBridge::UpdateScreenRects() {
268268
std::unordered_set<int32_t> visited_nodes;
269-
UpdateScreenRects(kRootNodeId, SkMatrix44::I(), &visited_nodes);
269+
UpdateScreenRects(kRootNodeId, SkM44{}, &visited_nodes);
270270
}
271271

272272
void AccessibilityBridge::UpdateScreenRects(
273273
int32_t node_id,
274-
SkMatrix44 parent_transform,
274+
SkM44 parent_transform,
275275
std::unordered_set<int32_t>* visited_nodes) {
276276
auto it = nodes_.find(node_id);
277277
if (it == nodes_.end()) {
@@ -282,22 +282,12 @@ void AccessibilityBridge::UpdateScreenRects(
282282
const auto& current_transform = parent_transform * node.transform;
283283

284284
const auto& rect = node.rect;
285-
SkScalar quad[] = {
286-
rect.left(), rect.top(), //
287-
rect.right(), rect.top(), //
288-
rect.right(), rect.bottom(), //
289-
rect.left(), rect.bottom(), //
285+
SkV4 dst[2] = {
286+
current_transform.map(rect.left(), rect.top(), 0, 1),
287+
current_transform.map(rect.right(), rect.bottom(), 0, 1),
290288
};
291-
SkScalar dst[4 * 4];
292-
current_transform.map2(quad, 4, dst);
293-
node.screen_rect.setLTRB(dst[0], dst[1], dst[8], dst[9]);
289+
node.screen_rect.setLTRB(dst[0].x, dst[0].y, dst[1].x, dst[1].y);
294290
node.screen_rect.sort();
295-
std::vector<SkVector4> points = {
296-
current_transform * SkVector4(rect.left(), rect.top(), 0, 1),
297-
current_transform * SkVector4(rect.right(), rect.top(), 0, 1),
298-
current_transform * SkVector4(rect.right(), rect.bottom(), 0, 1),
299-
current_transform * SkVector4(rect.left(), rect.bottom(), 0, 1),
300-
};
301291

302292
visited_nodes->emplace(node_id);
303293

shell/platform/fuchsia/flutter/accessibility_bridge.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class AccessibilityBridge
108108
int32_t flags;
109109
SkRect rect;
110110
SkRect screen_rect;
111-
SkMatrix44 transform;
111+
SkM44 transform;
112112
std::vector<int32_t> children_in_hit_test_order;
113113
};
114114

@@ -165,7 +165,7 @@ class AccessibilityBridge
165165
//
166166
// Update calls this via UpdateScreenRects().
167167
void UpdateScreenRects(int32_t node_id,
168-
SkMatrix44 parent_transform,
168+
SkM44 parent_transform,
169169
std::unordered_set<int32_t>* visited_nodes);
170170

171171
// Traverses the semantics tree to find the node_id hit by the given x,y

testing/assertions_skia.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,6 @@ std::ostream& operator<<(std::ostream& os, const SkVector3& v) {
7777
return os << v.x() << ", " << v.y() << ", " << v.z();
7878
}
7979

80-
std::ostream& operator<<(std::ostream& os, const SkVector4& v) {
81-
return os << v.fData[0] << ", " << v.fData[1] << ", " << v.fData[2] << ", "
82-
<< v.fData[3];
83-
}
84-
8580
std::ostream& operator<<(std::ostream& os, const SkRect& r) {
8681
return os << "LTRB: " << r.fLeft << ", " << r.fTop << ", " << r.fRight << ", "
8782
<< r.fBottom;

testing/assertions_skia.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "third_party/skia/include/core/SkClipOp.h"
1111
#include "third_party/skia/include/core/SkM44.h"
1212
#include "third_party/skia/include/core/SkMatrix.h"
13-
#include "third_party/skia/include/core/SkMatrix44.h"
1413
#include "third_party/skia/include/core/SkPaint.h"
1514
#include "third_party/skia/include/core/SkPath.h"
1615
#include "third_party/skia/include/core/SkPoint3.h"
@@ -23,7 +22,6 @@ extern std::ostream& operator<<(std::ostream& os, const SkClipOp& o);
2322
extern std::ostream& operator<<(std::ostream& os, const SkMatrix& m);
2423
extern std::ostream& operator<<(std::ostream& os, const SkM44& m);
2524
extern std::ostream& operator<<(std::ostream& os, const SkVector3& v);
26-
extern std::ostream& operator<<(std::ostream& os, const SkVector4& v);
2725
extern std::ostream& operator<<(std::ostream& os, const SkRect& r);
2826
extern std::ostream& operator<<(std::ostream& os, const SkRRect& r);
2927
extern std::ostream& operator<<(std::ostream& os, const SkPath& r);

0 commit comments

Comments
 (0)