Changeset 220379 in webkit


Ignore:
Timestamp:
Aug 7, 2017, 7:46:11 PM (8 years ago)
Author:
Simon Fraser
Message:

Make TransformOperation::type() non-virtual
https://bugs.webkit.org/show_bug.cgi?id=175297

Reviewed by Sam Weinig.

Store the OperationType in the base class so that type() and isSameType() can
be non-virtual.

Small perf win on some benchmarks.

  • platform/graphics/transforms/IdentityTransformOperation.h:
  • platform/graphics/transforms/Matrix3DTransformOperation.h:
  • platform/graphics/transforms/MatrixTransformOperation.h:
  • platform/graphics/transforms/PerspectiveTransformOperation.h:
  • platform/graphics/transforms/RotateTransformOperation.cpp:

(WebCore::RotateTransformOperation::blend):

  • platform/graphics/transforms/RotateTransformOperation.h:
  • platform/graphics/transforms/ScaleTransformOperation.cpp:

(WebCore::ScaleTransformOperation::blend):

  • platform/graphics/transforms/ScaleTransformOperation.h:
  • platform/graphics/transforms/SkewTransformOperation.cpp:

(WebCore::SkewTransformOperation::blend):

  • platform/graphics/transforms/SkewTransformOperation.h:
  • platform/graphics/transforms/TransformOperation.h:

(WebCore::TransformOperation::TransformOperation):
(WebCore::TransformOperation::type const):
(WebCore::TransformOperation::isSameType const):

  • platform/graphics/transforms/TranslateTransformOperation.cpp:

(WebCore::TranslateTransformOperation::blend):

  • platform/graphics/transforms/TranslateTransformOperation.h:
Location:
trunk/Source/WebCore
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/Source/WebCore/ChangeLog

    r220378 r220379  
     12017-08-07  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Make TransformOperation::type() non-virtual
     4        https://bugs.webkit.org/show_bug.cgi?id=175297
     5
     6        Reviewed by Sam Weinig.
     7
     8        Store the OperationType in the base class so that type() and isSameType() can
     9        be non-virtual.
     10
     11        Small perf win on some benchmarks.
     12
     13        * platform/graphics/transforms/IdentityTransformOperation.h:
     14        * platform/graphics/transforms/Matrix3DTransformOperation.h:
     15        * platform/graphics/transforms/MatrixTransformOperation.h:
     16        * platform/graphics/transforms/PerspectiveTransformOperation.h:
     17        * platform/graphics/transforms/RotateTransformOperation.cpp:
     18        (WebCore::RotateTransformOperation::blend):
     19        * platform/graphics/transforms/RotateTransformOperation.h:
     20        * platform/graphics/transforms/ScaleTransformOperation.cpp:
     21        (WebCore::ScaleTransformOperation::blend):
     22        * platform/graphics/transforms/ScaleTransformOperation.h:
     23        * platform/graphics/transforms/SkewTransformOperation.cpp:
     24        (WebCore::SkewTransformOperation::blend):
     25        * platform/graphics/transforms/SkewTransformOperation.h:
     26        * platform/graphics/transforms/TransformOperation.h:
     27        (WebCore::TransformOperation::TransformOperation):
     28        (WebCore::TransformOperation::type const):
     29        (WebCore::TransformOperation::isSameType const):
     30        * platform/graphics/transforms/TranslateTransformOperation.cpp:
     31        (WebCore::TranslateTransformOperation::blend):
     32        * platform/graphics/transforms/TranslateTransformOperation.h:
     33
    1342017-08-07  Simon Fraser  <simon.fraser@apple.com>
    235
  • TabularUnified trunk/Source/WebCore/platform/graphics/transforms/IdentityTransformOperation.h

    r200341 r220379  
    33 *           (C) 2000 Antti Koivisto (koivisto@kde.org)
    44 *           (C) 2000 Dirk Mueller (mueller@kde.org)
    5  * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
     5 * Copyright (C) 2003, 2005-2008, 2017 Apple Inc. All rights reserved.
    66 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
    77 *
     
    2323 */
    2424
    25 #ifndef IdentityTransformOperation_h
    26 #define IdentityTransformOperation_h
     25#pragma once
    2726
    2827#include "TransformOperation.h"
     
    4544private:
    4645    bool isIdentity() const override { return true; }
    47     OperationType type() const override { return IDENTITY; }
    48     bool isSameType(const TransformOperation& o) const override { return o.type() == IDENTITY; }
    4946
    5047    bool operator==(const TransformOperation& o) const override
     
    6663
    6764    IdentityTransformOperation()
     65        : TransformOperation(IDENTITY)
    6866    {
    6967    }
    70 
    7168};
    7269
     
    7471
    7572SPECIALIZE_TYPE_TRAITS_TRANSFORMOPERATION(WebCore::IdentityTransformOperation, type() == WebCore::TransformOperation::IDENTITY)
    76 
    77 #endif // IdentityTransformOperation_h
  • TabularUnified trunk/Source/WebCore/platform/graphics/transforms/Matrix3DTransformOperation.h

    r200341 r220379  
    2424 */
    2525
    26 #ifndef Matrix3DTransformOperation_h
    27 #define Matrix3DTransformOperation_h
     26#pragma once
    2827
    2928#include "TransformOperation.h"
     
    5049    bool isAffectedByTransformOrigin() const override { return !isIdentity(); }
    5150
    52     OperationType type() const override { return MATRIX_3D; }
    53     bool isSameType(const TransformOperation& o) const override { return o.type() == MATRIX_3D; }
    54 
    5551    bool operator==(const TransformOperation&) const override;
    5652
     
    6662
    6763    Matrix3DTransformOperation(const TransformationMatrix& mat)
     64        : TransformOperation(MATRIX_3D)
     65        , m_matrix(mat)
    6866    {
    69         m_matrix = mat;
    7067    }
    7168
     
    7673
    7774SPECIALIZE_TYPE_TRAITS_TRANSFORMOPERATION(WebCore::Matrix3DTransformOperation, type() == WebCore::TransformOperation::MATRIX_3D)
    78 
    79 #endif // Matrix3DTransformOperation_h
  • TabularUnified trunk/Source/WebCore/platform/graphics/transforms/MatrixTransformOperation.h

    r200341 r220379  
    33 *           (C) 2000 Antti Koivisto (koivisto@kde.org)
    44 *           (C) 2000 Dirk Mueller (mueller@kde.org)
    5  * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
     5 * Copyright (C) 2003, 2005-2008, 2017 Apple Inc. All rights reserved.
    66 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
    77 *
     
    2323 */
    2424
    25 #ifndef MatrixTransformOperation_h
    26 #define MatrixTransformOperation_h
     25#pragma once
    2726
    2827#include "TransformOperation.h"
     
    5554    bool isAffectedByTransformOrigin() const override { return !isIdentity(); }
    5655
    57     OperationType type() const override { return MATRIX; }
    58     bool isSameType(const TransformOperation& o) const override { return o.type() == MATRIX; }
    59 
    6056    bool operator==(const TransformOperation&) const override;
    6157
     
    7268
    7369    MatrixTransformOperation(double a, double b, double c, double d, double e, double f)
    74         : m_a(a)
     70        : TransformOperation(MATRIX)
     71        , m_a(a)
    7572        , m_b(b)
    7673        , m_c(c)
     
    8279
    8380    MatrixTransformOperation(const TransformationMatrix& t)
    84         : m_a(t.a())
     81        : TransformOperation(MATRIX)
     82        , m_a(t.a())
    8583        , m_b(t.b())
    8684        , m_c(t.c())
     
    102100
    103101SPECIALIZE_TYPE_TRAITS_TRANSFORMOPERATION(WebCore::MatrixTransformOperation, type() == WebCore::TransformOperation::MATRIX)
    104 
    105 #endif // MatrixTransformOperation_h
  • TabularUnified trunk/Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.h

    r200341 r220379  
    2424 */
    2525
    26 #ifndef PerspectiveTransformOperation_h
    27 #define PerspectiveTransformOperation_h
     26#pragma once
    2827
    2928#include "Length.h"
     
    5251    bool isAffectedByTransformOrigin() const override { return !isIdentity(); }
    5352
    54     OperationType type() const override { return PERSPECTIVE; }
    55     bool isSameType(const TransformOperation& o) const override { return o.type() == PERSPECTIVE; }
    56 
    5753    bool operator==(const TransformOperation&) const override;
    5854
     
    6864
    6965    PerspectiveTransformOperation(const Length& p)
    70         : m_p(p)
     66        : TransformOperation(PERSPECTIVE)
     67        , m_p(p)
    7168    {
    7269        ASSERT(p.isFixed());
     
    7976
    8077SPECIALIZE_TYPE_TRAITS_TRANSFORMOPERATION(WebCore::PerspectiveTransformOperation, type() == WebCore::TransformOperation::PERSPECTIVE)
    81 
    82 #endif // PerspectiveTransformOperation_h
  • TabularUnified trunk/Source/WebCore/platform/graphics/transforms/RotateTransformOperation.cpp

    r202195 r220379  
    4444   
    4545    if (blendToIdentity)
    46         return RotateTransformOperation::create(m_x, m_y, m_z, m_angle - m_angle * progress, m_type);
     46        return RotateTransformOperation::create(m_x, m_y, m_z, m_angle - m_angle * progress, type());
    4747   
    4848    const RotateTransformOperation* fromOp = downcast<RotateTransformOperation>(from);
     
    5656                                                fromOp ? fromOp->m_y : m_y,
    5757                                                fromOp ? fromOp->m_z : m_z,
    58                                                 WebCore::blend(fromAngle, m_angle, progress), m_type);
     58                                                WebCore::blend(fromAngle, m_angle, progress), type());
    5959    }
    6060
  • TabularUnified trunk/Source/WebCore/platform/graphics/transforms/RotateTransformOperation.h

    r200341 r220379  
    33 *           (C) 2000 Antti Koivisto (koivisto@kde.org)
    44 *           (C) 2000 Dirk Mueller (mueller@kde.org)
    5  * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
     5 * Copyright (C) 2003, 2005-2008, 2017 Apple Inc. All rights reserved.
    66 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
    77 *
     
    2323 */
    2424
    25 #ifndef RotateTransformOperation_h
    26 #define RotateTransformOperation_h
     25#pragma once
    2726
    2827#include "TransformOperation.h"
     
    4544    Ref<TransformOperation> clone() const override
    4645    {
    47         return adoptRef(*new RotateTransformOperation(m_x, m_y, m_z, m_angle, m_type));
     46        return adoptRef(*new RotateTransformOperation(m_x, m_y, m_z, m_angle, type()));
    4847    }
    4948
     
    5655    bool isIdentity() const override { return m_angle == 0; }
    5756    bool isAffectedByTransformOrigin() const override { return !isIdentity(); }
    58 
    59     OperationType type() const override { return m_type; }
    60     bool isSameType(const TransformOperation& o) const override { return o.type() == m_type; }
    6157
    6258    bool operator==(const TransformOperation&) const override;
     
    7369
    7470    RotateTransformOperation(double x, double y, double z, double angle, OperationType type)
    75         : m_x(x)
     71        : TransformOperation(type)
     72        , m_x(x)
    7673        , m_y(y)
    7774        , m_z(z)
    7875        , m_angle(angle)
    79         , m_type(type)
    8076    {
    8177        ASSERT(isRotateTransformOperationType());
     
    8682    double m_z;
    8783    double m_angle;
    88     OperationType m_type;
    8984};
    9085
     
    9287
    9388SPECIALIZE_TYPE_TRAITS_TRANSFORMOPERATION(WebCore::RotateTransformOperation, isRotateTransformOperationType())
    94 
    95 #endif // RotateTransformOperation_h
  • TabularUnified trunk/Source/WebCore/platform/graphics/transforms/ScaleTransformOperation.cpp

    r200341 r220379  
    4444        return ScaleTransformOperation::create(WebCore::blend(m_x, 1.0, progress),
    4545                                               WebCore::blend(m_y, 1.0, progress),
    46                                                WebCore::blend(m_z, 1.0, progress), m_type);
     46                                               WebCore::blend(m_z, 1.0, progress), type());
    4747   
    4848    const ScaleTransformOperation* fromOp = downcast<ScaleTransformOperation>(from);
     
    5252    return ScaleTransformOperation::create(WebCore::blend(fromX, m_x, progress),
    5353                                           WebCore::blend(fromY, m_y, progress),
    54                                            WebCore::blend(fromZ, m_z, progress), m_type);
     54                                           WebCore::blend(fromZ, m_z, progress), type());
    5555}
    5656
  • TabularUnified trunk/Source/WebCore/platform/graphics/transforms/ScaleTransformOperation.h

    r200341 r220379  
    33 *           (C) 2000 Antti Koivisto (koivisto@kde.org)
    44 *           (C) 2000 Dirk Mueller (mueller@kde.org)
    5  * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
     5 * Copyright (C) 2003, 2005-2008, 2017 Apple Inc. All rights reserved.
    66 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
    77 *
     
    2323 */
    2424
    25 #ifndef ScaleTransformOperation_h
    26 #define ScaleTransformOperation_h
     25#pragma once
    2726
    2827#include "TransformOperation.h"
     
    4544    Ref<TransformOperation> clone() const override
    4645    {
    47         return adoptRef(*new ScaleTransformOperation(m_x, m_y, m_z, m_type));
     46        return adoptRef(*new ScaleTransformOperation(m_x, m_y, m_z, type()));
    4847    }
    4948
     
    5554    bool isIdentity() const override { return m_x == 1 &&  m_y == 1 &&  m_z == 1; }
    5655    bool isAffectedByTransformOrigin() const override { return !isIdentity(); }
    57 
    58     OperationType type() const override { return m_type; }
    59     bool isSameType(const TransformOperation& o) const override { return o.type() == m_type; }
    6056
    6157    bool operator==(const TransformOperation&) const override;
     
    7268
    7369    ScaleTransformOperation(double sx, double sy, double sz, OperationType type)
    74         : m_x(sx)
     70        : TransformOperation(type)
     71        , m_x(sx)
    7572        , m_y(sy)
    7673        , m_z(sz)
    77         , m_type(type)
    7874    {
    7975        ASSERT(isScaleTransformOperationType());
     
    8379    double m_y;
    8480    double m_z;
    85     OperationType m_type;
    8681};
    8782
     
    8984
    9085SPECIALIZE_TYPE_TRAITS_TRANSFORMOPERATION(WebCore::ScaleTransformOperation, isScaleTransformOperationType())
    91 
    92 #endif // ScaleTransformOperation_h
  • TabularUnified trunk/Source/WebCore/platform/graphics/transforms/SkewTransformOperation.cpp

    r200341 r220379  
    4242   
    4343    if (blendToIdentity)
    44         return SkewTransformOperation::create(WebCore::blend(m_angleX, 0.0, progress), WebCore::blend(m_angleY, 0.0, progress), m_type);
     44        return SkewTransformOperation::create(WebCore::blend(m_angleX, 0.0, progress), WebCore::blend(m_angleY, 0.0, progress), type());
    4545   
    4646    const SkewTransformOperation* fromOp = downcast<SkewTransformOperation>(from);
    4747    double fromAngleX = fromOp ? fromOp->m_angleX : 0;
    4848    double fromAngleY = fromOp ? fromOp->m_angleY : 0;
    49     return SkewTransformOperation::create(WebCore::blend(fromAngleX, m_angleX, progress), WebCore::blend(fromAngleY, m_angleY, progress), m_type);
     49    return SkewTransformOperation::create(WebCore::blend(fromAngleX, m_angleX, progress), WebCore::blend(fromAngleY, m_angleY, progress), type());
    5050}
    5151
  • TabularUnified trunk/Source/WebCore/platform/graphics/transforms/SkewTransformOperation.h

    r200341 r220379  
    33 *           (C) 2000 Antti Koivisto (koivisto@kde.org)
    44 *           (C) 2000 Dirk Mueller (mueller@kde.org)
    5  * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
     5 * Copyright (C) 2003, 2005-2008, 2017 Apple Inc. All rights reserved.
    66 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
    77 *
     
    2323 */
    2424
    25 #ifndef SkewTransformOperation_h
    26 #define SkewTransformOperation_h
     25#pragma once
    2726
    2827#include "TransformOperation.h"
     
    4039    Ref<TransformOperation> clone() const override
    4140    {
    42         return adoptRef(*new SkewTransformOperation(m_angleX, m_angleY, m_type));
     41        return adoptRef(*new SkewTransformOperation(m_angleX, m_angleY, type()));
    4342    }
    4443
     
    4948    bool isIdentity() const override { return m_angleX == 0 && m_angleY == 0; }
    5049    bool isAffectedByTransformOrigin() const override { return !isIdentity(); }
    51 
    52     OperationType type() const override { return m_type; }
    53     bool isSameType(const TransformOperation& o) const override { return o.type() == m_type; }
    5450
    5551    bool operator==(const TransformOperation&) const override;
     
    6662   
    6763    SkewTransformOperation(double angleX, double angleY, OperationType type)
    68         : m_angleX(angleX)
     64        : TransformOperation(type)
     65        , m_angleX(angleX)
    6966        , m_angleY(angleY)
    70         , m_type(type)
    7167    {
    7268        ASSERT(isSkewTransformOperationType());
     
    7571    double m_angleX;
    7672    double m_angleY;
    77     OperationType m_type;
    7873};
    7974
     
    8176
    8277SPECIALIZE_TYPE_TRAITS_TRANSFORMOPERATION(WebCore::SkewTransformOperation, isSkewTransformOperationType())
    83 
    84 #endif // SkewTransformOperation_h
  • TabularUnified trunk/Source/WebCore/platform/graphics/transforms/TransformOperation.h

    r200341 r220379  
    33 *           (C) 2000 Antti Koivisto (koivisto@kde.org)
    44 *           (C) 2000 Dirk Mueller (mueller@kde.org)
    5  * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
     5 * Copyright (C) 2003, 2005-2008, 2017 Apple Inc. All rights reserved.
    66 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
    77 *
     
    2323 */
    2424
    25 #ifndef TransformOperation_h
    26 #define TransformOperation_h
     25#pragma once
    2726
    2827#include "FloatSize.h"
     
    5352    };
    5453
     54    TransformOperation(OperationType type)
     55        : m_type(type)
     56    {
     57    }
    5558    virtual ~TransformOperation() { }
    5659
     
    6770    virtual Ref<TransformOperation> blend(const TransformOperation* from, double progress, bool blendToIdentity = false) = 0;
    6871
    69     virtual OperationType type() const = 0;
    70     virtual bool isSameType(const TransformOperation&) const { return false; }
     72    OperationType type() const { return m_type; }
     73    bool isSameType(const TransformOperation& other) const { return type() == other.type(); }
    7174
    7275    virtual bool isAffectedByTransformOrigin() const { return false; }
     
    107110   
    108111    virtual void dump(TextStream&) const = 0;
     112
     113private:
     114    OperationType m_type;
    109115};
    110116
     
    118124    static bool isType(const WebCore::TransformOperation& operation) { return operation.predicate; } \
    119125SPECIALIZE_TYPE_TRAITS_END()
    120 
    121 #endif // TransformOperation_h
  • TabularUnified trunk/Source/WebCore/platform/graphics/transforms/TranslateTransformOperation.cpp

    r200343 r220379  
    4343    Length zeroLength(0, Fixed);
    4444    if (blendToIdentity)
    45         return TranslateTransformOperation::create(WebCore::blend(m_x, zeroLength, progress), WebCore::blend(m_y, zeroLength, progress), WebCore::blend(m_z, zeroLength, progress), m_type);
     45        return TranslateTransformOperation::create(WebCore::blend(m_x, zeroLength, progress), WebCore::blend(m_y, zeroLength, progress), WebCore::blend(m_z, zeroLength, progress), type());
    4646
    4747    const TranslateTransformOperation* fromOp = downcast<TranslateTransformOperation>(from);
     
    4949    Length fromY = fromOp ? fromOp->m_y : zeroLength;
    5050    Length fromZ = fromOp ? fromOp->m_z : zeroLength;
    51     return TranslateTransformOperation::create(WebCore::blend(fromX, x(), progress), WebCore::blend(fromY, y(), progress), WebCore::blend(fromZ, z(), progress), m_type);
     51    return TranslateTransformOperation::create(WebCore::blend(fromX, x(), progress), WebCore::blend(fromY, y(), progress), WebCore::blend(fromZ, z(), progress), type());
    5252}
    5353
  • TabularUnified trunk/Source/WebCore/platform/graphics/transforms/TranslateTransformOperation.h

    r200341 r220379  
    33 *           (C) 2000 Antti Koivisto (koivisto@kde.org)
    44 *           (C) 2000 Dirk Mueller (mueller@kde.org)
    5  * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
     5 * Copyright (C) 2003, 2005-2008, 2017 Apple Inc. All rights reserved.
    66 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
    77 *
     
    2323 */
    2424
    25 #ifndef TranslateTransformOperation_h
    26 #define TranslateTransformOperation_h
     25#pragma once
    2726
    2827#include "Length.h"
     
    4746    Ref<TransformOperation> clone() const override
    4847    {
    49         return adoptRef(*new TranslateTransformOperation(m_x, m_y, m_z, m_type));
     48        return adoptRef(*new TranslateTransformOperation(m_x, m_y, m_z, type()));
    5049    }
    5150
     
    6059private:
    6160    bool isIdentity() const override { return !floatValueForLength(m_x, 1) && !floatValueForLength(m_y, 1) && !floatValueForLength(m_z, 1); }
    62 
    63     OperationType type() const override { return m_type; }
    64     bool isSameType(const TransformOperation& o) const override { return o.type() == m_type; }
    6561
    6662    bool operator==(const TransformOperation&) const override;
     
    7773
    7874    TranslateTransformOperation(const Length& tx, const Length& ty, const Length& tz, OperationType type)
    79         : m_x(tx)
     75        : TransformOperation(type)
     76        , m_x(tx)
    8077        , m_y(ty)
    8178        , m_z(tz)
    82         , m_type(type)
    8379    {
    8480        ASSERT(isTranslateTransformOperationType());
     
    8884    Length m_y;
    8985    Length m_z;
    90     OperationType m_type;
    9186};
    9287
     
    9489
    9590SPECIALIZE_TYPE_TRAITS_TRANSFORMOPERATION(WebCore::TranslateTransformOperation, isTranslateTransformOperationType())
    96 
    97 #endif // TranslateTransformOperation_h
Note: See TracChangeset for help on using the changeset viewer.