Chromium Code Reviews| Index: mojo/services/geometry/cpp/geometry_util.cc |
| diff --git a/mojo/services/geometry/cpp/geometry_util.cc b/mojo/services/geometry/cpp/geometry_util.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6aad17503136bd786e9792bba0087ffb2fa06ac5 |
| --- /dev/null |
| +++ b/mojo/services/geometry/cpp/geometry_util.cc |
| @@ -0,0 +1,27 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include <string> |
|
viettrungluu
2015/12/11 00:15:13
You want <string.h> (or <cstring>) for memcpy, not
jeffbrown
2015/12/11 19:40:55
Done.
|
| +#include "mojo/services/geometry/cpp/geometry_util.h" |
| + |
| +namespace mojo { |
| + |
| +static float kIdentityMatrix[]{1.f, 0.f, 0.f, 0.f, // comments to prevent |
|
abarth-chromium
2015/12/10 22:49:53
const ?
jeffbrown
2015/12/11 19:40:55
Done.
|
| + 0.f, 1.f, 0.f, 0.f, // auto formatter reflow |
| + 0.f, 0.f, 1.f, 0.f, // |
| + 0.f, 0.f, 0.f, 1.f}; |
| + |
| +void SetIdentityTransform(Transform* transform) { |
| + transform->matrix.resize(16u); |
| + memcpy(transform->matrix.data(), kIdentityMatrix, sizeof(kIdentityMatrix)); |
| +} |
| + |
| +void SetTranslationTransform(Transform* transform, float x, float y, float z) { |
| + SetIdentityTransform(transform); |
| + transform->matrix[3] = x; |
| + transform->matrix[7] = y; |
| + transform->matrix[11] = z; |
| +} |
| + |
| +} // namespace mojo |