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

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

Issue 384083002: WIP BSP Tree for 3D Layer Sorting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed some forgotten debug output Created 6 years, 5 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CC_QUADS_DRAW_POLYGON_H_
6 #define CC_QUADS_DRAW_POLYGON_H_
7
8 #include <vector>
9
10 #include "cc/base/math_util.h"
11 #include "cc/output/bsp_compare_result.h"
12 #include "cc/quads/draw_quad.h"
13 #include "ui/gfx/point3_f.h"
14 #include "ui/gfx/quad_f.h"
15 #include "ui/gfx/vector3d_f.h"
16
17 namespace cc {
18
19 class DrawPolygon {
20 public:
21 DrawPolygon();
22 ~DrawPolygon();
23
24 DrawPolygon(DrawQuad* original_ref,
25 const std::vector<gfx::Point3F>& in_points,
26 int draw_order_index = 0);
27
28 bool Split(const DrawPolygon& splitter,
29 scoped_ptr<DrawPolygon>* front,
30 scoped_ptr<DrawPolygon>* back);
31 float SignedPointDistance(const gfx::Point3F& point) const;
32 void ApplyTransform(const gfx::Transform& transform);
33 // Checks polygon a against polygon b and returns which side it lies on, or
34 // whether it crosses (necessitating a split in the BSP tree).
35 static BspCompareResult SideCompare(const DrawPolygon& a,
36 const DrawPolygon& b);
37 void ToQuads2D(std::vector<gfx::QuadF>* quads) const;
38 bool GetInverseTransform(gfx::Transform* transform) const;
39 void SetNormal(const gfx::Vector3dF& normal);
40
41 const std::vector<gfx::Point3F>& points() const { return points_; }
42 const gfx::Vector3dF& normal() const { return normal_; }
43 const DrawQuad* original_ref() const { return original_ref_; }
44 const int order_index() const { return order_index_; }
45
46 scoped_ptr<DrawPolygon> CreateCopy();
47
48 private:
49 std::vector<gfx::Point3F> points_;
50 // Normalized, necessitated by distance calculations and tests of coplanarity.
51 gfx::Vector3dF normal_;
52 // This is an index that can be used to test whether a quad comes before or
53 // after another in document order, useful for tie-breaking when it comes
54 // to coplanar surfaces.
55 int order_index_;
56 // The pointer to the original quad, which gives us all the drawing info
57 // we need.
58 // This DrawQuad is owned by the caller and its lifetime must be preserved
59 // as long as this DrawPolygon is alive.
60 DrawQuad* original_ref_;
61 };
62
63 } // namespace cc
64
65 #endif // CC_QUADS_DRAW_POLYGON_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698