Disable WebContentsObserverAndroidTest#testDidFirstVisuallyNonEmptyPaint
[chromium-blink-merge.git] / cc / surfaces / surface_factory.h
blob0a2ece7aeed11047d2c8ec1bd42c599322e3811d
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_FACTORY_H_
6 #define CC_SURFACES_SURFACE_FACTORY_H_
8 #include "base/callback_forward.h"
9 #include "base/containers/scoped_ptr_hash_map.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "cc/surfaces/surface_id.h"
13 #include "cc/surfaces/surface_resource_holder.h"
14 #include "cc/surfaces/surfaces_export.h"
16 namespace gfx {
17 class Size;
20 namespace cc {
21 class CompositorFrame;
22 class CopyOutputRequest;
23 class Surface;
24 class SurfaceFactoryClient;
25 class SurfaceManager;
27 // A SurfaceFactory is used to create surfaces that may share resources and
28 // receive returned resources for frames submitted to those surfaces. Resources
29 // submitted to frames created by a particular factory will be returned to that
30 // factory's client when they are no longer being used. This is the only class
31 // most users of surfaces will need to directly interact with.
32 class CC_SURFACES_EXPORT SurfaceFactory
33 : public base::SupportsWeakPtr<SurfaceFactory> {
34 public:
35 SurfaceFactory(SurfaceManager* manager, SurfaceFactoryClient* client);
36 ~SurfaceFactory();
38 void Create(SurfaceId surface_id, const gfx::Size& size);
39 void Destroy(SurfaceId surface_id);
40 // A frame can only be submitted to a surface created by this factory,
41 // although the frame may reference surfaces created by other factories.
42 // The callback is called the first time this frame is used to draw.
43 void SubmitFrame(SurfaceId surface_id,
44 scoped_ptr<CompositorFrame> frame,
45 const base::Closure& callback);
46 void RequestCopyOfSurface(SurfaceId surface_id,
47 scoped_ptr<CopyOutputRequest> copy_request);
49 SurfaceFactoryClient* client() { return client_; }
51 void ReceiveFromChild(const TransferableResourceArray& resources);
52 void RefResources(const TransferableResourceArray& resources);
53 void UnrefResources(const ReturnedResourceArray& resources);
55 private:
56 SurfaceManager* manager_;
57 SurfaceFactoryClient* client_;
58 typedef base::ScopedPtrHashMap<SurfaceId, Surface> OwningSurfaceMap;
59 base::ScopedPtrHashMap<SurfaceId, Surface> surface_map_;
61 SurfaceResourceHolder holder_;
63 DISALLOW_COPY_AND_ASSIGN(SurfaceFactory);
66 } // namespace cc
68 #endif // CC_SURFACES_SURFACE_FACTORY_H_