Changeset 152175 in webkit


Ignore:
Timestamp:
Jun 28, 2013 10:31:30 AM (11 years ago)
Author:
Simon Fraser
Message:

Allow some LayoutPoint and LayoutSize conversions to be inlined
https://bugs.webkit.org/show_bug.cgi?id=118167

Reviewed by Ryosuke Niwa.

Construction of FloatSize from LayoutSize, and FloatPoint's move(const LayoutSize&)
and moveBy(const LayoutPoint&) were not inlined, and showed up on some profiles.

Make them inlined by removing the overloaded functions, and instead providing
conversion operators from LayoutSize to FloatSize, and LayoutPoint to FloatPoint.
Do the same to allow a LayoutRect to be converted to a FloatRect.

This is nice because it removes pollution of FloatRect, FloatPoint and FloatSize with
Layout* entirely.

Remove Qt-specific conversions on LayoutRect, LayoutPoint and LayoutSize. Qt can
convert via IntRect/FloatRect as necessary.

  • platform/graphics/FloatPoint.cpp:
  • platform/graphics/FloatPoint.h:

(WebCore::FloatPoint::move):
(WebCore::FloatPoint::moveBy):

  • platform/graphics/FloatRect.cpp:
  • platform/graphics/FloatRect.h:
  • platform/graphics/FloatSize.cpp:
  • platform/graphics/FloatSize.h:
  • platform/graphics/LayoutPoint.h:

(WebCore::LayoutPoint::operator FloatPoint):

  • platform/graphics/LayoutRect.cpp:
  • platform/graphics/LayoutRect.h:

(WebCore::LayoutRect::operator FloatRect):

  • platform/graphics/LayoutSize.h:

(WebCore::LayoutSize::operator FloatSize):

Location:
trunk/Source/WebCore
Files:
3 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r152168 r152175  
     12013-06-28  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Allow some LayoutPoint and LayoutSize conversions to be inlined
     4        https://bugs.webkit.org/show_bug.cgi?id=118167
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Construction of FloatSize from LayoutSize, and FloatPoint's move(const LayoutSize&)
     9        and moveBy(const LayoutPoint&) were not inlined, and showed up on some profiles.
     10       
     11        Make them inlined by removing the overloaded functions, and instead providing
     12        conversion operators from LayoutSize to FloatSize, and LayoutPoint to FloatPoint.
     13        Do the same to allow a LayoutRect to be converted to a FloatRect.
     14       
     15        This is nice because it removes pollution of FloatRect, FloatPoint and FloatSize with
     16        Layout* entirely.
     17       
     18        Remove Qt-specific conversions on LayoutRect, LayoutPoint and LayoutSize. Qt can
     19        convert via IntRect/FloatRect as necessary.
     20
     21        * platform/graphics/FloatPoint.cpp:
     22        * platform/graphics/FloatPoint.h:
     23        (WebCore::FloatPoint::move):
     24        (WebCore::FloatPoint::moveBy):
     25        * platform/graphics/FloatRect.cpp:
     26        * platform/graphics/FloatRect.h:
     27        * platform/graphics/FloatSize.cpp:
     28        * platform/graphics/FloatSize.h:
     29        * platform/graphics/LayoutPoint.h:
     30        (WebCore::LayoutPoint::operator FloatPoint):
     31        * platform/graphics/LayoutRect.cpp:
     32        * platform/graphics/LayoutRect.h:
     33        (WebCore::LayoutRect::operator FloatRect):
     34        * platform/graphics/LayoutSize.h:
     35        (WebCore::LayoutSize::operator FloatSize):
     36
    1372013-06-28  Christophe Dumez  <ch.dumez@sisa.samsung.com>
    238
  • trunk/Source/WebCore/Target.pri

    r152167 r152175  
    28602860    platform/graphics/qt/FloatRectQt.cpp \
    28612861    platform/graphics/qt/FloatSizeQt.cpp \
    2862     platform/graphics/qt/LayoutPointQt.cpp \
    2863     platform/graphics/qt/LayoutRectQt.cpp \
    2864     platform/graphics/qt/LayoutSizeQt.cpp \
    28652862    platform/graphics/qt/GradientQt.cpp \
    28662863    platform/graphics/qt/GraphicsContextQt.cpp \
  • trunk/Source/WebCore/platform/graphics/FloatPoint.cpp

    r138800 r152175  
    3131#include "FloatConversion.h"
    3232#include "IntPoint.h"
    33 #include "LayoutPoint.h"
    34 #include "LayoutSize.h"
    3533#include "TransformationMatrix.h"
    3634#include <limits>
     
    4038
    4139FloatPoint::FloatPoint(const IntPoint& p) : m_x(p.x()), m_y(p.y())
    42 {
    43 }
    44 
    45 FloatPoint::FloatPoint(const LayoutPoint& p) : m_x(p.x()), m_y(p.y())
    4640{
    4741}
     
    6559{
    6660    return sqrtf(lengthSquared());
    67 }
    68 
    69 void FloatPoint::move(const LayoutSize& size)
    70 {
    71     m_x += size.width();
    72     m_y += size.height();
    73 }
    74 
    75 void FloatPoint::moveBy(const LayoutPoint& point)
    76 {
    77     m_x += point.x();
    78     m_y += point.y();
    7961}
    8062
  • trunk/Source/WebCore/platform/graphics/FloatPoint.h

    r149193 r152175  
    6565class IntPoint;
    6666class IntSize;
    67 class LayoutPoint;
    68 class LayoutSize;
    6967
    7068class FloatPoint {
     
    7371    FloatPoint(float x, float y) : m_x(x), m_y(y) { }
    7472    FloatPoint(const IntPoint&);
    75     FloatPoint(const LayoutPoint&);
    7673    explicit FloatPoint(const FloatSize& size) : m_x(size.width()), m_y(size.height()) { }
    7774
     
    10097        m_y += a.height();
    10198    }
    102     void move(const LayoutSize&);
    10399    void move(const FloatSize& a)
    104100    {
     
    111107        m_y += a.y();
    112108    }
    113     void moveBy(const LayoutPoint&);
    114109    void moveBy(const FloatPoint& a)
    115110    {
  • trunk/Source/WebCore/platform/graphics/FloatRect.cpp

    r133779 r152175  
    3030#include "FloatConversion.h"
    3131#include "IntRect.h"
    32 #include "LayoutRect.h"
    3332#include <algorithm>
    3433#include <math.h>
     
    4140
    4241FloatRect::FloatRect(const IntRect& r) : m_location(r.location()), m_size(r.size())
    43 {
    44 }
    45 
    46 FloatRect::FloatRect(const LayoutRect& r) : m_location(r.location()), m_size(r.size())
    4742{
    4843}
  • trunk/Source/WebCore/platform/graphics/FloatRect.h

    r150437 r152175  
    6363namespace WebCore {
    6464
    65 class LayoutRect;
    6665class IntRect;
    6766class IntPoint;
     
    8079        : m_location(FloatPoint(x, y)), m_size(FloatSize(width, height)) { }
    8180    FloatRect(const IntRect&);
    82     FloatRect(const LayoutRect&);
    8381
    8482    static FloatRect narrowPrecision(double x, double y, double width, double height);
  • trunk/Source/WebCore/platform/graphics/FloatSize.cpp

    r133779 r152175  
    3030#include "FloatConversion.h"
    3131#include "IntSize.h"
    32 #include "LayoutSize.h"
    3332#include <limits>
    3433#include <math.h>
     
    3938
    4039FloatSize::FloatSize(const IntSize& size) : m_width(size.width()), m_height(size.height())
    41 {
    42 }
    43 
    44 FloatSize::FloatSize(const LayoutSize& size) : m_width(size.width()), m_height(size.height())
    4540{
    4641}
  • trunk/Source/WebCore/platform/graphics/FloatSize.h

    r151642 r152175  
    6161
    6262class IntSize;
    63 class LayoutSize;
    6463
    6564class FloatSize {
     
    6867    FloatSize(float width, float height) : m_width(width), m_height(height) { }
    6968    FloatSize(const IntSize&);
    70     FloatSize(const LayoutSize&);
    7169
    7270    static FloatSize narrowPrecision(double width, double height);
  • trunk/Source/WebCore/platform/graphics/LayoutPoint.h

    r133779 r152175  
    3636#include <wtf/MathExtras.h>
    3737
    38 #if PLATFORM(QT)
    39 #include <qglobal.h>
    40 QT_BEGIN_NAMESPACE
    41 class QPoint;
    42 class QPointF;
    43 QT_END_NAMESPACE
    44 #endif
    45 
    4638namespace WebCore {
    4739
     
    9082        return LayoutPoint(m_y, m_x);
    9183    }
    92 
    93 #if PLATFORM(QT)
    94     explicit LayoutPoint(const QPoint&);
    95     explicit LayoutPoint(const QPointF&);
    96     operator QPointF() const;
    97 #endif
     84   
     85    operator FloatPoint() const { return FloatPoint(m_x, m_y); }
    9886
    9987private:
  • trunk/Source/WebCore/platform/graphics/LayoutRect.cpp

    r133779 r152175  
    3232#include "LayoutRect.h"
    3333
    34 #include "FloatRect.h"
    35 #include "LayoutUnit.h"
    3634#include <algorithm>
    3735
  • trunk/Source/WebCore/platform/graphics/LayoutRect.h

    r143410 r152175  
    3232#define LayoutRect_h
    3333
     34#include "FloatRect.h"
    3435#include "IntRect.h"
    3536#include "LayoutBoxExtent.h"
    3637#include "LayoutPoint.h"
    3738#include <wtf/Vector.h>
    38 
    39 #if PLATFORM(QT)
    40 #include <qglobal.h>
    41 QT_BEGIN_NAMESPACE
    42 class QRect;
    43 class QRectF;
    44 QT_END_NAMESPACE
    45 #endif
    4639
    4740namespace WebCore {
     
    176169        return LayoutRect(LayoutUnit::nearlyMin() / 2, LayoutUnit::nearlyMin() / 2, LayoutUnit::nearlyMax(), LayoutUnit::nearlyMax());
    177170    }
    178 
    179 #if PLATFORM(QT)
    180     explicit LayoutRect(const QRect&);
    181     explicit LayoutRect(const QRectF&);
    182     operator QRectF() const;
    183 #endif
     171   
     172    operator FloatRect() const { return FloatRect(m_location, m_size); }
    184173
    185174private:
  • trunk/Source/WebCore/platform/graphics/LayoutSize.h

    r143410 r152175  
    3535#include "IntSize.h"
    3636#include "LayoutUnit.h"
    37 
    38 #if PLATFORM(QT)
    39 #include <qglobal.h>
    40 QT_BEGIN_NAMESPACE
    41 class QSize;
    42 class QSizeF;
    43 QT_END_NAMESPACE
    44 #endif
    4537
    4638namespace WebCore {
     
    121113    }
    122114
    123 #if PLATFORM(QT)
    124     explicit LayoutSize(const QSize&);
    125     explicit LayoutSize(const QSizeF&);
    126     operator QSizeF() const;
    127 #endif
     115    operator FloatSize() const { return FloatSize(m_width, m_height); }
    128116
    129117private:
Note: See TracChangeset for help on using the changeset viewer.