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

Side by Side Diff: content/common/gpu/client/context_provider_command_buffer.cc

Issue 1095893002: gpu: Fix some context lost marking glitches+leaks and add UMA stats (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: kbr's comment Created 5 years, 7 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #include "content/common/gpu/client/context_provider_command_buffer.h" 5 #include "content/common/gpu/client/context_provider_command_buffer.h"
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 21 matching lines...) Expand all
32 provider_->OnLostContext(); 32 provider_->OnLostContext();
33 } 33 }
34 34
35 private: 35 private:
36 ContextProviderCommandBuffer* provider_; 36 ContextProviderCommandBuffer* provider_;
37 }; 37 };
38 38
39 scoped_refptr<ContextProviderCommandBuffer> 39 scoped_refptr<ContextProviderCommandBuffer>
40 ContextProviderCommandBuffer::Create( 40 ContextProviderCommandBuffer::Create(
41 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, 41 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d,
42 const std::string& debug_name) { 42 CommandBufferContextType type) {
43 if (!context3d) 43 if (!context3d)
44 return NULL; 44 return NULL;
45 45
46 return new ContextProviderCommandBuffer(context3d.Pass(), debug_name); 46 return new ContextProviderCommandBuffer(context3d.Pass(), type);
47 } 47 }
48 48
49 ContextProviderCommandBuffer::ContextProviderCommandBuffer( 49 ContextProviderCommandBuffer::ContextProviderCommandBuffer(
50 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, 50 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d,
51 const std::string& debug_name) 51 CommandBufferContextType type)
52 : context3d_(context3d.Pass()), 52 : context3d_(context3d.Pass()),
53 debug_name_(debug_name), 53 context_type_(type),
54 debug_name_(CommandBufferContextTypeToString(type)),
54 destroyed_(false) { 55 destroyed_(false) {
55 DCHECK(main_thread_checker_.CalledOnValidThread()); 56 DCHECK(main_thread_checker_.CalledOnValidThread());
56 DCHECK(context3d_); 57 DCHECK(context3d_);
57 context_thread_checker_.DetachFromThread(); 58 context_thread_checker_.DetachFromThread();
58 } 59 }
59 60
60 ContextProviderCommandBuffer::~ContextProviderCommandBuffer() { 61 ContextProviderCommandBuffer::~ContextProviderCommandBuffer() {
61 DCHECK(main_thread_checker_.CalledOnValidThread() || 62 DCHECK(main_thread_checker_.CalledOnValidThread() ||
62 context_thread_checker_.CalledOnValidThread()); 63 context_thread_checker_.CalledOnValidThread());
63 64
(...skipping 22 matching lines...) Expand all
86 return context3d_.get(); 87 return context3d_.get();
87 } 88 }
88 89
89 bool ContextProviderCommandBuffer::BindToCurrentThread() { 90 bool ContextProviderCommandBuffer::BindToCurrentThread() {
90 // This is called on the thread the context will be used. 91 // This is called on the thread the context will be used.
91 DCHECK(context_thread_checker_.CalledOnValidThread()); 92 DCHECK(context_thread_checker_.CalledOnValidThread());
92 93
93 if (lost_context_callback_proxy_) 94 if (lost_context_callback_proxy_)
94 return true; 95 return true;
95 96
97 context3d_->SetContextType(context_type_);
96 if (!context3d_->InitializeOnCurrentThread()) 98 if (!context3d_->InitializeOnCurrentThread())
97 return false; 99 return false;
98 100
99 InitializeCapabilities(); 101 InitializeCapabilities();
100 102
101 std::string unique_context_name = 103 std::string unique_context_name =
102 base::StringPrintf("%s-%p", debug_name_.c_str(), context3d_.get()); 104 base::StringPrintf("%s-%p", debug_name_.c_str(), context3d_.get());
103 context3d_->traceBeginCHROMIUM("gpu_toplevel", unique_context_name.c_str()); 105 context3d_->traceBeginCHROMIUM("gpu_toplevel", unique_context_name.c_str());
104 106
105 lost_context_callback_proxy_.reset(new LostContextCallbackProxy(this)); 107 lost_context_callback_proxy_.reset(new LostContextCallbackProxy(this));
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 236
235 void ContextProviderCommandBuffer::SetMemoryPolicyChangedCallback( 237 void ContextProviderCommandBuffer::SetMemoryPolicyChangedCallback(
236 const MemoryPolicyChangedCallback& memory_policy_changed_callback) { 238 const MemoryPolicyChangedCallback& memory_policy_changed_callback) {
237 DCHECK(context_thread_checker_.CalledOnValidThread()); 239 DCHECK(context_thread_checker_.CalledOnValidThread());
238 DCHECK(memory_policy_changed_callback_.is_null() || 240 DCHECK(memory_policy_changed_callback_.is_null() ||
239 memory_policy_changed_callback.is_null()); 241 memory_policy_changed_callback.is_null());
240 memory_policy_changed_callback_ = memory_policy_changed_callback; 242 memory_policy_changed_callback_ = memory_policy_changed_callback;
241 } 243 }
242 244
243 } // namespace content 245 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698