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

Side by Side Diff: cc/surfaces/surface_factory.h

Issue 1304063014: cc: Plumbing for BeginFrameSource based on Surfaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: SurfaceAggregator tests; fix some bugs revealed by tests Created 5 years, 2 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
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_FACTORY_H_ 5 #ifndef CC_SURFACES_SURFACE_FACTORY_H_
6 #define CC_SURFACES_SURFACE_FACTORY_H_ 6 #define CC_SURFACES_SURFACE_FACTORY_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/callback_forward.h" 10 #include "base/callback_forward.h"
11 #include "base/containers/scoped_ptr_hash_map.h" 11 #include "base/containers/scoped_ptr_hash_map.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "cc/output/compositor_frame.h" 14 #include "cc/output/compositor_frame.h"
15 #include "cc/surfaces/surface_id.h" 15 #include "cc/surfaces/surface_id.h"
16 #include "cc/surfaces/surface_resource_holder.h" 16 #include "cc/surfaces/surface_resource_holder.h"
17 #include "cc/surfaces/surface_sequence.h" 17 #include "cc/surfaces/surface_sequence.h"
18 #include "cc/surfaces/surfaces_export.h" 18 #include "cc/surfaces/surfaces_export.h"
19 19
20 namespace gfx { 20 namespace gfx {
21 class Size; 21 class Size;
22 } 22 }
23 23
24 namespace cc { 24 namespace cc {
25 class BeginFrameSource;
25 class CopyOutputRequest; 26 class CopyOutputRequest;
26 class Surface; 27 class Surface;
27 class SurfaceFactoryClient; 28 class SurfaceFactoryClient;
28 class SurfaceManager; 29 class SurfaceManager;
29 30
30 enum class SurfaceDrawStatus { DRAW_SKIPPED, DRAWN }; 31 enum class SurfaceDrawStatus { DRAW_SKIPPED, DRAWN };
31 32
32 // A SurfaceFactory is used to create surfaces that may share resources and 33 // A SurfaceFactory is used to create surfaces that may share resources and
33 // receive returned resources for frames submitted to those surfaces. Resources 34 // receive returned resources for frames submitted to those surfaces. Resources
34 // submitted to frames created by a particular factory will be returned to that 35 // submitted to frames created by a particular factory will be returned to that
35 // factory's client when they are no longer being used. This is the only class 36 // factory's client when they are no longer being used. This is the only class
36 // most users of surfaces will need to directly interact with. 37 // most users of surfaces will need to directly interact with.
37 class CC_SURFACES_EXPORT SurfaceFactory 38 class CC_SURFACES_EXPORT SurfaceFactory
38 : public base::SupportsWeakPtr<SurfaceFactory> { 39 : public base::SupportsWeakPtr<SurfaceFactory> {
39 public: 40 public:
40 using DrawCallback = base::Callback<void(SurfaceDrawStatus)>; 41 using DrawCallback = base::Callback<void(SurfaceDrawStatus)>;
41 42
42 SurfaceFactory(SurfaceManager* manager, SurfaceFactoryClient* client); 43 SurfaceFactory(SurfaceManager* manager, SurfaceFactoryClient* client);
43 ~SurfaceFactory(); 44 ~SurfaceFactory();
44 45
45 void Create(SurfaceId surface_id); 46 void Create(SurfaceId surface_id);
46 void Destroy(SurfaceId surface_id); 47 void Destroy(SurfaceId surface_id);
47 void DestroyAll(); 48 void DestroyAll();
49
50 void SetBeginFrameSource(SurfaceId surface_id,
51 BeginFrameSource* begin_frame_source);
52
48 // A frame can only be submitted to a surface created by this factory, 53 // A frame can only be submitted to a surface created by this factory,
49 // although the frame may reference surfaces created by other factories. 54 // although the frame may reference surfaces created by other factories.
50 // The callback is called the first time this frame is used to draw, or if 55 // The callback is called the first time this frame is used to draw, or if
51 // the frame is discarded. 56 // the frame is discarded.
52 void SubmitCompositorFrame(SurfaceId surface_id, 57 void SubmitCompositorFrame(SurfaceId surface_id,
53 scoped_ptr<CompositorFrame> frame, 58 scoped_ptr<CompositorFrame> frame,
54 const DrawCallback& callback); 59 const DrawCallback& callback);
55 void RequestCopyOfSurface(SurfaceId surface_id, 60 void RequestCopyOfSurface(SurfaceId surface_id,
56 scoped_ptr<CopyOutputRequest> copy_request); 61 scoped_ptr<CopyOutputRequest> copy_request);
57 62
(...skipping 15 matching lines...) Expand all
73 SurfaceManager* manager_; 78 SurfaceManager* manager_;
74 SurfaceFactoryClient* client_; 79 SurfaceFactoryClient* client_;
75 SurfaceResourceHolder holder_; 80 SurfaceResourceHolder holder_;
76 81
77 bool needs_sync_points_; 82 bool needs_sync_points_;
78 83
79 typedef base::ScopedPtrHashMap<SurfaceId, scoped_ptr<Surface>> 84 typedef base::ScopedPtrHashMap<SurfaceId, scoped_ptr<Surface>>
80 OwningSurfaceMap; 85 OwningSurfaceMap;
81 OwningSurfaceMap surface_map_; 86 OwningSurfaceMap surface_map_;
82 87
88 SurfaceId most_recently_created_surface_id_;
89
83 DISALLOW_COPY_AND_ASSIGN(SurfaceFactory); 90 DISALLOW_COPY_AND_ASSIGN(SurfaceFactory);
84 }; 91 };
85 92
86 } // namespace cc 93 } // namespace cc
87 94
88 #endif // CC_SURFACES_SURFACE_FACTORY_H_ 95 #endif // CC_SURFACES_SURFACE_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698