Chromium Code Reviews| 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 "cc/surfaces/surface_id.h" | |
| 12 #include "cc/surfaces/surface_sequence.h" | |
| 13 #include "cc/surfaces/surface_sequence_generator.h" | |
| 14 #include "ui/gfx/geometry/size.h" | |
| 15 | |
| 16 namespace cc { | |
| 17 | |
| 18 struct SurfaceInfo { | |
|
Fady Samuel
2016/12/07 23:29:05
Put this in a separate file?
| |
| 19 SurfaceId id; | |
| 20 float scale = 1.f; | |
| 21 gfx::Size size; | |
| 22 | |
| 23 SurfaceInfo() {} | |
| 24 SurfaceInfo(const SurfaceId& id, float scale, gfx::Size size) | |
| 25 : id(id), scale(scale), size(size) {} | |
| 26 bool operator==(const SurfaceInfo& info) const { | |
|
kylechar
2016/12/08 02:02:46
You should define != too if you define ==.
| |
| 27 return id == info.id && scale == info.scale && size == info.size; | |
| 28 } | |
| 29 }; | |
| 30 | |
| 31 class CompositorFrameMetadata; | |
| 32 class SurfaceEmbedding; | |
| 33 typedef std::unique_ptr<SurfaceEmbedding> SurfaceEmbeddingPtr; | |
| 34 | |
| 35 class SurfaceEmbeddingOwner { | |
| 36 public: | |
| 37 virtual SurfaceSequenceGenerator* GetSurfaceSequenceGenerator() = 0; | |
| 38 }; | |
| 39 | |
| 40 class SurfaceEmbedding { | |
|
kylechar
2016/12/08 02:02:46
One class per header and file should be named afte
| |
| 41 public: | |
| 42 explicit SurfaceEmbedding(const SurfaceInfo& info) : info_(info) {} | |
| 43 ~SurfaceEmbedding(); | |
|
kylechar
2016/12/08 02:02:46
virtual ~SurfaceEmbedding();
| |
| 44 | |
| 45 void RemoveReference() { | |
|
kylechar
2016/12/08 02:02:46
Function definitions should be in the .cc file unl
| |
| 46 if (!has_ref_) | |
| 47 return; | |
| 48 DCHECK(id().is_valid()); | |
| 49 RemoveReferenceImpl(); | |
| 50 has_ref_ = false; | |
| 51 } | |
| 52 | |
| 53 SurfaceEmbeddingPtr CreateReference(SurfaceEmbeddingOwner* owner) { | |
|
Fady Samuel
2016/12/07 23:29:05
How about simply making this a pure virtual functi
| |
| 54 SurfaceEmbeddingPtr clone = Clone(); | |
| 55 clone->AddReferenceImpl(owner); | |
| 56 clone->has_ref_ = true; | |
| 57 return clone; | |
| 58 } | |
| 59 | |
| 60 void DelegateReference(CompositorFrameMetadata* metadata) { | |
|
Fady Samuel
2016/12/07 23:29:05
DelegateReference is a confusing name: How about j
| |
| 61 DelegateReferenceImpl(metadata); | |
| 62 has_ref_ = false; | |
| 63 } | |
| 64 | |
| 65 const SurfaceInfo& info() { return info_; } | |
| 66 const SurfaceId& id() const { return info_.id; } | |
| 67 float scale() const { return info_.scale; } | |
| 68 const gfx::Size& size() const { return info_.size; } | |
| 69 | |
| 70 SurfaceEmbeddingPtr Clone() { | |
|
Fady Samuel
2016/12/08 12:49:24
If you want a clone then just make Clone() a pure
| |
| 71 DCHECK(!has_ref_); | |
| 72 return SurfaceEmbeddingPtr(CloneImpl()); | |
| 73 } | |
| 74 | |
| 75 private: | |
| 76 virtual void AddReferenceImpl(SurfaceEmbeddingOwner*) = 0; | |
| 77 virtual void RemoveReferenceImpl() = 0; | |
| 78 virtual void DelegateReferenceImpl(CompositorFrameMetadata*) = 0; | |
| 79 virtual SurfaceEmbedding* CloneImpl() = 0; | |
| 80 | |
| 81 const SurfaceInfo info_; | |
| 82 bool has_ref_ = false; | |
| 83 }; | |
| 84 | |
| 85 } // namespace cc | |
| 86 | |
| 87 #endif // CC_SURFACES_SURFACE_EMBEDDING_BASE_H_ | |
| OLD | NEW |