OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2016 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. | |
4 | |
5 #ifndef CC_SURFACES_SURFACE_EMBEDDING_BASE_H_ | |
6 #define CC_SURFACES_SURFACE_EMBEDDING_BASE_H_ | |
7 | |
8 #include <memory> | |
9 | |
10 #include "base/memory/ptr_util.h" | |
11 #include "base/memory/ref_counted.h" | |
12 #include "cc/surfaces/surface_id.h" | |
13 #include "cc/surfaces/surface_reference_owner.h" | |
14 #include "cc/surfaces/surface_sequence.h" | |
15 #include "ui/gfx/geometry/size.h" | |
16 | |
17 namespace cc { | |
18 | |
19 struct SurfaceInfo { | |
Fady Samuel
2016/12/12 16:12:01
Move to a separate file.
| |
20 SurfaceId id; | |
21 float scale = 1.f; | |
22 gfx::Size size; | |
23 | |
24 SurfaceInfo() {} | |
Fady Samuel
2016/12/12 16:12:00
SurfaceInfo() = default;
| |
25 SurfaceInfo(const SurfaceId& id, float scale, gfx::Size size) | |
26 : id(id), scale(scale), size(size) {} | |
27 bool operator==(const SurfaceInfo& info) const { | |
Fady Samuel
2016/12/12 16:12:00
Implement !=
| |
28 return id == info.id && scale == info.scale && size == info.size; | |
29 } | |
30 }; | |
31 | |
32 class CompositorFrameMetadata; | |
33 class SurfaceEmbedding; | |
34 typedef scoped_refptr<SurfaceEmbedding> SurfaceEmbeddingPtr; | |
Fady Samuel
2016/12/12 16:12:00
This typedef isn't adding value. Please be explici
| |
35 | |
36 /* The base class for the references returned by SurfaceReferenceFactory and | |
37 * its subclasses. | |
38 * The objects of this class hold on to their corresponding surface reference | |
39 * until destroy is called or until the object goes out of scope. | |
40 * To keep things as lightweight as possible, the base class only keeps a | |
41 * pointer to the factory and it's left up to the subclasses to decide what | |
42 * other information they need to keep. */ | |
43 class SurfaceRef { | |
Fady Samuel
2016/12/12 16:12:00
Please try to have one class per header / cc file
| |
44 public: | |
45 explicit SurfaceRef(const SurfaceEmbedding* factory); | |
Fady Samuel
2016/12/12 16:12:00
I'd also give this a move only constructor and mov
| |
46 virtual ~SurfaceRef(); | |
47 | |
48 void Destroy(); | |
49 void Destroy(CompositorFrameMetadata* metadata); | |
50 bool IsDestroyed() const; | |
51 | |
52 const SurfaceEmbedding* factory() const { return factory_.get(); } | |
53 | |
54 private: | |
55 scoped_refptr<const SurfaceEmbedding> factory_; | |
56 }; | |
57 | |
58 typedef std::unique_ptr<SurfaceRef> SurfaceRefPtr; | |
59 | |
60 class SequenceSurfaceRef : public SurfaceRef { | |
61 public: | |
62 SequenceSurfaceRef(const SurfaceEmbedding* factory, | |
Fady Samuel
2016/12/12 16:12:00
Move constructor and move assignment operator.
| |
63 const SurfaceSequence& seq); | |
64 | |
65 const SurfaceSequence& seq() const { return seq_; } | |
66 | |
67 private: | |
68 const SurfaceSequence seq_; | |
69 }; | |
70 | |
71 class SurfaceEmbedding : public base::RefCounted<SurfaceEmbedding> { | |
72 public: | |
73 virtual SurfaceRefPtr CreateReference(SurfaceReferenceOwner*, | |
74 const SurfaceId&) const = 0; | |
75 | |
76 protected: | |
77 virtual ~SurfaceEmbedding() = default; | |
78 | |
79 private: | |
80 friend class base::RefCounted<SurfaceEmbedding>; | |
81 virtual void DestroyReference(SurfaceRef*) const = 0; | |
82 virtual void DestroyReference(SurfaceRef*, | |
83 CompositorFrameMetadata*) const = 0; | |
84 friend class SurfaceRef; | |
85 }; | |
86 | |
87 } // namespace cc | |
88 | |
89 #endif // CC_SURFACES_SURFACE_EMBEDDING_BASE_H_ | |
OLD | NEW |