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

Unified Diff: cc/output/context_cache_controller.h

Issue 2278283003: Refactor client visibility handling (Closed)
Patch Set: more fixes Created 4 years, 4 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/BUILD.gn ('k') | cc/output/context_cache_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/output/context_cache_controller.h
diff --git a/cc/output/context_cache_controller.h b/cc/output/context_cache_controller.h
new file mode 100644
index 0000000000000000000000000000000000000000..fb1ab9f4efb59a3273b158d6ac5c31dd555b6d66
--- /dev/null
+++ b/cc/output/context_cache_controller.h
@@ -0,0 +1,74 @@
+// 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.
+
+#ifndef CC_OUTPUT_CONTEXT_CACHE_CONTROLLER_H_
+#define CC_OUTPUT_CONTEXT_CACHE_CONTROLLER_H_
+
+#include <cstdint>
+#include <memory>
+
+#include "base/macros.h"
+#include "cc/base/cc_export.h"
+
+class GrContext;
+
+namespace gpu {
+class ContextSupport;
+}
+
+namespace cc {
+
+// ContextCacheController manages clearing cached data on ContextProvider when
+// appropriate. Currently, cache clearing happens when the ContextProvider
+// transitions from visible to not visible. As a ContextProvider may have
+// multiple clients, ContextCacheController tracks visibility across all
+// clients and only cleans up when appropriate.
+//
+// Note: Virtuals on this function are for testing only. This function is not
+// designed to have multiple implementations.
+class CC_EXPORT ContextCacheController {
+ public:
+ class CC_EXPORT ScopedVisibility {
+ public:
+ ~ScopedVisibility();
+
+ private:
+ friend class ContextCacheController;
+ ScopedVisibility();
+ void Release();
+
+ bool released_ = false;
+ };
+
+ explicit ContextCacheController(gpu::ContextSupport* context_support);
+ virtual ~ContextCacheController();
+
+ void SetGrContext(GrContext* gr_context);
+
+ // Clients of the owning ContextProvider should call this function when they
+ // become visible. The returned ScopedVisibility pointer must be passed back
+ // to ClientBecameNotVisible or it will DCHECK in its destructor.
+ virtual std::unique_ptr<ScopedVisibility> ClientBecameVisible();
+
+ // When a client becomes not visible (either due to a visibility change or
+ // because it is being deleted), it must pass back any ScopedVisibility
+ // pointers it owns via this function.
+ virtual void ClientBecameNotVisible(
+ std::unique_ptr<ScopedVisibility> scoped_visibility);
+
+ protected:
+ std::unique_ptr<ScopedVisibility> CreateScopedVisibilityForTesting() const;
+ void ReleaseScopedVisibilityForTesting(
+ std::unique_ptr<ScopedVisibility> scoped_visibility) const;
+
+ private:
+ gpu::ContextSupport* context_support_;
+ GrContext* gr_context_ = nullptr;
+
+ uint32_t num_clients_visible_ = 0;
+};
+
+} // namespace cc
+
+#endif // CC_OUTPUT_CONTEXT_CACHE_CONTROLLER_H_
« no previous file with comments | « cc/BUILD.gn ('k') | cc/output/context_cache_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698