| OLD | NEW |
| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 namespace cc { | 33 namespace cc { |
| 34 | 34 |
| 35 DrawPolygon::DrawPolygon() { | 35 DrawPolygon::DrawPolygon() { |
| 36 } | 36 } |
| 37 | 37 |
| 38 DrawPolygon::DrawPolygon(const DrawQuad* original, | 38 DrawPolygon::DrawPolygon(const DrawQuad* original, |
| 39 const std::vector<gfx::Point3F>& in_points, | 39 const std::vector<gfx::Point3F>& in_points, |
| 40 const gfx::Vector3dF& normal, | 40 const gfx::Vector3dF& normal, |
| 41 int draw_order_index) | 41 int draw_order_index) |
| 42 : order_index_(draw_order_index), original_ref_(original), is_split_(true) { | 42 : normal_(normal), |
| 43 order_index_(draw_order_index), |
| 44 original_ref_(original), |
| 45 is_split_(true) { |
| 43 for (size_t i = 0; i < in_points.size(); i++) { | 46 for (size_t i = 0; i < in_points.size(); i++) { |
| 44 points_.push_back(in_points[i]); | 47 points_.push_back(in_points[i]); |
| 45 } | 48 } |
| 46 #if DCHECK_IS_ON() | 49 // If life was fair, we could recalculate the normal from the given points |
| 47 normal_ = normal; | 50 // and assert it was roughly the same. This causes unhelpful breaks on |
| 48 ConstructNormal(); | 51 // trivial slices of split polygons. Similarly, when splitting, it is |
| 49 DCHECK_LE((normal_ - normal).Length(), normalized_threshold); | 52 // better to keep the normal that was constructed from the original. |
| 50 #endif | |
| 51 normal_ = normal; | |
| 52 } | 53 } |
| 53 | 54 |
| 54 // This takes the original DrawQuad that this polygon should be based on, | 55 // This takes the original DrawQuad that this polygon should be based on, |
| 55 // a visible content rect to make the 4 corner points from, and a transformation | 56 // a visible content rect to make the 4 corner points from, and a transformation |
| 56 // to move it and its normal into screen space. | 57 // to move it and its normal into screen space. |
| 57 DrawPolygon::DrawPolygon(const DrawQuad* original_ref, | 58 DrawPolygon::DrawPolygon(const DrawQuad* original_ref, |
| 58 const gfx::RectF& visible_layer_rect, | 59 const gfx::RectF& visible_layer_rect, |
| 59 const gfx::Transform& transform, | 60 const gfx::Transform& transform, |
| 60 int draw_order_index) | 61 int draw_order_index) |
| 61 : normal_(0.0f, 0.0f, 1.0f), | 62 : normal_(0.0f, 0.0f, 1.0f), |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 quads->push_back( | 343 quads->push_back( |
| 343 gfx::QuadF(first, | 344 gfx::QuadF(first, |
| 344 gfx::PointF(points_[offset].x(), points_[offset].y()), | 345 gfx::PointF(points_[offset].x(), points_[offset].y()), |
| 345 gfx::PointF(points_[op1].x(), points_[op1].y()), | 346 gfx::PointF(points_[op1].x(), points_[op1].y()), |
| 346 gfx::PointF(points_[op2].x(), points_[op2].y()))); | 347 gfx::PointF(points_[op2].x(), points_[op2].y()))); |
| 347 offset = op2; | 348 offset = op2; |
| 348 } | 349 } |
| 349 } | 350 } |
| 350 | 351 |
| 351 } // namespace cc | 352 } // namespace cc |
| OLD | NEW |