Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[web] Cleanup Vector3 #42096

Merged
merged 2 commits into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions lib/web_ui/lib/src/engine/canvas_pool.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1128,9 +1128,6 @@ class ContextStateHandle {
/// Provides save stack tracking functionality to implementations of
/// [EngineCanvas].
class _SaveStackTracking {
// !Warning: this vector should not be mutated.
static final Vector3 _unitZ = Vector3(0.0, 0.0, 1.0);

final List<SaveStackEntry> _saveStack = <SaveStackEntry>[];

/// The stack that maintains clipping operations used when text is painted
Expand Down Expand Up @@ -1189,7 +1186,7 @@ class _SaveStackTracking {
/// Rotates the [currentTransform] matrix.
@mustCallSuper
void rotate(double radians) {
_currentTransform.rotate(_unitZ, radians);
_currentTransform.rotate(kUnitZ, radians);
}

/// Skews the [currentTransform] matrix.
Expand Down
8 changes: 2 additions & 6 deletions lib/web_ui/lib/src/engine/engine_canvas.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ class SaveClipEntry {
/// Provides save stack tracking functionality to implementations of
/// [EngineCanvas].
mixin SaveStackTracking on EngineCanvas {
static final Vector3 _unitZ = Vector3(0.0, 0.0, 1.0);

final List<SaveStackEntry> _saveStack = <SaveStackEntry>[];

/// The stack that maintains clipping operations used when text is painted
Expand Down Expand Up @@ -206,7 +204,7 @@ mixin SaveStackTracking on EngineCanvas {
/// Classes that override this method must call `super.rotate()`.
@override
void rotate(double radians) {
_currentTransform.rotate(_unitZ, radians);
_currentTransform.rotate(kUnitZ, radians);
}

/// Skews the [currentTransform] matrix.
Expand Down Expand Up @@ -288,8 +286,6 @@ class _SaveElementStackEntry {
/// Provides save stack tracking functionality to implementations of
/// [EngineCanvas].
mixin SaveElementStackTracking on EngineCanvas {
static final Vector3 _unitZ = Vector3(0.0, 0.0, 1.0);

final List<_SaveElementStackEntry> _saveStack = <_SaveElementStackEntry>[];

/// The element at the top of the element stack, or [rootElement] if the stack
Expand Down Expand Up @@ -373,7 +369,7 @@ mixin SaveElementStackTracking on EngineCanvas {
/// Classes that override this method must call `super.rotate()`.
@override
void rotate(double radians) {
_currentTransform.rotate(_unitZ, radians);
_currentTransform.rotate(kUnitZ, radians);
}

/// Skews the [currentTransform] matrix.
Expand Down
8 changes: 4 additions & 4 deletions lib/web_ui/lib/src/engine/html/bitmap_canvas.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1081,11 +1081,11 @@ class BitmapCanvas extends EngineCanvas {
final double dpr = ui.window.devicePixelRatio;
final double width = ui.window.physicalSize.width * dpr;
final double height = ui.window.physicalSize.height * dpr;
final Vector3 topLeft = inverted.perspectiveTransform(Vector3(0, 0, 0));
final Vector3 topRight = inverted.perspectiveTransform(Vector3(width, 0, 0));
final Vector3 topLeft = inverted.perspectiveTransform(x: 0, y: 0, z: 0);
final Vector3 topRight = inverted.perspectiveTransform(x: width, y: 0, z: 0);
final Vector3 bottomRight =
inverted.perspectiveTransform(Vector3(width, height, 0));
final Vector3 bottomLeft = inverted.perspectiveTransform(Vector3(0, height, 0));
inverted.perspectiveTransform(x: width, y: height, z: 0);
final Vector3 bottomLeft = inverted.perspectiveTransform(x: 0, y: height, z: 0);
return ui.Rect.fromLTRB(
math.min(topLeft.x,
math.min(topRight.x, math.min(bottomRight.x, bottomLeft.x))),
Expand Down
Loading