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 #ifndef CC_SURFACES_SURFACE_H_ | 5 #ifndef CC_SURFACES_SURFACE_H_ |
6 #define CC_SURFACES_SURFACE_H_ | 6 #define CC_SURFACES_SURFACE_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/containers/hash_tables.h" | 9 #include "base/containers/hash_tables.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "cc/surfaces/surface_id.h" | 12 #include "cc/surfaces/surface_id.h" |
13 #include "cc/surfaces/surfaces_export.h" | 13 #include "cc/surfaces/surfaces_export.h" |
14 #include "ui/gfx/size.h" | 14 #include "ui/gfx/size.h" |
15 | 15 |
16 namespace ui { | |
17 struct LatencyInfo; | |
18 } | |
19 | |
20 namespace cc { | 16 namespace cc { |
21 class CompositorFrame; | 17 class CompositorFrame; |
22 class CopyOutputRequest; | 18 class CopyOutputRequest; |
23 class SurfaceManager; | 19 class SurfaceManager; |
24 class SurfaceFactory; | 20 class SurfaceFactory; |
25 class SurfaceResourceHolder; | 21 class SurfaceResourceHolder; |
26 | 22 |
27 class CC_SURFACES_EXPORT Surface { | 23 class CC_SURFACES_EXPORT Surface { |
28 public: | 24 public: |
29 Surface(SurfaceId id, const gfx::Size& size, SurfaceFactory* factory); | 25 Surface(SurfaceId id, const gfx::Size& size, SurfaceFactory* factory); |
30 ~Surface(); | 26 ~Surface(); |
31 | 27 |
32 const gfx::Size& size() const { return size_; } | 28 const gfx::Size& size() const { return size_; } |
33 SurfaceId surface_id() const { return surface_id_; } | 29 SurfaceId surface_id() const { return surface_id_; } |
34 | 30 |
35 void QueueFrame(scoped_ptr<CompositorFrame> frame, | 31 void QueueFrame(scoped_ptr<CompositorFrame> frame, |
36 const base::Closure& draw_callback); | 32 const base::Closure& draw_callback); |
37 void RequestCopyOfOutput(scoped_ptr<CopyOutputRequest> copy_request); | 33 void RequestCopyOfOutput(scoped_ptr<CopyOutputRequest> copy_request); |
38 // Returns the most recent frame that is eligible to be rendered. | 34 // Returns the most recent frame that is eligible to be rendered. |
39 const CompositorFrame* GetEligibleFrame(); | 35 const CompositorFrame* GetEligibleFrame(); |
40 | 36 |
41 // Returns a number that increments by 1 every time a new frame is enqueued. | 37 // Returns a number that increments by 1 every time a new frame is enqueued. |
42 int frame_index() const { return frame_index_; } | 38 int frame_index() const { return frame_index_; } |
43 | 39 |
44 void TakeLatencyInfo(std::vector<ui::LatencyInfo>* latency_info); | |
45 void RunDrawCallbacks(); | 40 void RunDrawCallbacks(); |
46 | 41 |
47 SurfaceFactory* factory() { return factory_; } | 42 SurfaceFactory* factory() { return factory_; } |
48 | 43 |
49 private: | 44 private: |
50 SurfaceId surface_id_; | 45 SurfaceId surface_id_; |
51 gfx::Size size_; | 46 gfx::Size size_; |
52 SurfaceFactory* factory_; | 47 SurfaceFactory* factory_; |
53 // TODO(jamesr): Support multiple frames in flight. | 48 // TODO(jamesr): Support multiple frames in flight. |
54 scoped_ptr<CompositorFrame> current_frame_; | 49 scoped_ptr<CompositorFrame> current_frame_; |
55 int frame_index_; | 50 int frame_index_; |
56 | 51 |
57 base::Closure draw_callback_; | 52 base::Closure draw_callback_; |
58 | 53 |
59 DISALLOW_COPY_AND_ASSIGN(Surface); | 54 DISALLOW_COPY_AND_ASSIGN(Surface); |
60 }; | 55 }; |
61 | 56 |
62 } // namespace cc | 57 } // namespace cc |
63 | 58 |
64 #endif // CC_SURFACES_SURFACE_H_ | 59 #endif // CC_SURFACES_SURFACE_H_ |
OLD | NEW |