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
aa80bd6f
Commit
aa80bd6f
authored
Dec 11, 2015
by
Ian Hickson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #886 from Hixie/applyPaintTransform
applyPaintTransform() improvements
parents
7c8c8c1e
d1364643
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
32 deletions
+39
-32
material.dart
packages/flutter/lib/src/material/material.dart
+5
-4
block.dart
packages/flutter/lib/src/rendering/block.dart
+2
-2
box.dart
packages/flutter/lib/src/rendering/box.dart
+23
-19
object.dart
packages/flutter/lib/src/rendering/object.dart
+5
-3
proxy_box.dart
packages/flutter/lib/src/rendering/proxy_box.dart
+2
-2
viewport.dart
packages/flutter/lib/src/rendering/viewport.dart
+2
-2
No files found.
packages/flutter/lib/src/material/material.dart
View file @
aa80bd6f
...
...
@@ -298,17 +298,18 @@ abstract class InkFeature {
assert
(
referenceBox
.
attached
);
assert
(!
_debugDisposed
);
// find the chain of renderers from us to the feature's referenceBox
List
<
RenderBox
>
descendants
=
<
RenderBox
>[];
List
<
RenderBox
>
descendants
=
<
RenderBox
>[
referenceBox
];
RenderBox
node
=
referenceBox
;
while
(
node
!=
renderer
)
{
descendants
.
add
(
node
);
node
=
node
.
parent
;
assert
(
node
!=
null
);
descendants
.
add
(
node
);
}
// determine the transform that gets our coordinate system to be like theirs
Matrix4
transform
=
new
Matrix4
.
identity
();
for
(
RenderBox
descendant
in
descendants
.
reversed
)
descendant
.
applyPaintTransform
(
transform
);
assert
(
descendants
.
length
>=
2
);
for
(
int
index
=
descendants
.
length
-
1
;
index
>
0
;
index
-=
1
)
descendants
[
index
].
applyPaintTransform
(
descendants
[
index
-
1
],
transform
);
paintFeature
(
canvas
,
transform
);
}
...
...
packages/flutter/lib/src/rendering/block.dart
View file @
aa80bd6f
...
...
@@ -420,12 +420,12 @@ class RenderBlockViewport extends RenderBlockBase {
context
.
pushClipRect
(
needsCompositing
,
offset
,
Point
.
origin
&
size
,
_paintContents
);
}
void
applyPaintTransform
(
Matrix4
transform
)
{
super
.
applyPaintTransform
(
transform
);
void
applyPaintTransform
(
RenderBox
child
,
Matrix4
transform
)
{
if
(
isVertical
)
transform
.
translate
(
0.0
,
startOffset
);
else
transform
.
translate
(
startOffset
,
0.0
);
super
.
applyPaintTransform
(
child
,
transform
);
}
bool
hitTestChildren
(
HitTestResult
result
,
{
Point
position
})
{
...
...
packages/flutter/lib/src/rendering/box.dart
View file @
aa80bd6f
...
...
@@ -609,23 +609,26 @@ abstract class RenderBox extends RenderObject {
/// visually "on top" (i.e., paints later).
bool
hitTestChildren
(
HitTestResult
result
,
{
Point
position
})
=>
false
;
static
Point
_transformPoint
(
Matrix4
transform
,
Point
point
)
{
Vector3
position3
=
new
Vector3
(
point
.
x
,
point
.
y
,
0.0
);
Vector3
transformed3
=
transform
.
transform3
(
position3
);
return
new
Point
(
transformed3
.
x
,
transformed3
.
y
);
}
/// Multiply the transform from the parent's coordinate system to this box's
/// coordinate system into the given transform
/// coordinate system into the given transform
.
///
/// This function is used to convert coordinate systems between boxes.
/// Subclasses that apply transforms during painting should override this
/// function to factor those transforms into the calculation.
void
applyPaintTransform
(
Matrix4
transform
)
{
if
(
parentData
is
BoxParentData
)
{
Point
position
=
(
parentData
as
BoxParentData
).
position
;
transform
.
translate
(
position
.
x
,
position
.
y
);
}
}
static
Point
_transformPoint
(
Matrix4
transform
,
Point
point
)
{
Vector3
position3
=
new
Vector3
(
point
.
x
,
point
.
y
,
0.0
);
Vector3
transformed3
=
transform
.
transform3
(
position3
);
return
new
Point
(
transformed3
.
x
,
transformed3
.
y
);
///
/// The RenderBox implementation takes care of adjusting the matrix for the
/// position of the given child.
void
applyPaintTransform
(
RenderObject
child
,
Matrix4
transform
)
{
assert
(
child
.
parent
==
this
);
BoxParentData
childParentData
=
child
.
parentData
;
Point
position
=
childParentData
.
position
;
transform
.
translate
(
position
.
x
,
position
.
y
);
}
/// Convert the given point from the global coodinate system to the local
...
...
@@ -634,24 +637,25 @@ abstract class RenderBox extends RenderObject {
assert
(
attached
);
Matrix4
transform
=
new
Matrix4
.
identity
();
RenderObject
renderer
=
this
;
while
(
renderer
!=
null
)
{
renderer
.
applyPaintTransform
(
transform
);
renderer
=
renderer
.
parent
;
while
(
renderer
.
parent
is
RenderObject
)
{
RenderObject
rendererParent
=
renderer
.
parent
;
rendererParent
.
applyPaintTransform
(
renderer
,
transform
);
renderer
=
rendererParent
;
}
/* double det = */
transform
.
invert
();
// TODO(abarth): Check the determinant for degeneracy.
return
_transformPoint
(
transform
,
point
);
}
/// Convert the given point from the local coordi
an
te system for this box to
/// the global coordinate sy
tem
/// Convert the given point from the local coordi
na
te system for this box to
/// the global coordinate sy
stem.
Point
localToGlobal
(
Point
point
)
{
List
<
RenderObject
>
renderers
=
<
RenderObject
>[];
for
(
RenderObject
renderer
=
this
;
renderer
!=
null
;
renderer
=
renderer
.
parent
)
renderers
.
add
(
renderer
);
Matrix4
transform
=
new
Matrix4
.
identity
();
for
(
RenderObject
renderer
in
renderers
.
reversed
)
renderer
.
applyPaintTransform
(
transform
);
for
(
int
index
=
renderers
.
length
-
1
;
index
>
0
;
index
-=
1
)
renderer
s
[
index
].
applyPaintTransform
(
renderers
[
index
-
1
],
transform
);
return
_transformPoint
(
transform
,
point
);
}
...
...
packages/flutter/lib/src/rendering/object.dart
View file @
aa80bd6f
...
...
@@ -1036,12 +1036,14 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
/// be recorded on separate compositing layers.
void
paint
(
PaintingContext
context
,
Offset
offset
)
{
}
///
If this render object applies a transform before painting, apply that
/// t
ransform to the given matrix
///
Applies the transform that would be applied when painting the given child
/// t
o the given matrix.
///
/// Used by coordinate conversion functions to translate coordinates local to
/// one render object into coordinates local to another render object.
void
applyPaintTransform
(
Matrix4
transform
)
{
}
void
applyPaintTransform
(
RenderObject
child
,
Matrix4
transform
)
{
assert
(
child
.
parent
==
this
);
}
// EVENTS
...
...
packages/flutter/lib/src/rendering/proxy_box.dart
View file @
aa80bd6f
...
...
@@ -974,9 +974,9 @@ class RenderTransform extends RenderProxyBox {
}
}
void
applyPaintTransform
(
Matrix4
transform
)
{
super
.
applyPaintTransform
(
transform
);
void
applyPaintTransform
(
RenderBox
child
,
Matrix4
transform
)
{
transform
.
multiply
(
_effectiveTransform
);
super
.
applyPaintTransform
(
child
,
transform
);
}
void
debugDescribeSettings
(
List
<
String
>
settings
)
{
...
...
packages/flutter/lib/src/rendering/viewport.dart
View file @
aa80bd6f
...
...
@@ -164,9 +164,9 @@ class RenderViewport extends RenderBox with RenderObjectWithChildMixin<RenderBox
}
}
void
applyPaintTransform
(
Matrix4
transform
)
{
super
.
applyPaintTransform
(
transform
);
void
applyPaintTransform
(
RenderBox
child
,
Matrix4
transform
)
{
transform
.
translate
(-
scrollOffset
.
dx
,
-
scrollOffset
.
dy
);
super
.
applyPaintTransform
(
child
,
transform
);
}
bool
hitTestChildren
(
HitTestResult
result
,
{
Point
position
})
{
...
...
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