Chromium Code Reviews| Index: gpu/command_buffer/client/gles2_implementation.cc |
| diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc |
| index d2f959c11b23f2ce34f6cd3c01ac053595704877..e6110941fa91f09ddaaa8984f11e883cc5d15819 100644 |
| --- a/gpu/command_buffer/client/gles2_implementation.cc |
| +++ b/gpu/command_buffer/client/gles2_implementation.cc |
| @@ -32,6 +32,7 @@ |
| #include "gpu/command_buffer/client/gpu_control.h" |
| #include "gpu/command_buffer/client/program_info_manager.h" |
| #include "gpu/command_buffer/client/query_tracker.h" |
| +#include "gpu/command_buffer/client/scoped_visibility_impl.h" |
| #include "gpu/command_buffer/client/shared_memory_limits.h" |
| #include "gpu/command_buffer/client/transfer_buffer.h" |
| #include "gpu/command_buffer/client/vertex_array_object_manager.h" |
| @@ -165,6 +166,7 @@ GLES2Implementation::GLES2Implementation( |
| gpu_control_(gpu_control), |
| capabilities_(gpu_control->GetCapabilities()), |
| aggressively_free_resources_(false), |
| + visible_clients_(0), |
| cached_extension_string_(nullptr), |
| weak_ptr_factory_(this) { |
| DCHECK(helper); |
| @@ -5861,18 +5863,22 @@ void GLES2Implementation::SetErrorMessageCallback( |
| error_message_callback_ = callback; |
| } |
| -void GLES2Implementation::SetClientVisible(int client_id, bool is_visible) { |
| - if (is_visible) { |
| - visible_clients_.insert(client_id); |
| - } else { |
| - auto found = visible_clients_.find(client_id); |
| - if (found != visible_clients_.end()) |
| - visible_clients_.erase(found); |
| - } |
| +std::unique_ptr<ContextSupport::ScopedVisibility> |
| +GLES2Implementation::ClientBecameVisible() { |
| + ++visible_clients_; |
| + return std::unique_ptr<gpu::ScopedVisibilityImpl>( |
| + new gpu::ScopedVisibilityImpl(this)); |
| +} |
| + |
| +void GLES2Implementation::ClientBecameNotVisible( |
| + std::unique_ptr<ScopedVisibility> visibility) { |
| + DCHECK_GT(visible_clients_, 0u); |
| + --visible_clients_; |
| + static_cast<ScopedVisibilityImpl*>(visibility.get())->Release(this); |
|
danakj
2016/08/18 21:39:44
I think maybe just define this class in this .cc f
ericrk
2016/08/19 17:23:19
Done.
|
| } |
| bool GLES2Implementation::AnyClientsVisible() const { |
| - return !visible_clients_.empty(); |
| + return visible_clients_ > 0; |
| } |
| void GLES2Implementation::SetLostContextCallback( |