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

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

Issue 509193002: Allow requesting a copy of a surface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « cc/surfaces/surface.cc ('k') | cc/surfaces/surface_factory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/callback_forward.h" 8 #include "base/callback_forward.h"
9 #include "base/containers/scoped_ptr_hash_map.h" 9 #include "base/containers/scoped_ptr_hash_map.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "cc/surfaces/surface_id.h" 12 #include "cc/surfaces/surface_id.h"
13 #include "cc/surfaces/surface_resource_holder.h" 13 #include "cc/surfaces/surface_resource_holder.h"
14 #include "cc/surfaces/surfaces_export.h" 14 #include "cc/surfaces/surfaces_export.h"
15 15
16 namespace gfx { 16 namespace gfx {
17 class Size; 17 class Size;
18 } 18 }
19 19
20 namespace cc { 20 namespace cc {
21 class CompositorFrame; 21 class CompositorFrame;
22 class CopyOutputRequest;
22 class Surface; 23 class Surface;
23 class SurfaceFactoryClient; 24 class SurfaceFactoryClient;
24 class SurfaceManager; 25 class SurfaceManager;
25 26
26 // A SurfaceFactory is used to create surfaces that may share resources and 27 // A SurfaceFactory is used to create surfaces that may share resources and
27 // receive returned resources for frames submitted to those surfaces. Resources 28 // receive returned resources for frames submitted to those surfaces. Resources
28 // submitted to frames created by a particular factory will be returned to that 29 // submitted to frames created by a particular factory will be returned to that
29 // factory's client when they are no longer being used. This is the only class 30 // factory's client when they are no longer being used. This is the only class
30 // most users of surfaces will need to directly interact with. 31 // most users of surfaces will need to directly interact with.
31 class CC_SURFACES_EXPORT SurfaceFactory 32 class CC_SURFACES_EXPORT SurfaceFactory
32 : public base::SupportsWeakPtr<SurfaceFactory> { 33 : public base::SupportsWeakPtr<SurfaceFactory> {
33 public: 34 public:
34 SurfaceFactory(SurfaceManager* manager, SurfaceFactoryClient* client); 35 SurfaceFactory(SurfaceManager* manager, SurfaceFactoryClient* client);
35 ~SurfaceFactory(); 36 ~SurfaceFactory();
36 37
37 void Create(SurfaceId surface_id, const gfx::Size& size); 38 void Create(SurfaceId surface_id, const gfx::Size& size);
38 void Destroy(SurfaceId surface_id); 39 void Destroy(SurfaceId surface_id);
39 // A frame can only be submitted to a surface created by this factory, 40 // A frame can only be submitted to a surface created by this factory,
40 // although the frame may reference surfaces created by other factories. 41 // although the frame may reference surfaces created by other factories.
41 // The callback is called the first time this frame is used to draw. 42 // The callback is called the first time this frame is used to draw.
42 void SubmitFrame(SurfaceId surface_id, 43 void SubmitFrame(SurfaceId surface_id,
43 scoped_ptr<CompositorFrame> frame, 44 scoped_ptr<CompositorFrame> frame,
44 const base::Closure& callback); 45 const base::Closure& callback);
46 void RequestCopyOfSurface(SurfaceId surface_id,
47 scoped_ptr<CopyOutputRequest> copy_request);
45 48
46 SurfaceFactoryClient* client() { return client_; } 49 SurfaceFactoryClient* client() { return client_; }
47 50
48 void ReceiveFromChild(const TransferableResourceArray& resources); 51 void ReceiveFromChild(const TransferableResourceArray& resources);
49 void RefResources(const TransferableResourceArray& resources); 52 void RefResources(const TransferableResourceArray& resources);
50 void UnrefResources(const ReturnedResourceArray& resources); 53 void UnrefResources(const ReturnedResourceArray& resources);
51 54
52 private: 55 private:
53 SurfaceManager* manager_; 56 SurfaceManager* manager_;
54 SurfaceFactoryClient* client_; 57 SurfaceFactoryClient* client_;
55 typedef base::ScopedPtrHashMap<SurfaceId, Surface> OwningSurfaceMap; 58 typedef base::ScopedPtrHashMap<SurfaceId, Surface> OwningSurfaceMap;
56 base::ScopedPtrHashMap<SurfaceId, Surface> surface_map_; 59 base::ScopedPtrHashMap<SurfaceId, Surface> surface_map_;
57 60
58 SurfaceResourceHolder holder_; 61 SurfaceResourceHolder holder_;
59 62
60 DISALLOW_COPY_AND_ASSIGN(SurfaceFactory); 63 DISALLOW_COPY_AND_ASSIGN(SurfaceFactory);
61 }; 64 };
62 65
63 } // namespace cc 66 } // namespace cc
64 67
65 #endif // CC_SURFACES_SURFACE_FACTORY_H_ 68 #endif // CC_SURFACES_SURFACE_FACTORY_H_
OLDNEW
« no previous file with comments | « cc/surfaces/surface.cc ('k') | cc/surfaces/surface_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698