Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Side by Side Diff: third_party/WebKit/Source/platform/transforms/RotateTransformOperation.cpp

Issue 2478233002: Make 'transform' a presentation attribute on SVG elements (Closed)
Patch Set: Rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) 2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 return RotateTransformOperation::create( 71 return RotateTransformOperation::create(
72 Rotation(axis(), blink::blend(fromRotate.angle(), angle(), progress)), 72 Rotation(axis(), blink::blend(fromRotate.angle(), angle(), progress)),
73 m_type); 73 m_type);
74 } 74 }
75 75
76 bool RotateTransformOperation::canBlendWith( 76 bool RotateTransformOperation::canBlendWith(
77 const TransformOperation& other) const { 77 const TransformOperation& other) const {
78 return other.isSameType(*this); 78 return other.isSameType(*this);
79 } 79 }
80 80
81 RotateAroundOriginTransformOperation::RotateAroundOriginTransformOperation(
82 double angle,
83 double originX,
84 double originY)
85 : RotateTransformOperation(Rotation(FloatPoint3D(0, 0, 1), angle),
86 RotateAroundOrigin),
87 m_originX(originX),
88 m_originY(originY) {}
89
90 void RotateAroundOriginTransformOperation::apply(
91 TransformationMatrix& transform,
92 const FloatSize& boxSize) const {
93 transform.translate(m_originX, m_originY);
94 RotateTransformOperation::apply(transform, boxSize);
95 transform.translate(-m_originX, -m_originY);
96 }
97
98 bool RotateAroundOriginTransformOperation::operator==(
99 const TransformOperation& other) const {
100 if (!isSameType(other))
101 return false;
102 const RotateAroundOriginTransformOperation& otherRotate =
103 toRotateAroundOriginTransformOperation(other);
104 const Rotation& otherRotation = otherRotate.m_rotation;
105 return m_rotation.axis == otherRotation.axis &&
106 m_rotation.angle == otherRotation.angle &&
107 m_originX == otherRotate.m_originX &&
108 m_originY == otherRotate.m_originY;
109 }
110
111 PassRefPtr<TransformOperation> RotateAroundOriginTransformOperation::blend(
112 const TransformOperation* from,
113 double progress,
114 bool blendToIdentity) {
115 if (from && !from->isSameType(*this))
116 return this;
117 if (blendToIdentity) {
118 return RotateAroundOriginTransformOperation::create(
119 angle() * (1 - progress), m_originX, m_originY);
120 }
121 if (!from) {
122 return RotateAroundOriginTransformOperation::create(angle() * progress,
123 m_originX, m_originY);
124 }
125 const RotateAroundOriginTransformOperation& fromRotate =
126 toRotateAroundOriginTransformOperation(*from);
127 return RotateAroundOriginTransformOperation::create(
128 blink::blend(fromRotate.angle(), angle(), progress),
129 blink::blend(fromRotate.m_originX, m_originX, progress),
130 blink::blend(fromRotate.m_originY, m_originY, progress));
131 }
132
133 PassRefPtr<TransformOperation> RotateAroundOriginTransformOperation::zoom(
134 double factor) {
135 return create(angle(), m_originX * factor, m_originY * factor);
136 }
137
81 } // namespace blink 138 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698