Changeset 168227 in webkit


Ignore:
Timestamp:
May 3, 2014 1:32:24 PM (10 years ago)
Author:
Simon Fraser
Message:

Very fuzzy layers under non-decompasable matrices
https://bugs.webkit.org/show_bug.cgi?id=132516
<rdar://problem/16717478>

Reviewed by Sam Weinig.

Source/WebCore:
r155977 added code to modify layer contentsScale based on a root-relative
scale, so that scaled-up layers remained sharp. It does this by decomposing
an accumulated matrix, but failed to test whether the decomposition
succeeded. This would result in contentsScale of 0, which is clamped to 0.1,
resulting in very fuzzy layers.

Fix by testing for success of decomposition.

Test: compositing/contents-scale/non-decomposable-matrix.html

  • platform/graphics/ca/GraphicsLayerCA.cpp:

(WebCore::maxScaleFromTransform):

  • platform/graphics/transforms/TransformationMatrix.cpp:

(WebCore::TransformationMatrix::decompose2): Return early for identity matrices,
with fix for m11 and m22.
(WebCore::TransformationMatrix::decompose4): Return early for identity matrices.

  • platform/graphics/transforms/TransformationMatrix.h:

Make Decomposed2Type and Decomposed4Type into C++ structs.
(WebCore::TransformationMatrix::Decomposed2Type::operator==): Added to make it easier
to write code that asserts that decomposition is correct.
(WebCore::TransformationMatrix::Decomposed4Type::operator==): Ditto.

LayoutTests:
Compare scaling under non-decomposable and decomposable matrices.

  • compositing/contents-scale/non-decomposable-matrix-expected.html: Added.
  • compositing/contents-scale/non-decomposable-matrix.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r168223 r168227  
     12014-05-03  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Very fuzzy layers under non-decompasable matrices
     4        https://bugs.webkit.org/show_bug.cgi?id=132516
     5        <rdar://problem/16717478>
     6
     7        Reviewed by Sam Weinig.
     8       
     9        Compare scaling under non-decomposable and decomposable matrices.
     10
     11        * compositing/contents-scale/non-decomposable-matrix-expected.html: Added.
     12        * compositing/contents-scale/non-decomposable-matrix.html: Added.
     13
    1142014-05-03  Zalan Bujtas  <zalan@apple.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r168226 r168227  
     12014-05-03  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Very fuzzy layers under non-decompasable matrices
     4        https://bugs.webkit.org/show_bug.cgi?id=132516
     5        <rdar://problem/16717478>
     6
     7        Reviewed by Sam Weinig.
     8       
     9        r155977 added code to modify layer contentsScale based on a root-relative
     10        scale, so that scaled-up layers remained sharp. It does this by decomposing
     11        an accumulated matrix, but failed to test whether the decomposition
     12        succeeded. This would result in contentsScale of 0, which is clamped to 0.1,
     13        resulting in very fuzzy layers.
     14       
     15        Fix by testing for success of decomposition.
     16
     17        Test: compositing/contents-scale/non-decomposable-matrix.html
     18
     19        * platform/graphics/ca/GraphicsLayerCA.cpp:
     20        (WebCore::maxScaleFromTransform):
     21        * platform/graphics/transforms/TransformationMatrix.cpp:
     22        (WebCore::TransformationMatrix::decompose2): Return early for identity matrices,
     23        with fix for m11 and m22.
     24        (WebCore::TransformationMatrix::decompose4): Return early for identity matrices.
     25        * platform/graphics/transforms/TransformationMatrix.h:
     26        Make Decomposed2Type and Decomposed4Type into C++ structs.
     27        (WebCore::TransformationMatrix::Decomposed2Type::operator==): Added to make it easier
     28        to write code that asserts that decomposition is correct.
     29        (WebCore::TransformationMatrix::Decomposed4Type::operator==): Ditto.
     30
    1312014-05-03  Simon Fraser  <simon.fraser@apple.com>
    232
  • trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp

    r168219 r168227  
    294294
    295295    TransformationMatrix::Decomposed4Type decomposeData;
    296     t.decompose4(decomposeData);
     296    if (!t.decompose4(decomposeData))
     297        return 1;
     298
    297299    return std::max(fabsf(narrowPrecisionToFloat(decomposeData.scaleX)), fabsf(narrowPrecisionToFloat(decomposeData.scaleY)));
    298300}
  • trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp

    r166233 r168227  
    15801580        decomp.scaleX = 1;
    15811581        decomp.scaleY = 1;
     1582        decomp.m11 = 1;
     1583        decomp.m22 = 1;
     1584        return true;
    15821585    }
    15831586
     
    15931596        decomp.scaleY = 1;
    15941597        decomp.scaleZ = 1;
     1598        return true;
    15951599    }
    15961600
  • trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h

    r165676 r168227  
    127127    }
    128128
    129     // This form preserves the double math from input to output
     129    // This form preserves the double math from input to output.
    130130    void map(double x, double y, double& x2, double& y2) const { multVecMatrix(x, y, x2, y2); }
    131131
    132     // Map a 3D point through the transform, returning a 3D point.
     132    // Maps a 3D point through the transform, returning a 3D point.
    133133    FloatPoint3D mapPoint(const FloatPoint3D&) const;
    134134
    135     // Map a 2D point through the transform, returning a 2D point.
     135    // Maps a 2D point through the transform, returning a 2D point.
    136136    // Note that this ignores the z component, effectively projecting the point into the z=0 plane.
    137137    FloatPoint mapPoint(const FloatPoint&) const;
     
    144144
    145145    // If the matrix has 3D components, the z component of the result is
    146     // dropped, effectively projecting the rect into the z=0 plane
     146    // dropped, effectively projecting the rect into the z=0 plane.
    147147    FloatRect mapRect(const FloatRect&) const;
    148148
     
    153153
    154154    // If the matrix has 3D components, the z component of the result is
    155     // dropped, effectively projecting the quad into the z=0 plane
     155    // dropped, effectively projecting the quad into the z=0 plane.
    156156    FloatQuad mapQuad(const FloatQuad&) const;
    157157
    158     // Map a point on the z=0 plane into a point on
    159     // the plane with with the transform applied, by extending
    160     // a ray perpendicular to the source plane and computing
    161     // the local x,y position of the point where that ray intersects
    162     // with the destination plane.
     158    // Maps a point on the z=0 plane into a point on the plane with with the transform applied, by
     159    // extending a ray perpendicular to the source plane and computing the local x,y position of
     160    // the point where that ray intersects with the destination plane.
    163161    FloatPoint projectPoint(const FloatPoint&, bool* clamped = 0) const;
    164     // Projects the four corners of the quad
     162    // Projects the four corners of the quad.
    165163    FloatQuad projectQuad(const FloatQuad&,  bool* clamped = 0) const;
    166164    // Projects the four corners of the quad and takes a bounding box,
     
    231229    TransformationMatrix& rotate3d(double rx, double ry, double rz);
    232230   
    233     // The vector (x,y,z) is normalized if it's not already. A vector of
    234     // (0,0,0) uses a vector of (0,0,1).
     231    // The vector (x,y,z) is normalized if it's not already. A vector of (0,0,0) uses a vector of (0,0,1).
    235232    TransformationMatrix& rotate3d(double x, double y, double z, double angle);
    236233   
     
    251248    bool hasPerspective() const { return m_matrix[2][3] != 0.0f; }
    252249
    253     // returns a transformation that maps a rect to a rect
     250    // Returns a transformation that maps a rect to a rect.
    254251    static TransformationMatrix rectToRect(const FloatRect&, const FloatRect&);
    255252
    256253    bool isInvertible() const;
    257254
    258     // This method returns the identity matrix if it is not invertible.
     255    // Returns the identity matrix if it is not invertible.
    259256    // Use isInvertible() before calling this if you need to know.
    260257    TransformationMatrix inverse() const;
    261258
    262     // decompose the matrix into its component parts
    263     typedef struct {
     259    // Decompose the matrix into its component parts.
     260    struct Decomposed2Type {
    264261        double scaleX, scaleY;
    265262        double translateX, translateY;
    266263        double angle;
    267264        double m11, m12, m21, m22;
    268     } Decomposed2Type;
    269 
    270     typedef struct {
     265       
     266        bool operator==(const Decomposed2Type& other) const
     267        {
     268            return scaleX == other.scaleX && scaleY == other.scaleY
     269                && translateX == other.translateX && translateY == other.translateY
     270                && angle == other.angle
     271                && m11 == other.m11 && m12 == other.m12 && m21 == other.m21 && m22 == other.m22;
     272        }
     273    };
     274
     275    struct Decomposed4Type {
    271276        double scaleX, scaleY, scaleZ;
    272277        double skewXY, skewXZ, skewYZ;
     
    274279        double translateX, translateY, translateZ;
    275280        double perspectiveX, perspectiveY, perspectiveZ, perspectiveW;
    276     } Decomposed4Type;
     281
     282        bool operator==(const Decomposed4Type& other) const
     283        {
     284            return scaleX == other.scaleX && scaleY == other.scaleY && scaleZ == other.scaleZ
     285                && skewXY == other.skewXY && skewXZ == other.skewXZ && skewYZ == other.skewYZ
     286                && quaternionX == other.quaternionX && quaternionY == other.quaternionY && quaternionZ == other.quaternionZ && quaternionW == other.quaternionW
     287                && translateX == other.translateX && translateY == other.translateY && translateZ == other.translateZ
     288                && perspectiveX == other.perspectiveX && perspectiveY == other.perspectiveY && perspectiveZ == other.perspectiveZ && perspectiveW == other.perspectiveW;
     289        }
     290    };
    277291   
    278292    bool decompose2(Decomposed2Type&) const;
     
    292306    }
    293307
    294     // Throw away the non-affine parts of the matrix (lossy!)
     308    // Throw away the non-affine parts of the matrix (lossy!).
    295309    void makeAffine();
    296310
     
    358372    bool isIntegerTranslation() const;
    359373
    360     // This method returns the matrix without 3D components.
     374    // Returns the matrix without 3D components.
    361375    TransformationMatrix to2dTransform() const;
    362376   
     
    381395    }
    382396
    383     // multiply passed 3D point by matrix
    384397    void multVecMatrix(double x, double y, double z, double& dstX, double& dstY, double& dstZ) const;
    385398    FloatPoint3D internalMapPoint(const FloatPoint3D& sourcePoint) const
Note: See TracChangeset for help on using the changeset viewer.