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

Side by Side Diff: gpu/command_buffer/client/gles2_implementation.cc

Issue 2252163003: Update Context Client Visibility to use Scoped Pattern (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // A class to emulate GLES2 over command buffers. 5 // A class to emulate GLES2 over command buffers.
6 6
7 #include "gpu/command_buffer/client/gles2_implementation.h" 7 #include "gpu/command_buffer/client/gles2_implementation.h"
8 8
9 #include <GLES2/gl2.h> 9 #include <GLES2/gl2.h>
10 #include <GLES2/gl2ext.h> 10 #include <GLES2/gl2ext.h>
(...skipping 14 matching lines...) Expand all
25 #include "base/threading/thread_task_runner_handle.h" 25 #include "base/threading/thread_task_runner_handle.h"
26 #include "base/trace_event/memory_allocator_dump.h" 26 #include "base/trace_event/memory_allocator_dump.h"
27 #include "base/trace_event/memory_dump_manager.h" 27 #include "base/trace_event/memory_dump_manager.h"
28 #include "base/trace_event/process_memory_dump.h" 28 #include "base/trace_event/process_memory_dump.h"
29 #include "base/trace_event/trace_event.h" 29 #include "base/trace_event/trace_event.h"
30 #include "gpu/command_buffer/client/buffer_tracker.h" 30 #include "gpu/command_buffer/client/buffer_tracker.h"
31 #include "gpu/command_buffer/client/gles2_cmd_helper.h" 31 #include "gpu/command_buffer/client/gles2_cmd_helper.h"
32 #include "gpu/command_buffer/client/gpu_control.h" 32 #include "gpu/command_buffer/client/gpu_control.h"
33 #include "gpu/command_buffer/client/program_info_manager.h" 33 #include "gpu/command_buffer/client/program_info_manager.h"
34 #include "gpu/command_buffer/client/query_tracker.h" 34 #include "gpu/command_buffer/client/query_tracker.h"
35 #include "gpu/command_buffer/client/scoped_visibility_impl.h"
35 #include "gpu/command_buffer/client/shared_memory_limits.h" 36 #include "gpu/command_buffer/client/shared_memory_limits.h"
36 #include "gpu/command_buffer/client/transfer_buffer.h" 37 #include "gpu/command_buffer/client/transfer_buffer.h"
37 #include "gpu/command_buffer/client/vertex_array_object_manager.h" 38 #include "gpu/command_buffer/client/vertex_array_object_manager.h"
38 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 39 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
39 #include "gpu/command_buffer/common/id_allocator.h" 40 #include "gpu/command_buffer/common/id_allocator.h"
40 #include "gpu/command_buffer/common/sync_token.h" 41 #include "gpu/command_buffer/common/sync_token.h"
41 #include "ui/gfx/geometry/rect.h" 42 #include "ui/gfx/geometry/rect.h"
42 #include "ui/gfx/geometry/rect_f.h" 43 #include "ui/gfx/geometry/rect_f.h"
43 44
44 #if defined(GPU_CLIENT_DEBUG) 45 #if defined(GPU_CLIENT_DEBUG)
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // use any extra for memory contrained devices (<=1GB). 159 // use any extra for memory contrained devices (<=1GB).
159 base::SysInfo::AmountOfPhysicalMemory() > 1024 * 1024 * 1024 160 base::SysInfo::AmountOfPhysicalMemory() > 1024 * 1024 * 1024
160 ? base::saturated_cast<uint32_t>( 161 ? base::saturated_cast<uint32_t>(
161 base::SysInfo::AmountOfPhysicalMemory() / 20) 162 base::SysInfo::AmountOfPhysicalMemory() / 20)
162 : 0), 163 : 0),
163 #endif 164 #endif
164 current_trace_stack_(0), 165 current_trace_stack_(0),
165 gpu_control_(gpu_control), 166 gpu_control_(gpu_control),
166 capabilities_(gpu_control->GetCapabilities()), 167 capabilities_(gpu_control->GetCapabilities()),
167 aggressively_free_resources_(false), 168 aggressively_free_resources_(false),
169 visible_clients_(0),
168 cached_extension_string_(nullptr), 170 cached_extension_string_(nullptr),
169 weak_ptr_factory_(this) { 171 weak_ptr_factory_(this) {
170 DCHECK(helper); 172 DCHECK(helper);
171 DCHECK(transfer_buffer); 173 DCHECK(transfer_buffer);
172 DCHECK(gpu_control); 174 DCHECK(gpu_control);
173 175
174 std::stringstream ss; 176 std::stringstream ss;
175 ss << std::hex << this; 177 ss << std::hex << this;
176 this_in_hex_ = ss.str(); 178 this_in_hex_ = ss.str();
177 179
(...skipping 5676 matching lines...) Expand 10 before | Expand all | Expand 10 after
5854 5856
5855 uint64_t GLES2Implementation::ShareGroupTracingGUID() const { 5857 uint64_t GLES2Implementation::ShareGroupTracingGUID() const {
5856 return share_group_->TracingGUID(); 5858 return share_group_->TracingGUID();
5857 } 5859 }
5858 5860
5859 void GLES2Implementation::SetErrorMessageCallback( 5861 void GLES2Implementation::SetErrorMessageCallback(
5860 const base::Callback<void(const char*, int32_t)>& callback) { 5862 const base::Callback<void(const char*, int32_t)>& callback) {
5861 error_message_callback_ = callback; 5863 error_message_callback_ = callback;
5862 } 5864 }
5863 5865
5864 void GLES2Implementation::SetClientVisible(int client_id, bool is_visible) { 5866 std::unique_ptr<ContextSupport::ScopedVisibility>
5865 if (is_visible) { 5867 GLES2Implementation::ClientBecameVisible() {
5866 visible_clients_.insert(client_id); 5868 ++visible_clients_;
5867 } else { 5869 return std::unique_ptr<gpu::ScopedVisibilityImpl>(
5868 auto found = visible_clients_.find(client_id); 5870 new gpu::ScopedVisibilityImpl(this));
5869 if (found != visible_clients_.end()) 5871 }
5870 visible_clients_.erase(found); 5872
5871 } 5873 void GLES2Implementation::ClientBecameNotVisible(
5874 std::unique_ptr<ScopedVisibility> visibility) {
5875 DCHECK_GT(visible_clients_, 0u);
5876 --visible_clients_;
5877 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.
5872 } 5878 }
5873 5879
5874 bool GLES2Implementation::AnyClientsVisible() const { 5880 bool GLES2Implementation::AnyClientsVisible() const {
5875 return !visible_clients_.empty(); 5881 return visible_clients_ > 0;
5876 } 5882 }
5877 5883
5878 void GLES2Implementation::SetLostContextCallback( 5884 void GLES2Implementation::SetLostContextCallback(
5879 const base::Closure& callback) { 5885 const base::Closure& callback) {
5880 lost_context_callback_ = callback; 5886 lost_context_callback_ = callback;
5881 } 5887 }
5882 5888
5883 GLuint64 GLES2Implementation::InsertFenceSyncCHROMIUM() { 5889 GLuint64 GLES2Implementation::InsertFenceSyncCHROMIUM() {
5884 const uint64_t release = gpu_control_->GenerateFenceSyncRelease(); 5890 const uint64_t release = gpu_control_->GenerateFenceSyncRelease();
5885 helper_->InsertFenceSyncCHROMIUM(release); 5891 helper_->InsertFenceSyncCHROMIUM(release);
(...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after
6909 cached_extensions_.clear(); 6915 cached_extensions_.clear();
6910 } 6916 }
6911 6917
6912 // Include the auto-generated part of this file. We split this because it means 6918 // Include the auto-generated part of this file. We split this because it means
6913 // we can easily edit the non-auto generated parts right here in this file 6919 // we can easily edit the non-auto generated parts right here in this file
6914 // instead of having to edit some template or the code generator. 6920 // instead of having to edit some template or the code generator.
6915 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" 6921 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h"
6916 6922
6917 } // namespace gles2 6923 } // namespace gles2
6918 } // namespace gpu 6924 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698