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

Unified Diff: cc/surfaces/sequence_surface_reference_factory.cc

Issue 2514033002: Introducing SurfaceReferenceFactory (Closed)
Patch Set: rebase Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/surfaces/sequence_surface_reference_factory.h ('k') | cc/surfaces/surface_info.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/surfaces/sequence_surface_reference_factory.cc
diff --git a/cc/surfaces/sequence_surface_reference_factory.cc b/cc/surfaces/sequence_surface_reference_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d22c9abe782bc86eb787b41c1e92801be5730f55
--- /dev/null
+++ b/cc/surfaces/sequence_surface_reference_factory.cc
@@ -0,0 +1,31 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/surfaces/sequence_surface_reference_factory.h"
+
+#include "cc/surfaces/sequence_surface_reference.h"
+
+namespace cc {
+
+std::unique_ptr<SurfaceReferenceBase>
+SequenceSurfaceReferenceFactory::CreateReference(
+ SurfaceReferenceOwner* owner,
+ const SurfaceId& surface_id) const {
+ auto seq = owner->GetSurfaceSequenceGenerator()->CreateSurfaceSequence();
+ RequireSequence(surface_id, seq);
+ return base::MakeUnique<SequenceSurfaceReference>(make_scoped_refptr(this),
+ seq);
+}
+
+void SequenceSurfaceReferenceFactory::DestroyReference(
+ SurfaceReferenceBase* surface_ref) const {
+ // This method can only be called by a SurfaceReferenceBase because it's
+ // private and only SurfaceReferenceBase is a friend. The reference only
+ // calls this method on the factory that created it. So it's safe to cast
+ // the passed reference to the type returned by CreateReference.
+ auto ref = static_cast<SequenceSurfaceReference*>(surface_ref);
+ SatisfySequence(ref->sequence());
+}
+
+} // namespace cc
« no previous file with comments | « cc/surfaces/sequence_surface_reference_factory.h ('k') | cc/surfaces/surface_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698