Explicitly add python-numpy dependency to install-build-deps.
[chromium-blink-merge.git] / cc / surfaces / surface.h
blob7b3fbc125b29f7850cffe78ea620122dad4c2200
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.
5 #ifndef CC_SURFACES_SURFACE_H_
6 #define CC_SURFACES_SURFACE_H_
8 #include <map>
9 #include <vector>
11 #include "base/callback.h"
12 #include "base/containers/hash_tables.h"
13 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h"
16 #include "cc/base/scoped_ptr_vector.h"
17 #include "cc/output/copy_output_request.h"
18 #include "cc/quads/render_pass_id.h"
19 #include "cc/surfaces/surface_id.h"
20 #include "cc/surfaces/surface_sequence.h"
21 #include "cc/surfaces/surfaces_export.h"
22 #include "ui/gfx/geometry/size.h"
24 namespace ui {
25 struct LatencyInfo;
28 namespace cc {
29 class CompositorFrame;
30 class CopyOutputRequest;
31 class SurfaceManager;
32 class SurfaceFactory;
33 class SurfaceResourceHolder;
35 class CC_SURFACES_EXPORT Surface {
36 public:
37 Surface(SurfaceId id, const gfx::Size& size, SurfaceFactory* factory);
38 ~Surface();
40 const gfx::Size& size() const { return size_; }
41 SurfaceId surface_id() const { return surface_id_; }
43 void QueueFrame(scoped_ptr<CompositorFrame> frame,
44 const base::Closure& draw_callback);
45 void RequestCopyOfOutput(scoped_ptr<CopyOutputRequest> copy_request);
46 // Adds each CopyOutputRequest in the current frame to copy_requests. The
47 // caller takes ownership of them.
48 void TakeCopyOutputRequests(
49 std::multimap<RenderPassId, CopyOutputRequest*>* copy_requests);
50 // Returns the most recent frame that is eligible to be rendered.
51 const CompositorFrame* GetEligibleFrame();
53 // Returns a number that increments by 1 every time a new frame is enqueued.
54 int frame_index() const { return frame_index_; }
56 void TakeLatencyInfo(std::vector<ui::LatencyInfo>* latency_info);
57 void RunDrawCallbacks();
59 base::WeakPtr<SurfaceFactory> factory() { return factory_; }
61 // Add a SurfaceSequence that must be satisfied before the Surface is
62 // destroyed.
63 void AddDestructionDependency(SurfaceSequence sequence);
65 // Satisfy all destruction dependencies that are contained in sequences, and
66 // remove them from sequences.
67 void SatisfyDestructionDependencies(
68 base::hash_set<SurfaceSequence>* sequences);
69 size_t GetDestructionDependencyCount() const {
70 return destruction_dependencies_.size();
73 private:
74 void ClearCopyRequests();
76 SurfaceId surface_id_;
77 gfx::Size size_;
78 base::WeakPtr<SurfaceFactory> factory_;
79 // TODO(jamesr): Support multiple frames in flight.
80 scoped_ptr<CompositorFrame> current_frame_;
81 int frame_index_;
82 std::vector<SurfaceSequence> destruction_dependencies_;
84 base::Closure draw_callback_;
86 DISALLOW_COPY_AND_ASSIGN(Surface);
89 } // namespace cc
91 #endif // CC_SURFACES_SURFACE_H_