sandbox/linux/bpf_dsl: eliminate implicit dependency on C++ compiler behavior
[chromium-blink-merge.git] / content / browser / android / edge_effect_base.cc
blob9f81f16f56d3be6dcede800134791a215afd1179
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/browser/android/edge_effect_base.h"
7 namespace content {
9 // static
10 gfx::Transform EdgeEffectBase::ComputeTransform(Edge edge,
11 const gfx::SizeF& viewport_size,
12 float offset) {
13 // Transforms assume the edge layers are anchored to their *top center point*.
14 switch (edge) {
15 case EDGE_TOP:
16 return gfx::Transform(1, 0, 0, 1, 0, offset);
17 case EDGE_LEFT:
18 return gfx::Transform(0, 1, -1, 0, -viewport_size.height() / 2.f + offset,
19 viewport_size.height() / 2.f);
20 case EDGE_BOTTOM:
21 return gfx::Transform(-1, 0, 0, -1, 0, viewport_size.height() + offset);
22 case EDGE_RIGHT:
23 return gfx::Transform(0, -1, 1, 0, -viewport_size.height() / 2.f +
24 viewport_size.width() + offset,
25 viewport_size.height() / 2.f);
26 default:
27 NOTREACHED() << "Invalid edge: " << edge;
28 return gfx::Transform();
32 // static
33 gfx::SizeF EdgeEffectBase::ComputeOrientedSize(
34 Edge edge,
35 const gfx::SizeF& viewport_size) {
36 switch (edge) {
37 case EDGE_TOP:
38 case EDGE_BOTTOM:
39 return viewport_size;
40 case EDGE_LEFT:
41 case EDGE_RIGHT:
42 return gfx::SizeF(viewport_size.height(), viewport_size.width());
43 default:
44 NOTREACHED() << "Invalid edge: " << edge;
45 return gfx::SizeF();
49 } // namespace content