Skip to content

Commit b647671

Browse files
committed
Add IPC encoding and decoding support for TransformOperations and TransformOperation
https://bugs.webkit.org/show_bug.cgi?id=248818 Reviewed by Alex Christensen. * Source/WebCore/Headers.cmake: * Source/WebCore/Sources.txt: * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * Source/WebCore/platform/graphics/transforms/IdentityTransformOperation.cpp: Added. (WebCore::IdentityTransformOperation::create): (WebCore::IdentityTransformOperation::IdentityTransformOperation): * Source/WebCore/platform/graphics/transforms/IdentityTransformOperation.h: * Source/WebCore/platform/graphics/transforms/Matrix3DTransformOperation.cpp: (WebCore::Matrix3DTransformOperation::create): (WebCore::Matrix3DTransformOperation::Matrix3DTransformOperation): * Source/WebCore/platform/graphics/transforms/Matrix3DTransformOperation.h: * Source/WebCore/platform/graphics/transforms/MatrixTransformOperation.cpp: (WebCore::MatrixTransformOperation::create): (WebCore::MatrixTransformOperation::MatrixTransformOperation): * Source/WebCore/platform/graphics/transforms/MatrixTransformOperation.h: * Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.cpp: (WebCore::PerspectiveTransformOperation::create): (WebCore::PerspectiveTransformOperation::PerspectiveTransformOperation): * Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.h: * Source/WebCore/platform/graphics/transforms/RotateTransformOperation.cpp: (WebCore::RotateTransformOperation::create): (WebCore::RotateTransformOperation::RotateTransformOperation): * Source/WebCore/platform/graphics/transforms/RotateTransformOperation.h: * Source/WebCore/platform/graphics/transforms/ScaleTransformOperation.cpp: (WebCore::ScaleTransformOperation::create): (WebCore::ScaleTransformOperation::ScaleTransformOperation): * Source/WebCore/platform/graphics/transforms/ScaleTransformOperation.h: * Source/WebCore/platform/graphics/transforms/SkewTransformOperation.cpp: (WebCore::SkewTransformOperation::create): (WebCore::SkewTransformOperation::SkewTransformOperation): * Source/WebCore/platform/graphics/transforms/SkewTransformOperation.h: * Source/WebCore/platform/graphics/transforms/TransformOperation.h: * Source/WebCore/platform/graphics/transforms/TransformOperations.cpp: (WebCore::TransformOperations::TransformOperations): * Source/WebCore/platform/graphics/transforms/TransformOperations.h: * Source/WebCore/platform/graphics/transforms/TranslateTransformOperation.cpp: (WebCore::TranslateTransformOperation::create): (WebCore::TranslateTransformOperation::TranslateTransformOperation): * Source/WebCore/platform/graphics/transforms/TranslateTransformOperation.h: * Source/WebKit/Shared/WebCoreArgumentCoders.cpp: (IPC::ArgumentCoder<WebCore::TransformOperation>::encode): (IPC::ArgumentCoder<WebCore::TransformOperation>::decode): * Source/WebKit/Shared/WebCoreArgumentCoders.h: * Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in: Canonical link: https://commits.webkit.org/257545@main
1 parent 46a9497 commit b647671

25 files changed

+404
-93
lines changed

Source/WebCore/Headers.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,8 +1793,13 @@ set(WebCore_PRIVATE_FRAMEWORK_HEADERS
17931793
platform/graphics/opentype/OpenTypeVerticalData.h
17941794

17951795
platform/graphics/transforms/AffineTransform.h
1796+
platform/graphics/transforms/IdentityTransformOperation.h
1797+
platform/graphics/transforms/Matrix3DTransformOperation.h
1798+
platform/graphics/transforms/MatrixTransformOperation.h
1799+
platform/graphics/transforms/PerspectiveTransformOperation.h
17961800
platform/graphics/transforms/RotateTransformOperation.h
17971801
platform/graphics/transforms/ScaleTransformOperation.h
1802+
platform/graphics/transforms/SkewTransformOperation.h
17981803
platform/graphics/transforms/TransformOperation.h
17991804
platform/graphics/transforms/TransformOperations.h
18001805
platform/graphics/transforms/TransformState.h

Source/WebCore/Sources.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2264,6 +2264,7 @@ platform/graphics/iso/ISOTrackEncryptionBox.cpp
22642264
platform/graphics/iso/ISOVTTCue.cpp
22652265
platform/graphics/opentype/OpenTypeMathData.cpp
22662266
platform/graphics/transforms/AffineTransform.cpp
2267+
platform/graphics/transforms/IdentityTransformOperation.cpp
22672268
platform/graphics/transforms/Matrix3DTransformOperation.cpp
22682269
platform/graphics/transforms/MatrixTransformOperation.cpp
22692270
platform/graphics/transforms/PerspectiveTransformOperation.cpp

Source/WebCore/WebCore.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11717,6 +11717,7 @@
1171711717
7199B94F2552103E00494A57 /* StyleSelfAlignmentData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleSelfAlignmentData.cpp; sourceTree = "<group>"; };
1171811718
7199F81E26FE15C000C627C2 /* close-button.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = "close-button.js"; sourceTree = "<group>"; };
1171911719
7199F82226FE161F00C627C2 /* close-support.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = "close-support.js"; sourceTree = "<group>"; };
11720+
71A0B25C29412DE500D69A79 /* IdentityTransformOperation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IdentityTransformOperation.cpp; sourceTree = "<group>"; };
1172011721
71A1B6071DEE5A820073BCFB /* en */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; name = en; path = "en.lproj/modern-media-controls-localized-strings.js"; sourceTree = SOURCE_ROOT; };
1172111722
71A3D17D2562B8240064E2A6 /* HTMLModelElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLModelElement.h; sourceTree = "<group>"; };
1172211723
71A3D17F2562B8240064E2A6 /* HTMLModelElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTMLModelElement.idl; sourceTree = "<group>"; };
@@ -22783,6 +22784,7 @@
2278322784
children = (
2278422785
84D0C4031115F1D40018AA34 /* AffineTransform.cpp */,
2278522786
84D0C4051115F1EA0018AA34 /* AffineTransform.h */,
22787+
71A0B25C29412DE500D69A79 /* IdentityTransformOperation.cpp */,
2278622788
49E911B50EF86D47009D0CAF /* IdentityTransformOperation.h */,
2278722789
49D5DC270F423A73008F20FD /* Matrix3DTransformOperation.cpp */,
2278822790
49D5DC280F423A73008F20FD /* Matrix3DTransformOperation.h */,
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (C) 2022 Apple Inc. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
* 1. Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* 2. Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
*
13+
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21+
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24+
*/
25+
26+
#include "config.h"
27+
#include "IdentityTransformOperation.h"
28+
29+
namespace WebCore {
30+
31+
Ref<IdentityTransformOperation> IdentityTransformOperation::create()
32+
{
33+
return adoptRef(*new IdentityTransformOperation());
34+
}
35+
36+
IdentityTransformOperation::IdentityTransformOperation()
37+
: TransformOperation(TransformOperation::Type::Identity)
38+
{
39+
}
40+
41+
} // namespace WebCore

Source/WebCore/platform/graphics/transforms/IdentityTransformOperation.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ struct BlendingContext;
3333

3434
class IdentityTransformOperation final : public TransformOperation {
3535
public:
36-
static Ref<IdentityTransformOperation> create()
37-
{
38-
return adoptRef(*new IdentityTransformOperation());
39-
}
36+
WEBCORE_EXPORT static Ref<IdentityTransformOperation> create();
4037

4138
Ref<TransformOperation> clone() const override
4239
{
@@ -63,10 +60,7 @@ class IdentityTransformOperation final : public TransformOperation {
6360

6461
void dump(WTF::TextStream&) const final;
6562

66-
IdentityTransformOperation()
67-
: TransformOperation(TransformOperation::Type::Identity)
68-
{
69-
}
63+
IdentityTransformOperation();
7064
};
7165

7266
} // namespace WebCore

Source/WebCore/platform/graphics/transforms/Matrix3DTransformOperation.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@
3232

3333
namespace WebCore {
3434

35+
Ref<Matrix3DTransformOperation> Matrix3DTransformOperation::create(const TransformationMatrix& matrix)
36+
{
37+
return adoptRef(*new Matrix3DTransformOperation(matrix));
38+
}
39+
40+
Matrix3DTransformOperation::Matrix3DTransformOperation(const TransformationMatrix& mat)
41+
: TransformOperation(TransformOperation::Type::Matrix3D)
42+
, m_matrix(mat)
43+
{
44+
}
45+
3546
bool Matrix3DTransformOperation::operator==(const TransformOperation& other) const
3647
{
3748
return isSameType(other) && m_matrix == downcast<Matrix3DTransformOperation>(other).m_matrix;

Source/WebCore/platform/graphics/transforms/Matrix3DTransformOperation.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ struct BlendingContext;
3434

3535
class Matrix3DTransformOperation final : public TransformOperation {
3636
public:
37-
static Ref<Matrix3DTransformOperation> create(const TransformationMatrix& matrix)
38-
{
39-
return adoptRef(*new Matrix3DTransformOperation(matrix));
40-
}
37+
WEBCORE_EXPORT static Ref<Matrix3DTransformOperation> create(const TransformationMatrix&);
4138

4239
Ref<TransformOperation> clone() const override
4340
{
@@ -65,11 +62,7 @@ class Matrix3DTransformOperation final : public TransformOperation {
6562

6663
void dump(WTF::TextStream&) const final;
6764

68-
Matrix3DTransformOperation(const TransformationMatrix& mat)
69-
: TransformOperation(TransformOperation::Type::Matrix3D)
70-
, m_matrix(mat)
71-
{
72-
}
65+
Matrix3DTransformOperation(const TransformationMatrix&);
7366

7467
TransformationMatrix m_matrix;
7568
};

Source/WebCore/platform/graphics/transforms/MatrixTransformOperation.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,22 @@
2828

2929
namespace WebCore {
3030

31+
Ref<MatrixTransformOperation> MatrixTransformOperation::create(const TransformationMatrix& t)
32+
{
33+
return adoptRef(*new MatrixTransformOperation(t));
34+
}
35+
36+
MatrixTransformOperation::MatrixTransformOperation(const TransformationMatrix& t)
37+
: TransformOperation(TransformOperation::Type::Matrix)
38+
, m_a(t.a())
39+
, m_b(t.b())
40+
, m_c(t.c())
41+
, m_d(t.d())
42+
, m_e(t.e())
43+
, m_f(t.f())
44+
{
45+
}
46+
3147
bool MatrixTransformOperation::operator==(const TransformOperation& other) const
3248
{
3349
if (!isSameType(other))

Source/WebCore/platform/graphics/transforms/MatrixTransformOperation.h

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ class MatrixTransformOperation final : public TransformOperation {
3939
return adoptRef(*new MatrixTransformOperation(a, b, c, d, e, f));
4040
}
4141

42-
static Ref<MatrixTransformOperation> create(const TransformationMatrix& t)
43-
{
44-
return adoptRef(*new MatrixTransformOperation(t));
45-
}
42+
WEBCORE_EXPORT static Ref<MatrixTransformOperation> create(const TransformationMatrix&);
4643

4744
Ref<TransformOperation> clone() const override
4845
{
@@ -80,17 +77,8 @@ class MatrixTransformOperation final : public TransformOperation {
8077
{
8178
}
8279

83-
MatrixTransformOperation(const TransformationMatrix& t)
84-
: TransformOperation(TransformOperation::Type::Matrix)
85-
, m_a(t.a())
86-
, m_b(t.b())
87-
, m_c(t.c())
88-
, m_d(t.d())
89-
, m_e(t.e())
90-
, m_f(t.f())
91-
{
92-
}
93-
80+
MatrixTransformOperation(const TransformationMatrix&);
81+
9482
double m_a;
9583
double m_b;
9684
double m_c;

Source/WebCore/platform/graphics/transforms/PerspectiveTransformOperation.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@
3232

3333
namespace WebCore {
3434

35+
Ref<PerspectiveTransformOperation> PerspectiveTransformOperation::create(const std::optional<Length>& p)
36+
{
37+
return adoptRef(*new PerspectiveTransformOperation(p));
38+
}
39+
40+
PerspectiveTransformOperation::PerspectiveTransformOperation(const std::optional<Length>& p)
41+
: TransformOperation(TransformOperation::Type::Perspective)
42+
, m_p(p)
43+
{
44+
ASSERT(!p || (*p).isFixed());
45+
}
46+
3547
bool PerspectiveTransformOperation::operator==(const TransformOperation& other) const
3648
{
3749
if (!isSameType(other))

0 commit comments

Comments
 (0)