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

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/layers/layer_impl.h"
9 #include "cc/output/bsp_compare_result.h" 10 #include "cc/output/bsp_compare_result.h"
11 #include "cc/quads/draw_quad.h"
10 12
11 namespace { 13 namespace {
12 // This allows for some imperfection in the normal comparison when checking if 14 // This allows for some imperfection in the normal comparison when checking if
13 // two pieces of geometry are coplanar. 15 // two pieces of geometry are coplanar.
14 static const float coplanar_dot_epsilon = 0.01f; 16 static const float coplanar_dot_epsilon = 0.01f;
15 // This threshold controls how "thick" a plane is. If a point's distance is 17 // 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 18 // <= |compare_threshold|, then it is considered on the plane. Only when this
17 // boundary is crossed do we consider doing splitting. 19 // boundary is crossed do we consider doing splitting.
18 static const float compare_threshold = 1.0f; 20 static const float compare_threshold = 1.0f;
19 // |split_threshold| is lower in this case because we want the points created 21 // |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, 40 const std::vector<gfx::Point3F>& in_points,
39 const gfx::Vector3dF& normal, 41 const gfx::Vector3dF& normal,
40 int draw_order_index) 42 int draw_order_index)
41 : order_index_(draw_order_index), original_ref_(original) { 43 : order_index_(draw_order_index), original_ref_(original) {
42 for (size_t i = 0; i < in_points.size(); i++) { 44 for (size_t i = 0; i < in_points.size(); i++) {
43 points_.push_back(in_points[i]); 45 points_.push_back(in_points[i]);
44 } 46 }
45 normal_ = normal; 47 normal_ = normal;
46 } 48 }
47 49
50 // This takes the original DrawQuad that this polygon should be based on,
51 // a visible content rect to make the 4 corner points from, and a transformation
52 // to move it and its normal into screen space.
53 DrawPolygon::DrawPolygon(DrawQuad* original_ref,
54 const gfx::RectF& visible_content_rect,
55 const gfx::Transform& transform,
56 int draw_order_index)
57 : order_index_(draw_order_index), original_ref_(original_ref) {
enne (OOO) 2014/07/30 18:43:56 I think you need to set the normal to a default va
troyhildebrandt 2014/07/30 23:36:57 Done.
58 gfx::Point3F points[8];
59 int num_vertices_in_clipped_quad;
60 gfx::QuadF send_quad(visible_content_rect);
61 MathUtil::MapClippedQuad3d(
enne (OOO) 2014/07/30 18:43:56 Can you just make "gfx::QuadF quad(visible_content
troyhildebrandt 2014/07/30 23:36:57 I put a comment on it.
62 transform, send_quad, points, &num_vertices_in_clipped_quad);
63 for (int i = 0; i < num_vertices_in_clipped_quad; i++) {
64 points_.push_back(points[i]);
65 }
66 ApplyTransformToNormal(transform);
67 }
68
48 DrawPolygon::~DrawPolygon() { 69 DrawPolygon::~DrawPolygon() {
49 } 70 }
50 71
51 scoped_ptr<DrawPolygon> DrawPolygon::CreateCopy() { 72 scoped_ptr<DrawPolygon> DrawPolygon::CreateCopy() {
52 DrawPolygon* new_polygon = new DrawPolygon(); 73 DrawPolygon* new_polygon = new DrawPolygon();
53 new_polygon->order_index_ = order_index_; 74 new_polygon->order_index_ = order_index_;
54 new_polygon->original_ref_ = original_ref_; 75 new_polygon->original_ref_ = original_ref_;
55 new_polygon->points_.reserve(points_.size()); 76 new_polygon->points_.reserve(points_.size());
56 new_polygon->points_ = points_; 77 new_polygon->points_ = points_;
57 new_polygon->normal_.set_x(normal_.x()); 78 new_polygon->normal_.set_x(normal_.x());
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 quads->push_back( 337 quads->push_back(
317 gfx::QuadF(first, 338 gfx::QuadF(first,
318 gfx::PointF(points_[offset].x(), points_[offset].y()), 339 gfx::PointF(points_[offset].x(), points_[offset].y()),
319 gfx::PointF(points_[op1].x(), points_[op1].y()), 340 gfx::PointF(points_[op1].x(), points_[op1].y()),
320 gfx::PointF(points_[op2].x(), points_[op2].y()))); 341 gfx::PointF(points_[op2].x(), points_[op2].y())));
321 offset = op2; 342 offset = op2;
322 } 343 }
323 } 344 }
324 345
325 } // namespace cc 346 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698