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

Side by Side Diff: cc/layer_quad.cc

Issue 12471007: Part 8 of cc/ directory shuffles: resources (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months 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 | Annotate | Revision Log
« no previous file with comments | « cc/layer_quad.h ('k') | cc/layer_quad_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2011 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.
4
5 #include "cc/layer_quad.h"
6
7 #include "base/logging.h"
8 #include "ui/gfx/quad_f.h"
9
10 namespace cc {
11
12 LayerQuad::Edge::Edge(gfx::PointF p, gfx::PointF q) {
13 DCHECK(p != q);
14
15 gfx::Vector2dF tangent(p.y() - q.y(), q.x() - p.x());
16 float cross2 = p.x() * q.y() - q.x() * p.y();
17
18 set(tangent.x(), tangent.y(), cross2);
19 scale(1.0f / tangent.Length());
20 }
21
22 LayerQuad::LayerQuad(const gfx::QuadF& quad) {
23 // Create edges.
24 left_ = Edge(quad.p4(), quad.p1());
25 right_ = Edge(quad.p2(), quad.p3());
26 top_ = Edge(quad.p1(), quad.p2());
27 bottom_ = Edge(quad.p3(), quad.p4());
28
29 float sign = quad.IsCounterClockwise() ? -1 : 1;
30 left_.scale(sign);
31 right_.scale(sign);
32 top_.scale(sign);
33 bottom_.scale(sign);
34 }
35
36 LayerQuad::LayerQuad(const Edge& left,
37 const Edge& top,
38 const Edge& right,
39 const Edge& bottom)
40 : left_(left),
41 top_(top),
42 right_(right),
43 bottom_(bottom) {}
44
45 gfx::QuadF LayerQuad::ToQuadF() const {
46 return gfx::QuadF(left_.Intersect(top_),
47 top_.Intersect(right_),
48 right_.Intersect(bottom_),
49 bottom_.Intersect(left_));
50 }
51
52 void LayerQuad::ToFloatArray(float flattened[12]) const {
53 flattened[0] = left_.x();
54 flattened[1] = left_.y();
55 flattened[2] = left_.z();
56 flattened[3] = top_.x();
57 flattened[4] = top_.y();
58 flattened[5] = top_.z();
59 flattened[6] = right_.x();
60 flattened[7] = right_.y();
61 flattened[8] = right_.z();
62 flattened[9] = bottom_.x();
63 flattened[10] = bottom_.y();
64 flattened[11] = bottom_.z();
65 }
66
67 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_quad.h ('k') | cc/layer_quad_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698