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

Side by Side Diff: cc/quads/draw_polygon.cc

Issue 416273002: BSP Tree perf tests to match LayerSorter perf tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/quads/draw_polygon.h" 5 #include "cc/quads/draw_polygon.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "cc/output/bsp_compare_result.h" 9 #include "cc/output/bsp_compare_result.h"
10 #include "cc/quads/draw_quad.h"
10 11
11 namespace { 12 namespace {
12 // This allows for some imperfection in the normal comparison when checking if 13 // This allows for some imperfection in the normal comparison when checking if
13 // two pieces of geometry are coplanar. 14 // two pieces of geometry are coplanar.
14 static const float coplanar_dot_epsilon = 0.01f; 15 static const float coplanar_dot_epsilon = 0.01f;
15 // This threshold controls how "thick" a plane is. If a point's distance is 16 // This threshold controls how "thick" a plane is. If a point's distance is
16 // <= |compare_threshold|, then it is considered on the plane. Only when this 17 // <= |compare_threshold|, then it is considered on the plane. Only when this
17 // boundary is crossed do we consider doing splitting. 18 // boundary is crossed do we consider doing splitting.
18 static const float compare_threshold = 1.0f; 19 static const float compare_threshold = 1.0f;
19 // |split_threshold| is lower in this case because we want the points created 20 // |split_threshold| is lower in this case because we want the points created
(...skipping 18 matching lines...) Expand all
38 const std::vector<gfx::Point3F>& in_points, 39 const std::vector<gfx::Point3F>& in_points,
39 const gfx::Vector3dF& normal, 40 const gfx::Vector3dF& normal,
40 int draw_order_index) 41 int draw_order_index)
41 : order_index_(draw_order_index), original_ref_(original) { 42 : order_index_(draw_order_index), original_ref_(original) {
42 for (size_t i = 0; i < in_points.size(); i++) { 43 for (size_t i = 0; i < in_points.size(); i++) {
43 points_.push_back(in_points[i]); 44 points_.push_back(in_points[i]);
44 } 45 }
45 normal_ = normal; 46 normal_ = normal;
46 } 47 }
47 48
49 // This takes the original DrawQuad that this polygon should be based on,
50 // a visible content rect to make the 4 corner points from, and a transformation
51 // to move it and its normal into screen space.
52 DrawPolygon::DrawPolygon(DrawQuad* original_ref,
53 const gfx::RectF& visible_content_rect,
54 const gfx::Transform& transform,
55 int draw_order_index)
56 : order_index_(draw_order_index), original_ref_(original_ref) {
57 normal_ = default_normal;
58 gfx::Point3F points[8];
59 int num_vertices_in_clipped_quad;
60 gfx::QuadF send_quad(visible_content_rect);
61
62 // Doing this mapping here is very important, since we can't just transform
63 // the points without clipping and not run into strange geometry issues when
64 // crossing w = 0. At this point, in the constructor, we know that we're
65 // working with a quad, so we can reuse the MathUtil::MapClippedQuad3d
66 // function instead of writing a generic polygon version of it.
67 MathUtil::MapClippedQuad3d(
68 transform, send_quad, points, &num_vertices_in_clipped_quad);
69 for (int i = 0; i < num_vertices_in_clipped_quad; i++) {
70 points_.push_back(points[i]);
71 }
72 ApplyTransformToNormal(transform);
73 }
74
48 DrawPolygon::~DrawPolygon() { 75 DrawPolygon::~DrawPolygon() {
49 } 76 }
50 77
51 scoped_ptr<DrawPolygon> DrawPolygon::CreateCopy() { 78 scoped_ptr<DrawPolygon> DrawPolygon::CreateCopy() {
52 DrawPolygon* new_polygon = new DrawPolygon(); 79 DrawPolygon* new_polygon = new DrawPolygon();
53 new_polygon->order_index_ = order_index_; 80 new_polygon->order_index_ = order_index_;
54 new_polygon->original_ref_ = original_ref_; 81 new_polygon->original_ref_ = original_ref_;
55 new_polygon->points_.reserve(points_.size()); 82 new_polygon->points_.reserve(points_.size());
56 new_polygon->points_ = points_; 83 new_polygon->points_ = points_;
57 new_polygon->normal_.set_x(normal_.x()); 84 new_polygon->normal_.set_x(normal_.x());
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 quads->push_back( 343 quads->push_back(
317 gfx::QuadF(first, 344 gfx::QuadF(first,
318 gfx::PointF(points_[offset].x(), points_[offset].y()), 345 gfx::PointF(points_[offset].x(), points_[offset].y()),
319 gfx::PointF(points_[op1].x(), points_[op1].y()), 346 gfx::PointF(points_[op1].x(), points_[op1].y()),
320 gfx::PointF(points_[op2].x(), points_[op2].y()))); 347 gfx::PointF(points_[op2].x(), points_[op2].y())));
321 offset = op2; 348 offset = op2;
322 } 349 }
323 } 350 }
324 351
325 } // namespace cc 352 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698