Convert semantics_node from SkMatrix44 to SkM44 (flutter/engine#17763)

* Convert semantics_node from SkMatrix44 to SkM44
This commit is contained in:
Brian Osman
2020-04-17 07:24:40 -04:00
committed by GitHub
parent 5449a14ac2
commit 948065c3a7
10 changed files with 21 additions and 36 deletions

View File

@@ -11,7 +11,7 @@
#include <unordered_map>
#include <vector>
#include "third_party/skia/include/core/SkMatrix44.h"
#include "third_party/skia/include/core/SkM44.h"
#include "third_party/skia/include/core/SkRect.h"
namespace flutter {
@@ -115,7 +115,7 @@ struct SemanticsNode {
int32_t textDirection = 0; // 0=unknown, 1=rtl, 2=ltr
SkRect rect = SkRect::MakeEmpty();
SkMatrix44 transform = SkMatrix44(SkMatrix44::kIdentity_Constructor);
SkM44 transform = SkM44{}; // Identity
std::vector<int32_t> childrenInTraversalOrder;
std::vector<int32_t> childrenInHitTestOrder;
std::vector<int32_t> customAccessibilityActions;

View File

@@ -95,7 +95,11 @@ void SemanticsUpdateBuilder::updateNode(
node.increasedValue = increasedValue;
node.decreasedValue = decreasedValue;
node.textDirection = textDirection;
node.transform.setColMajord(transform.data());
SkScalar scalarTransform[16];
for (int i = 0; i < 16; ++i) {
scalarTransform[i] = transform.data()[i];
}
node.transform = SkM44::ColMajor(scalarTransform);
node.childrenInTraversalOrder =
std::vector<int32_t>(childrenInTraversalOrder.data(),
childrenInTraversalOrder.data() +

View File

@@ -314,7 +314,7 @@ void PlatformViewAndroid::UpdateSemantics(
buffer_float32[position++] = node.rect.top();
buffer_float32[position++] = node.rect.right();
buffer_float32[position++] = node.rect.bottom();
node.transform.asColMajorf(&buffer_float32[position]);
node.transform.getColMajor(&buffer_float32[position]);
position += 16;
buffer_int32[position++] = node.childrenInTraversalOrder.size();

View File

@@ -378,7 +378,7 @@ flutter::SemanticsAction GetSemanticsActionForScrollDirection(
}
- (CGRect)globalRect {
SkMatrix44 globalTransform = [self node].transform;
SkM44 globalTransform = [self node].transform;
for (SemanticsObject* parent = [self parent]; parent; parent = parent.parent) {
globalTransform = parent.node.transform * globalTransform;
}
@@ -386,9 +386,8 @@ flutter::SemanticsAction GetSemanticsActionForScrollDirection(
SkPoint quad[4];
[self node].rect.toQuad(quad);
for (auto& point : quad) {
SkScalar vector[4] = {point.x(), point.y(), 0, 1};
globalTransform.mapScalars(vector);
point.set(vector[0] / vector[3], vector[1] / vector[3]);
SkV4 vector = globalTransform.map(point.x(), point.y(), 0, 1);
point.set(vector.x / vector.w, vector.y / vector.w);
}
SkRect rect;
rect.setBounds(quad, 4);

View File

@@ -22,7 +22,6 @@
#include "flutter/shell/platform/darwin/ios/framework/Source/FlutterView.h"
#include "flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.h"
#include "flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge_ios.h"
#include "third_party/skia/include/core/SkMatrix44.h"
#include "third_party/skia/include/core/SkRect.h"
namespace flutter {

View File

@@ -701,7 +701,7 @@ FlutterEngineResult FlutterEngineInitialize(size_t version,
user_data](flutter::SemanticsNodeUpdates update) {
for (const auto& value : update) {
const auto& node = value.second;
SkMatrix transform = static_cast<SkMatrix>(node.transform);
SkMatrix transform = node.transform.asM33();
FlutterTransformation flutter_transform{
transform.get(SkMatrix::kMScaleX),
transform.get(SkMatrix::kMSkewX),

View File

@@ -58,7 +58,7 @@ fuchsia::ui::gfx::mat4 AccessibilityBridge::GetNodeTransform(
const flutter::SemanticsNode& node) const {
fuchsia::ui::gfx::mat4 value;
float* m = value.matrix.data();
node.transform.asColMajorf(m);
node.transform.getColMajor(m);
return value;
}
@@ -266,12 +266,12 @@ void AccessibilityBridge::AddSemanticsNodeUpdate(
void AccessibilityBridge::UpdateScreenRects() {
std::unordered_set<int32_t> visited_nodes;
UpdateScreenRects(kRootNodeId, SkMatrix44::I(), &visited_nodes);
UpdateScreenRects(kRootNodeId, SkM44{}, &visited_nodes);
}
void AccessibilityBridge::UpdateScreenRects(
int32_t node_id,
SkMatrix44 parent_transform,
SkM44 parent_transform,
std::unordered_set<int32_t>* visited_nodes) {
auto it = nodes_.find(node_id);
if (it == nodes_.end()) {
@@ -282,22 +282,12 @@ void AccessibilityBridge::UpdateScreenRects(
const auto& current_transform = parent_transform * node.transform;
const auto& rect = node.rect;
SkScalar quad[] = {
rect.left(), rect.top(), //
rect.right(), rect.top(), //
rect.right(), rect.bottom(), //
rect.left(), rect.bottom(), //
SkV4 dst[2] = {
current_transform.map(rect.left(), rect.top(), 0, 1),
current_transform.map(rect.right(), rect.bottom(), 0, 1),
};
SkScalar dst[4 * 4];
current_transform.map2(quad, 4, dst);
node.screen_rect.setLTRB(dst[0], dst[1], dst[8], dst[9]);
node.screen_rect.setLTRB(dst[0].x, dst[0].y, dst[1].x, dst[1].y);
node.screen_rect.sort();
std::vector<SkVector4> points = {
current_transform * SkVector4(rect.left(), rect.top(), 0, 1),
current_transform * SkVector4(rect.right(), rect.top(), 0, 1),
current_transform * SkVector4(rect.right(), rect.bottom(), 0, 1),
current_transform * SkVector4(rect.left(), rect.bottom(), 0, 1),
};
visited_nodes->emplace(node_id);

View File

@@ -108,7 +108,7 @@ class AccessibilityBridge
int32_t flags;
SkRect rect;
SkRect screen_rect;
SkMatrix44 transform;
SkM44 transform;
std::vector<int32_t> children_in_hit_test_order;
};
@@ -165,7 +165,7 @@ class AccessibilityBridge
//
// Update calls this via UpdateScreenRects().
void UpdateScreenRects(int32_t node_id,
SkMatrix44 parent_transform,
SkM44 parent_transform,
std::unordered_set<int32_t>* visited_nodes);
// Traverses the semantics tree to find the node_id hit by the given x,y

View File

@@ -77,11 +77,6 @@ std::ostream& operator<<(std::ostream& os, const SkVector3& v) {
return os << v.x() << ", " << v.y() << ", " << v.z();
}
std::ostream& operator<<(std::ostream& os, const SkVector4& v) {
return os << v.fData[0] << ", " << v.fData[1] << ", " << v.fData[2] << ", "
<< v.fData[3];
}
std::ostream& operator<<(std::ostream& os, const SkRect& r) {
return os << "LTRB: " << r.fLeft << ", " << r.fTop << ", " << r.fRight << ", "
<< r.fBottom;

View File

@@ -10,7 +10,6 @@
#include "third_party/skia/include/core/SkClipOp.h"
#include "third_party/skia/include/core/SkM44.h"
#include "third_party/skia/include/core/SkMatrix.h"
#include "third_party/skia/include/core/SkMatrix44.h"
#include "third_party/skia/include/core/SkPaint.h"
#include "third_party/skia/include/core/SkPath.h"
#include "third_party/skia/include/core/SkPoint3.h"
@@ -23,7 +22,6 @@ extern std::ostream& operator<<(std::ostream& os, const SkClipOp& o);
extern std::ostream& operator<<(std::ostream& os, const SkMatrix& m);
extern std::ostream& operator<<(std::ostream& os, const SkM44& m);
extern std::ostream& operator<<(std::ostream& os, const SkVector3& v);
extern std::ostream& operator<<(std::ostream& os, const SkVector4& v);
extern std::ostream& operator<<(std::ostream& os, const SkRect& r);
extern std::ostream& operator<<(std::ostream& os, const SkRRect& r);
extern std::ostream& operator<<(std::ostream& os, const SkPath& r);