Chromium Code Reviews| 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..bcf0b3a88d2b4b98298fe45340cbb2f1cda116a7 |
| --- /dev/null |
| +++ b/cc/output/context_cache_controller.h |
| @@ -0,0 +1,64 @@ |
| +// 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 |
|
danakj
2016/08/26 23:49:08
My one thought is that it's a bit weird that the i
ericrk
2016/08/29 22:43:22
Yeah, I had a similar thought, but I assumed there
|
| +// appropriate. Currently, cache clearing happens when the Context provider |
|
danakj
2016/08/26 23:49:08
when the ContextProvider
ericrk
2016/08/29 22:43:22
Done.
|
| +// transitions from Visible to Not Visible. As a ContextProvider may have |
|
danakj
2016/08/26 23:49:08
visible to not visible
ericrk
2016/08/29 22:43:22
Done.
|
| +// multiple clients, ContextCacheController tracks visibility across all |
| +// clients and only cleans up when appropriate. |
| +class CC_EXPORT ContextCacheController { |
|
ericrk
2016/08/26 22:55:47
This name is a bit silly - I'm thinking of a bette
danakj
2016/08/26 23:49:08
lies it's perfect
|
| + public: |
| + class ScopedVisibility { |
| + public: |
| + ~ScopedVisibility(); |
| + |
| + private: |
| + friend class ContextCacheController; |
| + ScopedVisibility(); |
| + void Release(); |
| + |
| + bool released_ = false; |
| + }; |
| + |
| + explicit ContextCacheController(gpu::ContextSupport* context_support); |
| + void SetGrContext(GrContext* gr_context); |
|
danakj
2016/08/26 23:49:08
whitespace after constructors/destructor plz
ericrk
2016/08/29 22:43:22
Done.
|
| + |
| + // 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. |
| + 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. |
| + void ClientBecameNotVisible( |
| + std::unique_ptr<ScopedVisibility> scoped_visibility); |
| + |
| + private: |
| + gpu::ContextSupport* context_support_; |
| + GrContext* gr_context_ = nullptr; |
| + |
| + uint32_t num_clients_visible_ = 0; |
| +}; |
| + |
| +} // namespace cc |
| + |
| +#endif // CC_OUTPUT_CONTEXT_CACHE_CONTROLLER_H_ |