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

Unified Diff: cc/surfaces/referenced_surface_tracker.h

Issue 2632273003: Move ReferencedSurfaceTracker into GpuCompositorFrameSink. (Closed)
Patch Set: Fix iterator invalidation. Created 3 years, 11 months 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/embedded_surface_tracker_unittest.cc ('k') | cc/surfaces/referenced_surface_tracker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/surfaces/referenced_surface_tracker.h
diff --git a/cc/surfaces/referenced_surface_tracker.h b/cc/surfaces/referenced_surface_tracker.h
new file mode 100644
index 0000000000000000000000000000000000000000..19e17f3d4d276c30e67bbe35cc1646cb12c7a41c
--- /dev/null
+++ b/cc/surfaces/referenced_surface_tracker.h
@@ -0,0 +1,78 @@
+// 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.
+
+#ifndef CC_SURFACES_REFERENCED_SURFACE_TRACKER_H_
+#define CC_SURFACES_REFERENCED_SURFACE_TRACKER_H_
+
+#include <unordered_set>
+#include <vector>
+
+#include "base/macros.h"
+#include "cc/surfaces/frame_sink_id.h"
+#include "cc/surfaces/surface_id.h"
+#include "cc/surfaces/surface_reference.h"
+#include "cc/surfaces/surfaces_export.h"
+
+namespace cc {
+
+// Tracks surface references for a client surface. UpdateReferences() should be
+// called once per CompositorFrame to populate |references_to_add_| and
+// |references_to_remove_|.
+class CC_SURFACES_EXPORT ReferencedSurfaceTracker {
+ public:
+ explicit ReferencedSurfaceTracker(const FrameSinkId& frame_sink_id);
+ ~ReferencedSurfaceTracker();
+
+ const SurfaceId& current_surface_id() const { return current_surface_id_; }
+
+ std::vector<SurfaceReference>& references_to_add() {
+ return references_to_add_;
+ }
+
+ std::vector<SurfaceReference>& references_to_remove() {
+ return references_to_remove_;
+ }
+
+ // Update the references for a CompositorFrame. If |local_frame_id| has
+ // changed then new references will be generated for everything in
+ // |referenced_surfaces|. Otherwise a diff from the referenced surfaces in the
+ // last frame will be computed. This should be called once per
+ // CompositorFrame.
+ void UpdateReferences(const LocalFrameId& local_frame_id,
+ const std::vector<SurfaceId>& referenced_surfaces);
+
+ private:
+ // Updates |referenced_surfaces_| based on a |new_referenced_surfaces| from a
+ // CompositorFrame. Populates |references_to_add_| and |references_to_remove_|
+ // based on the difference between the sets.
+ void ProcessNewReferences(const std::unordered_set<SurfaceId, SurfaceIdHash>&
+ new_referenced_surfaces);
+
+ // Adds reference from |current_surface_id_| to |surface_id|.
+ void AddSurfaceReference(const SurfaceId& surface_id);
+
+ // Removes reference from |current_surface_id_| to |surface_id|.
+ void RemoveSurfaceReference(const SurfaceId& surface_id);
+
+ // The id of the client surface that is embedding other surfaces.
+ SurfaceId current_surface_id_;
+
+ // TODO(samans): Use the same SurfaceId set that SurfaceManager holds.
+ // Set of surfaces referenced by the last submitted CompositorFrame.
+ std::unordered_set<SurfaceId, SurfaceIdHash> referenced_surfaces_;
+
+ // References to surfaces that should be added for the next CompositorFrame.
+ std::vector<SurfaceReference> references_to_add_;
+
+ // References to surfaces that should be removed after the next
+ // CompositorFrame has been submitted and the surfaces are no longer needed by
+ // |current_surface_id_|.
+ std::vector<SurfaceReference> references_to_remove_;
+
+ DISALLOW_COPY_AND_ASSIGN(ReferencedSurfaceTracker);
+};
+
+} // namespace cc
+
+#endif // CC_SURFACES_REFERENCED_SURFACE_TRACKER_H_
« no previous file with comments | « cc/surfaces/embedded_surface_tracker_unittest.cc ('k') | cc/surfaces/referenced_surface_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698