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

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

Issue 1135743004: cc: Add null checks for GrContext created by ContextProviderCommandBuffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Create and check GrContext early in LTHI::InitializeRenderer() 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 return context3d_->GetContextSupport(); 127 return context3d_->GetContextSupport();
128 } 128 }
129 129
130 class GrContext* ContextProviderCommandBuffer::GrContext() { 130 class GrContext* ContextProviderCommandBuffer::GrContext() {
131 DCHECK(lost_context_callback_proxy_); // Is bound to thread. 131 DCHECK(lost_context_callback_proxy_); // Is bound to thread.
132 DCHECK(context_thread_checker_.CalledOnValidThread()); 132 DCHECK(context_thread_checker_.CalledOnValidThread());
133 133
134 if (gr_context_) 134 if (gr_context_)
135 return gr_context_->get(); 135 return gr_context_->get();
136 136
137 // If GlContext is already lost, skip trying to make a GrContext which
138 // could fail.
139 if (IsContextLost())
140 return nullptr;
piman 2015/05/12 23:33:51 I'd skip this part. No use trying to optimize for
141
137 gr_context_.reset(new GrContextForWebGraphicsContext3D(context3d_.get())); 142 gr_context_.reset(new GrContextForWebGraphicsContext3D(context3d_.get()));
138 143
139 // If GlContext is already lost, also abandon the new GrContext. 144 // If GlContext was lost after the GrContext initialization, delete
140 if (IsContextLost()) 145 // the GrContext.
141 gr_context_->get()->abandonContext(); 146 if (gr_context_->get() && IsContextLost())
147 gr_context_.reset(nullptr);
142 148
143 return gr_context_->get(); 149 return gr_context_->get();
144 } 150 }
145 151
146 void ContextProviderCommandBuffer::SetupLock() { 152 void ContextProviderCommandBuffer::SetupLock() {
147 DCHECK(context3d_); 153 DCHECK(context3d_);
148 context3d_->GetCommandBufferProxy()->SetLock(&context_lock_); 154 context3d_->GetCommandBufferProxy()->SetLock(&context_lock_);
149 } 155 }
150 156
151 base::Lock* ContextProviderCommandBuffer::GetLock() { 157 base::Lock* ContextProviderCommandBuffer::GetLock() {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 241
236 void ContextProviderCommandBuffer::SetMemoryPolicyChangedCallback( 242 void ContextProviderCommandBuffer::SetMemoryPolicyChangedCallback(
237 const MemoryPolicyChangedCallback& memory_policy_changed_callback) { 243 const MemoryPolicyChangedCallback& memory_policy_changed_callback) {
238 DCHECK(context_thread_checker_.CalledOnValidThread()); 244 DCHECK(context_thread_checker_.CalledOnValidThread());
239 DCHECK(memory_policy_changed_callback_.is_null() || 245 DCHECK(memory_policy_changed_callback_.is_null() ||
240 memory_policy_changed_callback.is_null()); 246 memory_policy_changed_callback.is_null());
241 memory_policy_changed_callback_ = memory_policy_changed_callback; 247 memory_policy_changed_callback_ = memory_policy_changed_callback;
242 } 248 }
243 249
244 } // namespace content 250 } // namespace content
OLDNEW
« cc/trees/layer_tree_host_impl.cc ('K') | « cc/trees/layer_tree_host_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698