Skip to content

Commit

Permalink
[web] Cleanup Vector3
Browse files Browse the repository at this point in the history
  • Loading branch information
mdebbar committed May 18, 2023
1 parent fe24767 commit 7c0a015
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 381 deletions.
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

0 comments on commit 7c0a015

Please sign in to comment.