-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadtransforms-floating-point
78 lines (69 loc) · 4.29 KB
/
readtransforms-floating-point
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
From: L. David Baron <dbaron@dbaron.org>
Bug 1158560 - Avoid accumulating unnecessary floating point error in ReadTransforms.
A try run shows that this fixes the fuzz in the test, as annotated.
FIXME: Investigate why aAppUnitsPerMatrixUnit is different.
FIXME: Need to retest removal of annotations, since I've added more removals.
diff --git a/layout/reftests/transform-3d/reftest.list b/layout/reftests/transform-3d/reftest.list
--- a/layout/reftests/transform-3d/reftest.list
+++ b/layout/reftests/transform-3d/reftest.list
@@ -59,20 +59,20 @@ fuzzy-if(webrender,0-1,0-4) == rotatex-t
fuzzy-if((gtkWidget&&layersOMTC)||(winWidget&&!layersGPUAccelerated),0-1,0-86) == overflow-hidden-1a.html overflow-hidden-1-ref.html
fails-if(webrender) == transform-style-flat-1a.html transform-style-flat-1-ref.html
== willchange-containing-block.html?willchange willchange-containing-block.html?ref
!= willchange-containing-block.html?willchange willchange-containing-block.html?noblock
fuzzy-if(winWidget&&!layersGPUAccelerated,0-1,0-606) == scroll-perspective-1.html scroll-perspective-1-ref.html
# Bugs
fails-if(!layersGPUAccelerated) == 1035611-1.html 1035611-1-ref.html # Bug 1072898 for !layersGPUAccelerated failures
!= 1157984-1.html about:blank # Bug 1157984
-fuzzy(0-3,0-99) == animate-cube-radians.html animate-cube-radians-ref.html # subpixel AA
-fuzzy(0-3,0-99) fuzzy-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)&&!layersGPUAccelerated,0-16,0-6) == animate-cube-radians-zoom.html animate-cube-radians-zoom-ref.html
+== animate-cube-radians.html animate-cube-radians-ref.html
+== animate-cube-radians-zoom.html animate-cube-radians-zoom-ref.html
!= animate-cube-radians-ref.html animate-cube-radians-zoom-ref.html
-fuzzy(0-3,0-99) == animate-cube-degrees.html animate-cube-degrees-ref.html # subpixel AA
+== animate-cube-degrees.html animate-cube-degrees-ref.html
== animate-cube-degrees-zoom.html animate-cube-degrees-zoom-ref.html
!= animate-cube-degrees-ref.html animate-cube-degrees-zoom-ref.html
fuzzy-if(gtkWidget,0-128,0-100) fuzzy-if(Android||OSX==1010||(gtkWidget&&layersGPUAccelerated),0-143,0-100) fuzzy-if(winWidget||OSX<1010,0-141,0-100) == preserves3d-nested.html preserves3d-nested-ref.html
fuzzy-if(cocoaWidget,0-128,0-9) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == animate-preserve3d-parent.html animate-preserve3d-ref.html # intermittently fuzzy on Mac
fuzzy-if(cocoaWidget,0-128,0-9) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) == animate-preserve3d-child.html animate-preserve3d-ref.html # intermittently fuzzy on Mac, bug 1461311 for Android
== animate-backface-hidden.html about:blank
== 1245450-1.html green-rect.html
fuzzy(0-1,0-2000) == opacity-preserve3d-1.html opacity-preserve3d-1-ref.html
diff --git a/layout/style/nsStyleTransformMatrix.cpp b/layout/style/nsStyleTransformMatrix.cpp
--- a/layout/style/nsStyleTransformMatrix.cpp
+++ b/layout/style/nsStyleTransformMatrix.cpp
@@ -980,18 +980,35 @@ ReadTransforms(const nsCSSValueList* aIn
}
}
if (aTransform) {
ReadTransformsImpl(result, aTransform, aRefBox, aContains3dTransform);
}
float scale = float(AppUnitsPerCSSPixel()) / aAppUnitsPerMatrixUnit;
- result.PreScale(1/scale, 1/scale, 1/scale);
- result.PostScale(scale, scale, scale);
+ // What we want to do here is conceptually this:
+ // result.PreScale(1/scale, 1/scale, 1/scale);
+ // result.PostScale(scale, scale, scale);
+ // in order to convert |result| from a matrix that applies to CSS
+ // pixels into a matrix that applies to device pixels. (Essentially,
+ // we apply one scale transform device pixels into CSS pixels, apply
+ // the matrix, and then apply the inverse.)
+ //
+ // However, actually making those calls would apply multiplication by
+ // both scale and 1/scale to the _11, _12, _13, _21, _22, _23, _31,
+ // _32, and _33 components of the matrix. This leads to accumulation
+ // of floating point error. So, instead, we'll do the equivalent but
+ // only actually touch the components we need to touch.
+ result._14 *= 1/scale;
+ result._24 *= 1/scale;
+ result._34 *= 1/scale;
+ result._41 *= scale;
+ result._42 *= scale;
+ result._43 *= scale;
return result;
}
Point
Convert2DPosition(nsStyleCoord const (&aValue)[2],
TransformReferenceBox& aRefBox,
int32_t aAppUnitsPerDevPixel)