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

Unified Diff: cc/surfaces/surface_embedding_base.cc

Issue 2514033002: Introducing SurfaceReferenceFactory (Closed)
Patch Set: ref 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
Index: cc/surfaces/surface_embedding_base.cc
diff --git a/cc/surfaces/surface_embedding_base.cc b/cc/surfaces/surface_embedding_base.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b3a0a890295c7e1ec6add93be21c3851644a1f81
--- /dev/null
+++ b/cc/surfaces/surface_embedding_base.cc
@@ -0,0 +1,37 @@
+// Copyright (c) 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/surface_embedding_base.h"
+
+namespace cc {
+
+void SurfaceRef::Destroy() {
+ if (!factory_)
+ return;
+ factory_->DestroyReference(this);
+ factory_ = nullptr;
+}
+
+void SurfaceRef::Destroy(CompositorFrameMetadata* metadata) {
+ if (!factory_)
+ return;
+ factory_->DestroyReference(this, metadata);
+ factory_ = nullptr;
+}
+
+bool SurfaceRef::IsDestroyed() const {
+ return factory_ == nullptr;
+}
+
+SurfaceRef::~SurfaceRef() {
+ Destroy();
+}
+
+SurfaceRef::SurfaceRef(const SurfaceEmbedding* factory) : factory_(factory) {}
+
+SequenceSurfaceRef::SequenceSurfaceRef(const SurfaceEmbedding* factory,
+ const SurfaceSequence& seq)
+ : SurfaceRef(factory), seq_(seq) {}
+
+} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698