OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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 REMOTING_CLIENT_GL_DRAWABLE_H_ | |
6 #define REMOTING_CLIENT_GL_DRAWABLE_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "base/memory/weak_ptr.h" | |
10 | |
11 namespace remoting { | |
12 | |
13 class GlCanvas; | |
14 | |
15 enum DrawableZIndex { | |
joedow
2016/12/22 00:29:02
Z index is fine, but would it make sense to refer
| |
16 AUTO = -1, | |
joedow
2016/12/22 00:29:02
DEFAULT instead of AUTO?
nicholss
2016/12/22 16:21:41
The default is AUTO, which is a css construct.
joedow
2016/12/22 19:18:09
Neither Android nor iOS use CSS so I wouldn't have
nicholss
2017/01/09 18:50:24
I don't really understand the issue leaning on a c
| |
17 DESKTOP = 100, | |
18 CURSOR_FEEDBACK = 200, | |
19 CURSOR = 300, | |
20 }; | |
21 | |
22 class GlDrawable { | |
23 public: | |
24 GlDrawable() {} | |
25 virtual ~GlDrawable(){}; | |
joedow
2016/12/22 00:29:02
space between () and {}
| |
26 | |
27 // Sets the canvas on which the object will be drawn. | |
28 // If |canvas| is nullptr, nothing will happen when calling Draw(). | |
joedow
2016/12/22 00:29:02
What should Draw() return if |canvas| is nullptr?
nicholss
2017/01/09 18:50:24
It would depend on the implementation. Draw return
| |
29 virtual void SetCanvas(GlCanvas* canvas) = 0; | |
30 | |
31 // Draws the object on the canvas. | |
32 // Return true if you have a next frame. | |
33 virtual bool Draw() = 0; | |
34 | |
35 // Used for the renderer to keep a stack of drawables. | |
joedow
2016/12/22 00:29:02
This could be used for other reasons too (i.e. if
| |
36 virtual base::WeakPtr<GlDrawable> GetWeakPtr() = 0; | |
37 | |
38 int GetZIndex() { return z_index_; }; | |
39 | |
40 // Specify the Z Index for this drawable. A higher Z Index will draw after a | |
joedow
2016/12/22 00:29:02
There is a lot of renderer impl details in the com
nicholss
2017/01/09 18:50:24
Normally interfaces are where behaviors and side e
| |
41 // lower z index. Elements with the same Z Index will draw in order inserted. | |
42 void SetZIndex(int z_index) { z_index_ = z_index; }; | |
43 | |
44 private: | |
45 int z_index_ = DrawableZIndex::AUTO; | |
46 | |
47 DISALLOW_COPY_AND_ASSIGN(GlDrawable); | |
48 }; | |
49 | |
50 namespace drawable { | |
51 | |
52 struct { | |
Yuwei
2016/12/21 23:41:59
Why not put the name after `struct`?
nicholss
2017/01/09 18:50:24
old c habits.
| |
53 bool operator()(base::WeakPtr<GlDrawable> a, base::WeakPtr<GlDrawable> b) { | |
joedow
2016/12/22 00:29:02
I don't think this belongs here. I feel like this
joedow
2016/12/22 00:29:02
Can these be const ref instead of passed by value?
| |
54 return a->GetZIndex() < b->GetZIndex(); | |
55 } | |
56 } SortDrawablesZOrder; | |
Yuwei
2016/12/21 23:41:59
Since this is not a sorter, I think it makes more
nicholss
2017/01/09 18:50:24
Good suggestion.
| |
57 | |
58 } // namespace drawable | |
59 | |
60 } // namespace remoting | |
61 | |
62 #endif // REMOTING_CLIENT_GL_DRAWABLE_H_ | |
OLD | NEW |