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

Side by Side Diff: third_party/WebKit/Source/platform/animation/AnimationTranslationUtil.cpp

Issue 2473013002: Use range-based for in toCompositorTransformOperations (Closed)
Patch Set: Use auto Created 4 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 25 matching lines...) Expand all
36 #include "platform/transforms/TransformationMatrix.h" 36 #include "platform/transforms/TransformationMatrix.h"
37 #include "platform/transforms/TranslateTransformOperation.h" 37 #include "platform/transforms/TranslateTransformOperation.h"
38 38
39 namespace blink { 39 namespace blink {
40 40
41 void toCompositorTransformOperations( 41 void toCompositorTransformOperations(
42 const TransformOperations& transformOperations, 42 const TransformOperations& transformOperations,
43 CompositorTransformOperations* outTransformOperations) { 43 CompositorTransformOperations* outTransformOperations) {
44 // We need to do a deep copy the transformOperations may contain ref pointers 44 // We need to do a deep copy the transformOperations may contain ref pointers
45 // to TransformOperation objects. 45 // to TransformOperation objects.
46 for (size_t j = 0; j < transformOperations.size(); ++j) { 46 for (const auto& operation : transformOperations.operations()) {
47 switch (transformOperations.operations()[j]->type()) { 47 switch (operation->type()) {
48 case TransformOperation::ScaleX: 48 case TransformOperation::ScaleX:
49 case TransformOperation::ScaleY: 49 case TransformOperation::ScaleY:
50 case TransformOperation::ScaleZ: 50 case TransformOperation::ScaleZ:
51 case TransformOperation::Scale3D: 51 case TransformOperation::Scale3D:
52 case TransformOperation::Scale: { 52 case TransformOperation::Scale: {
53 ScaleTransformOperation* transform = 53 auto transform =
54 static_cast<ScaleTransformOperation*>( 54 static_cast<const ScaleTransformOperation*>(operation.get());
55 transformOperations.operations()[j].get());
56 outTransformOperations->appendScale(transform->x(), transform->y(), 55 outTransformOperations->appendScale(transform->x(), transform->y(),
57 transform->z()); 56 transform->z());
58 break; 57 break;
59 } 58 }
60 case TransformOperation::TranslateX: 59 case TransformOperation::TranslateX:
61 case TransformOperation::TranslateY: 60 case TransformOperation::TranslateY:
62 case TransformOperation::TranslateZ: 61 case TransformOperation::TranslateZ:
63 case TransformOperation::Translate3D: 62 case TransformOperation::Translate3D:
64 case TransformOperation::Translate: { 63 case TransformOperation::Translate: {
65 TranslateTransformOperation* transform = 64 auto transform =
66 static_cast<TranslateTransformOperation*>( 65 static_cast<const TranslateTransformOperation*>(operation.get());
67 transformOperations.operations()[j].get()); 66 DCHECK(transform->x().isFixed() && transform->y().isFixed());
68 ASSERT(transform->x().isFixed() && transform->y().isFixed());
69 outTransformOperations->appendTranslate( 67 outTransformOperations->appendTranslate(
70 transform->x().value(), transform->y().value(), transform->z()); 68 transform->x().value(), transform->y().value(), transform->z());
71 break; 69 break;
72 } 70 }
73 case TransformOperation::RotateX: 71 case TransformOperation::RotateX:
74 case TransformOperation::RotateY: 72 case TransformOperation::RotateY:
75 case TransformOperation::Rotate3D: 73 case TransformOperation::Rotate3D:
76 case TransformOperation::Rotate: { 74 case TransformOperation::Rotate: {
77 RotateTransformOperation* transform = 75 auto transform =
78 static_cast<RotateTransformOperation*>( 76 static_cast<const RotateTransformOperation*>(operation.get());
79 transformOperations.operations()[j].get());
80 outTransformOperations->appendRotate( 77 outTransformOperations->appendRotate(
81 transform->x(), transform->y(), transform->z(), transform->angle()); 78 transform->x(), transform->y(), transform->z(), transform->angle());
82 break; 79 break;
83 } 80 }
84 case TransformOperation::SkewX: 81 case TransformOperation::SkewX:
85 case TransformOperation::SkewY: 82 case TransformOperation::SkewY:
86 case TransformOperation::Skew: { 83 case TransformOperation::Skew: {
87 SkewTransformOperation* transform = 84 auto transform =
88 static_cast<SkewTransformOperation*>( 85 static_cast<const SkewTransformOperation*>(operation.get());
89 transformOperations.operations()[j].get());
90 outTransformOperations->appendSkew(transform->angleX(), 86 outTransformOperations->appendSkew(transform->angleX(),
91 transform->angleY()); 87 transform->angleY());
92 break; 88 break;
93 } 89 }
94 case TransformOperation::Matrix: { 90 case TransformOperation::Matrix: {
95 MatrixTransformOperation* transform = 91 auto transform =
96 static_cast<MatrixTransformOperation*>( 92 static_cast<const MatrixTransformOperation*>(operation.get());
97 transformOperations.operations()[j].get());
98 TransformationMatrix m = transform->matrix(); 93 TransformationMatrix m = transform->matrix();
99 outTransformOperations->appendMatrix( 94 outTransformOperations->appendMatrix(
100 TransformationMatrix::toSkMatrix44(m)); 95 TransformationMatrix::toSkMatrix44(m));
101 break; 96 break;
102 } 97 }
103 case TransformOperation::Matrix3D: { 98 case TransformOperation::Matrix3D: {
104 Matrix3DTransformOperation* transform = 99 auto transform =
105 static_cast<Matrix3DTransformOperation*>( 100 static_cast<const Matrix3DTransformOperation*>(operation.get());
106 transformOperations.operations()[j].get());
107 TransformationMatrix m = transform->matrix(); 101 TransformationMatrix m = transform->matrix();
108 outTransformOperations->appendMatrix( 102 outTransformOperations->appendMatrix(
109 TransformationMatrix::toSkMatrix44(m)); 103 TransformationMatrix::toSkMatrix44(m));
110 break; 104 break;
111 } 105 }
112 case TransformOperation::Perspective: { 106 case TransformOperation::Perspective: {
113 PerspectiveTransformOperation* transform = 107 auto transform =
114 static_cast<PerspectiveTransformOperation*>( 108 static_cast<const PerspectiveTransformOperation*>(operation.get());
115 transformOperations.operations()[j].get());
116 outTransformOperations->appendPerspective(transform->perspective()); 109 outTransformOperations->appendPerspective(transform->perspective());
117 break; 110 break;
118 } 111 }
119 case TransformOperation::Interpolated: { 112 case TransformOperation::Interpolated: {
120 TransformationMatrix m; 113 TransformationMatrix m;
121 transformOperations.operations()[j]->apply(m, FloatSize()); 114 operation->apply(m, FloatSize());
122 outTransformOperations->appendMatrix( 115 outTransformOperations->appendMatrix(
123 TransformationMatrix::toSkMatrix44(m)); 116 TransformationMatrix::toSkMatrix44(m));
124 break; 117 break;
125 } 118 }
126 case TransformOperation::Identity: 119 case TransformOperation::Identity:
127 outTransformOperations->appendIdentity(); 120 outTransformOperations->appendIdentity();
128 break; 121 break;
129 case TransformOperation::None: 122 case TransformOperation::None:
130 // Do nothing. 123 // Do nothing.
131 break; 124 break;
132 } // switch 125 } // switch
133 } // for each operation 126 } // for each operation
134 } 127 }
135 128
136 } // namespace blink 129 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698