Changeset 222603 in webkit


Ignore:
Timestamp:
Sep 27, 2017 11:16:52 PM (7 years ago)
Author:
zandobersek@gmail.com
Message:

[Cairo] Drop cairo_matrix_t conversion operators for AffineTransform, TransformationMatrix
https://bugs.webkit.org/show_bug.cgi?id=177539

Reviewed by Carlos Garcia Campos.

Remove the cairo_matrix_t conversion operators from the AffineTransform
and TransformationMatrix classes. These are rarely used, but enforce
including the cairo.h header in both headers, which leads to the Cairo
headers being included in around 800 build targets.

Instead, the toCairoMatrix() function is added to CairoUtilities.h that
creates a cairo_matrix_t object for the given AffineTransform. No
toCairoMatrix() is needed for TransformationMatrix since objects of
that type aren't converted to cairo_matrix_t anywhere in the codebase.

This patch excludes unnecessary Cairo headers from about 550 build
targets (with those headers being included in the other affected 250
targets by some other header inclusion chain). CairoUtilities.h header
is now included where necessary to make toCairoMatrix() available, and
duplicated cairo.h inclusions are removed.

No new tests -- no change in behavior.

  • editing/gtk/EditorGtk.cpp: Explicitly include <cairo.h> since it's

necessary for Cairo operations used there.

  • platform/Cairo.cmake:
  • platform/graphics/cairo/CairoUtilities.cpp:

(WebCore::drawPatternToCairoContext):
(WebCore::toCairoMatrix):

  • platform/graphics/cairo/CairoUtilities.h:
  • platform/graphics/cairo/GradientCairo.cpp:

(WebCore::Gradient::platformGradient):
(WebCore::Gradient::setPlatformGradientSpaceTransform):

  • platform/graphics/cairo/GraphicsContextCairo.cpp:

(WebCore::GraphicsContext::concatCTM):
(WebCore::GraphicsContext::setCTM):

  • platform/graphics/cairo/PathCairo.cpp: No need to include AffineTransform.h.

(WebCore::Path::addPath):
(WebCore::Path::transform):

  • platform/graphics/cairo/PatternCairo.cpp: Ditto.

(WebCore::Pattern::createPlatformPattern const):

  • platform/graphics/cairo/TransformationMatrixCairo.cpp: Removed.
  • platform/graphics/transforms/AffineTransform.h:
  • platform/graphics/transforms/TransformationMatrix.h:
Location:
trunk/Source/WebCore
Files:
1 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r222602 r222603  
     12017-09-27  Zan Dobersek  <zdobersek@igalia.com>
     2
     3        [Cairo] Drop cairo_matrix_t conversion operators for AffineTransform, TransformationMatrix
     4        https://bugs.webkit.org/show_bug.cgi?id=177539
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        Remove the cairo_matrix_t conversion operators from the AffineTransform
     9        and TransformationMatrix classes. These are rarely used, but enforce
     10        including the cairo.h header in both headers, which leads to the Cairo
     11        headers being included in around 800 build targets.
     12
     13        Instead, the toCairoMatrix() function is added to CairoUtilities.h that
     14        creates a cairo_matrix_t object for the given AffineTransform. No
     15        toCairoMatrix() is needed for TransformationMatrix since objects of
     16        that type aren't converted to cairo_matrix_t anywhere in the codebase.
     17
     18        This patch excludes unnecessary Cairo headers from about 550 build
     19        targets (with those headers being included in the other affected 250
     20        targets by some other header inclusion chain). CairoUtilities.h header
     21        is now included where necessary to make toCairoMatrix() available, and
     22        duplicated cairo.h inclusions are removed.
     23
     24        No new tests -- no change in behavior.
     25
     26        * editing/gtk/EditorGtk.cpp: Explicitly include <cairo.h> since it's
     27        necessary for Cairo operations used there.
     28        * platform/Cairo.cmake:
     29        * platform/graphics/cairo/CairoUtilities.cpp:
     30        (WebCore::drawPatternToCairoContext):
     31        (WebCore::toCairoMatrix):
     32        * platform/graphics/cairo/CairoUtilities.h:
     33        * platform/graphics/cairo/GradientCairo.cpp:
     34        (WebCore::Gradient::platformGradient):
     35        (WebCore::Gradient::setPlatformGradientSpaceTransform):
     36        * platform/graphics/cairo/GraphicsContextCairo.cpp:
     37        (WebCore::GraphicsContext::concatCTM):
     38        (WebCore::GraphicsContext::setCTM):
     39        * platform/graphics/cairo/PathCairo.cpp: No need to include AffineTransform.h.
     40        (WebCore::Path::addPath):
     41        (WebCore::Path::transform):
     42        * platform/graphics/cairo/PatternCairo.cpp: Ditto.
     43        (WebCore::Pattern::createPlatformPattern const):
     44        * platform/graphics/cairo/TransformationMatrixCairo.cpp: Removed.
     45        * platform/graphics/transforms/AffineTransform.h:
     46        * platform/graphics/transforms/TransformationMatrix.h:
     47
    1482017-09-27  Alex Christensen  <achristensen@webkit.org>
    249
  • trunk/Source/WebCore/editing/gtk/EditorGtk.cpp

    r221960 r222603  
    4646#include "XLinkNames.h"
    4747#include "markup.h"
     48#include <cairo.h>
    4849
    4950namespace WebCore {
  • trunk/Source/WebCore/platform/Cairo.cmake

    r217404 r222603  
    2121    platform/graphics/cairo/PlatformPathCairo.cpp
    2222    platform/graphics/cairo/RefPtrCairo.cpp
    23     platform/graphics/cairo/TransformationMatrixCairo.cpp
    2423)
    2524
  • trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp

    r219819 r222603  
    255255    // than sampling it at (x mod w, y mod h), so we transform the translation component of the pattern matrix in that way.
    256256
    257     cairo_matrix_t patternMatrix = cairo_matrix_t(patternTransform);
     257    cairo_matrix_t patternMatrix = toCairoMatrix(patternTransform);
    258258    // dx and dy are added here as well to compensate the previous translation of the destination rectangle.
    259259    double phaseOffsetX = phase.x() + tileRect.x() * patternTransform.a() + dx;
     
    386386}
    387387
     388cairo_matrix_t toCairoMatrix(const AffineTransform& transform)
     389{
     390    return cairo_matrix_t { transform.a(), transform.b(), transform.c(), transform.d(), transform.e(), transform.f() };
     391}
     392
    388393} // namespace WebCore
    389394
  • trunk/Source/WebCore/platform/graphics/cairo/CairoUtilities.h

    r214283 r222603  
    9696RefPtr<cairo_region_t> toCairoRegion(const Region&);
    9797
     98cairo_matrix_t toCairoMatrix(const AffineTransform&);
     99
    98100} // namespace WebCore
    99101
  • trunk/Source/WebCore/platform/graphics/cairo/GradientCairo.cpp

    r216121 r222603  
    3030#if USE(CAIRO)
    3131
     32#include "CairoUtilities.h"
    3233#include "GraphicsContext.h"
    3334#include "PlatformContextCairo.h"
    34 #include <cairo.h>
    3535
    3636namespace WebCore {
     
    8585    }
    8686
    87     cairo_matrix_t matrix = m_gradientSpaceTransformation;
     87    cairo_matrix_t matrix = toCairoMatrix(m_gradientSpaceTransformation);
    8888    cairo_matrix_invert(&matrix);
    8989    cairo_pattern_set_matrix(m_gradient, &matrix);
     
    9595{
    9696    if (m_gradient) {
    97         cairo_matrix_t matrix = gradientSpaceTransformation;
     97        cairo_matrix_t matrix = toCairoMatrix(gradientSpaceTransformation);
    9898        cairo_matrix_invert(&matrix);
    9999        cairo_pattern_set_matrix(m_gradient, &matrix);
  • trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp

    r214100 r222603  
    823823
    824824    cairo_t* cr = platformContext()->cr();
    825     const cairo_matrix_t matrix = cairo_matrix_t(transform);
     825    const cairo_matrix_t matrix = toCairoMatrix(transform);
    826826    cairo_transform(cr, &matrix);
    827827    m_data->concatCTM(transform);
     
    839839
    840840    cairo_t* cr = platformContext()->cr();
    841     const cairo_matrix_t matrix = cairo_matrix_t(transform);
     841    const cairo_matrix_t matrix = toCairoMatrix(transform);
    842842    cairo_set_matrix(cr, &matrix);
    843843    m_data->setCTM(transform);
  • trunk/Source/WebCore/platform/graphics/cairo/PathCairo.cpp

    r187621 r222603  
    2929#if USE(CAIRO)
    3030
    31 #include "AffineTransform.h"
     31#include "CairoUtilities.h"
    3232#include "FloatRect.h"
    3333#include "GraphicsContext.h"
    3434#include "PlatformPathCairo.h"
    3535#include "StrokeStyleApplier.h"
    36 #include <cairo.h>
    3736#include <math.h>
    3837#include <wtf/MathExtras.h>
     
    318317        return;
    319318
    320     cairo_matrix_t matrix(transform);
     319    cairo_matrix_t matrix = toCairoMatrix(transform);
    321320    if (cairo_matrix_invert(&matrix) != CAIRO_STATUS_SUCCESS)
    322321        return;
     
    432431}
    433432
    434 void Path::transform(const AffineTransform& trans)
    435 {
    436     cairo_t* cr = ensurePlatformPath()->context();
    437     cairo_matrix_t c_matrix = cairo_matrix_t(trans);
    438     cairo_matrix_invert(&c_matrix);
    439     cairo_transform(cr, &c_matrix);
     433void Path::transform(const AffineTransform& transform)
     434{
     435    cairo_t* cr = ensurePlatformPath()->context();
     436    cairo_matrix_t matrix = toCairoMatrix(transform);
     437    cairo_matrix_invert(&matrix);
     438    cairo_transform(cr, &matrix);
    440439}
    441440
  • trunk/Source/WebCore/platform/graphics/cairo/PatternCairo.cpp

    r216702 r222603  
    2929#if USE(CAIRO)
    3030
    31 #include "AffineTransform.h"
     31#include "CairoUtilities.h"
    3232#include "GraphicsContext.h"
    33 #include <cairo.h>
    3433
    3534namespace WebCore {
     
    4443
    4544    // cairo merges patter space and user space itself
    46     cairo_matrix_t matrix = m_patternSpaceTransformation;
     45    cairo_matrix_t matrix = toCairoMatrix(m_patternSpaceTransformation);
    4746    cairo_matrix_invert(&matrix);
    4847    cairo_pattern_set_matrix(pattern, &matrix);
  • trunk/Source/WebCore/platform/graphics/transforms/AffineTransform.h

    r222253 r222603  
    3535#if USE(CG)
    3636typedef struct CGAffineTransform CGAffineTransform;
    37 #elif USE(CAIRO)
    38 #include <cairo.h>
    3937#endif
    4038
     
    182180#if USE(CG)
    183181    WEBCORE_EXPORT operator CGAffineTransform() const;
    184 #elif USE(CAIRO)
    185     operator cairo_matrix_t() const;
    186182#endif
    187183
  • trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h

    r220503 r222603  
    3838#if USE(CG)
    3939typedef struct CGAffineTransform CGAffineTransform;
    40 #elif USE(CAIRO)
    41 #include <cairo.h>
    4240#endif
    4341
     
    361359    WEBCORE_EXPORT TransformationMatrix(const CGAffineTransform&);
    362360    WEBCORE_EXPORT operator CGAffineTransform() const;
    363 #elif USE(CAIRO)
    364     operator cairo_matrix_t() const;
    365361#endif
    366362
Note: See TracChangeset for help on using the changeset viewer.