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

Side by Side Diff: cc/resources/layer_quad.cc

Issue 960893004: Revert of Splitting of layers for correct intersections (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « cc/resources/layer_quad.h ('k') | cc/test/data/anti_aliasing.png » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/resources/layer_quad.h" 5 #include "cc/resources/layer_quad.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/gfx/geometry/quad_f.h" 8 #include "ui/gfx/geometry/quad_f.h"
9 9
10 namespace cc { 10 namespace cc {
11 11
12 LayerQuad::Edge::Edge(const gfx::PointF& p, const gfx::PointF& q) { 12 LayerQuad::Edge::Edge(const gfx::PointF& p, const gfx::PointF& q) {
13 if (p == q) { 13 DCHECK(p != q);
14 degenerate_ = true; 14
15 return;
16 }
17 degenerate_ = false;
18 gfx::Vector2dF tangent(p.y() - q.y(), q.x() - p.x()); 15 gfx::Vector2dF tangent(p.y() - q.y(), q.x() - p.x());
19 float cross2 = p.x() * q.y() - q.x() * p.y(); 16 float cross2 = p.x() * q.y() - q.x() * p.y();
20 17
21 set(tangent.x(), tangent.y(), cross2); 18 set(tangent.x(), tangent.y(), cross2);
22 scale(1.0f / tangent.Length()); 19 scale(1.0f / tangent.Length());
23 } 20 }
24 21
25 LayerQuad::LayerQuad(const gfx::QuadF& quad) { 22 LayerQuad::LayerQuad(const gfx::QuadF& quad) {
26 // Create edges. 23 // Create edges.
27 left_ = Edge(quad.p4(), quad.p1()); 24 left_ = Edge(quad.p4(), quad.p1());
(...skipping 11 matching lines...) Expand all
39 LayerQuad::LayerQuad(const Edge& left, 36 LayerQuad::LayerQuad(const Edge& left,
40 const Edge& top, 37 const Edge& top,
41 const Edge& right, 38 const Edge& right,
42 const Edge& bottom) 39 const Edge& bottom)
43 : left_(left), 40 : left_(left),
44 top_(top), 41 top_(top),
45 right_(right), 42 right_(right),
46 bottom_(bottom) {} 43 bottom_(bottom) {}
47 44
48 gfx::QuadF LayerQuad::ToQuadF() const { 45 gfx::QuadF LayerQuad::ToQuadF() const {
49 if (left_.degenerate()) {
50 return gfx::QuadF(top_.Intersect(bottom_), top_.Intersect(right_),
51 right_.Intersect(bottom_), bottom_.Intersect(top_));
52 }
53 if (right_.degenerate()) {
54 return gfx::QuadF(left_.Intersect(top_), top_.Intersect(bottom_),
55 bottom_.Intersect(top_), bottom_.Intersect(left_));
56 }
57 if (top_.degenerate()) {
58 return gfx::QuadF(left_.Intersect(right_), right_.Intersect(left_),
59 right_.Intersect(bottom_), bottom_.Intersect(left_));
60 }
61 if (bottom_.degenerate()) {
62 return gfx::QuadF(left_.Intersect(top_), top_.Intersect(right_),
63 right_.Intersect(left_), left_.Intersect(right_));
64 }
65 return gfx::QuadF(left_.Intersect(top_), 46 return gfx::QuadF(left_.Intersect(top_),
66 top_.Intersect(right_), 47 top_.Intersect(right_),
67 right_.Intersect(bottom_), 48 right_.Intersect(bottom_),
68 bottom_.Intersect(left_)); 49 bottom_.Intersect(left_));
69 } 50 }
70 51
71 void LayerQuad::ToFloatArray(float flattened[12]) const { 52 void LayerQuad::ToFloatArray(float flattened[12]) const {
72 if (left_.degenerate()) { 53 flattened[0] = left_.x();
73 flattened[0] = bottom_.x(); 54 flattened[1] = left_.y();
74 flattened[1] = bottom_.y(); 55 flattened[2] = left_.z();
75 flattened[2] = bottom_.z(); 56 flattened[3] = top_.x();
76 } else { 57 flattened[4] = top_.y();
77 flattened[0] = left_.x(); 58 flattened[5] = top_.z();
78 flattened[1] = left_.y(); 59 flattened[6] = right_.x();
79 flattened[2] = left_.z(); 60 flattened[7] = right_.y();
80 } 61 flattened[8] = right_.z();
81 if (top_.degenerate()) { 62 flattened[9] = bottom_.x();
82 flattened[3] = left_.x(); 63 flattened[10] = bottom_.y();
83 flattened[4] = left_.y(); 64 flattened[11] = bottom_.z();
84 flattened[5] = left_.z();
85 } else {
86 flattened[3] = top_.x();
87 flattened[4] = top_.y();
88 flattened[5] = top_.z();
89 }
90 if (right_.degenerate()) {
91 flattened[6] = top_.x();
92 flattened[7] = top_.y();
93 flattened[8] = top_.z();
94 } else {
95 flattened[6] = right_.x();
96 flattened[7] = right_.y();
97 flattened[8] = right_.z();
98 }
99 if (bottom_.degenerate()) {
100 flattened[9] = right_.x();
101 flattened[10] = right_.y();
102 flattened[11] = right_.z();
103 } else {
104 flattened[9] = bottom_.x();
105 flattened[10] = bottom_.y();
106 flattened[11] = bottom_.z();
107 }
108 } 65 }
109 66
110 } // namespace cc 67 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/layer_quad.h ('k') | cc/test/data/anti_aliasing.png » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698