Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
0041182d
Commit
0041182d
authored
Jul 27, 2015
by
Viktor Lidholt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimizes sprites by replacing save/restore by caching the total matrix
parent
54803998
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
19 deletions
+23
-19
node.dart
packages/flutter/example/game/lib/node.dart
+14
-13
sprite.dart
packages/flutter/example/game/lib/sprite.dart
+9
-6
No files found.
packages/flutter/example/game/lib/node.dart
View file @
0041182d
...
...
@@ -37,6 +37,7 @@ class Node {
int
_addedOrder
;
int
_childrenLastAddedOrder
=
0
;
bool
_childrenNeedSorting
=
false
;
Matrix4
_savedTotalMatrix
;
/// Decides if the node and its children is currently paused.
///
...
...
@@ -414,7 +415,7 @@ class Node {
}
void
_prePaint
(
PaintingCanvas
canvas
)
{
canvas
.
save
();
_savedTotalMatrix
=
canvas
.
getTotalMatrix
();
// Get the transformation matrix and apply transform
canvas
.
concat
(
transformMatrix
.
storage
);
...
...
@@ -465,7 +466,7 @@ class Node {
}
void
_postPaint
(
PaintingCanvas
canvas
)
{
canvas
.
restore
(
);
canvas
.
setMatrix
(
_savedTotalMatrix
);
}
// Receiving update calls
...
...
packages/flutter/example/game/lib/sprite.dart
View file @
0041182d
...
...
@@ -65,7 +65,8 @@ class Sprite extends NodeWithSize {
}
void
paint
(
PaintingCanvas
canvas
)
{
canvas
.
save
();
// Store old matrix
Matrix4
savedMatrix
=
canvas
.
getTotalMatrix
();
// Account for pivot point
applyTransformForPivot
(
canvas
);
...
...
@@ -107,8 +108,10 @@ class Sprite extends NodeWithSize {
}
else
{
// Paint a red square for missing texture
canvas
.
drawRect
(
new
Rect
.
fromLTRB
(
0.0
,
0.0
,
size
.
width
,
size
.
height
),
new
Paint
()..
color
=
const
Color
.
fromARGB
(
255
,
255
,
0
,
0
));
new
Paint
()..
color
=
new
Color
.
fromARGB
(
255
,
255
,
0
,
0
));
}
canvas
.
restore
();
// Restore matrix
canvas
.
setMatrix
(
savedMatrix
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment