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

Side by Side Diff: content/browser/android/in_process/synchronous_compositor_factory_impl.cc

Issue 461333002: Nullify video context provider when there is no harware compositor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/browser/android/in_process/synchronous_compositor_factory_impl .h" 5 #include "content/browser/android/in_process/synchronous_compositor_factory_impl .h"
6 6
7 #include "content/browser/android/in_process/synchronous_compositor_output_surfa ce.h" 7 #include "content/browser/android/in_process/synchronous_compositor_output_surfa ce.h"
8 #include "content/public/browser/browser_thread.h" 8 #include "content/public/browser/browser_thread.h"
9 #include "content/renderer/gpu/frame_swap_message_queue.h" 9 #include "content/renderer/gpu/frame_swap_message_queue.h"
10 #include "gpu/command_buffer/client/gl_in_process_context.h" 10 #include "gpu/command_buffer/client/gl_in_process_context.h"
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 225
226 void SynchronousCompositorFactoryImpl::CompositorInitializedHardwareDraw() { 226 void SynchronousCompositorFactoryImpl::CompositorInitializedHardwareDraw() {
227 base::AutoLock lock(num_hardware_compositor_lock_); 227 base::AutoLock lock(num_hardware_compositor_lock_);
228 num_hardware_compositors_++; 228 num_hardware_compositors_++;
229 } 229 }
230 230
231 void SynchronousCompositorFactoryImpl::CompositorReleasedHardwareDraw() { 231 void SynchronousCompositorFactoryImpl::CompositorReleasedHardwareDraw() {
232 base::AutoLock lock(num_hardware_compositor_lock_); 232 base::AutoLock lock(num_hardware_compositor_lock_);
233 DCHECK_GT(num_hardware_compositors_, 0u); 233 DCHECK_GT(num_hardware_compositors_, 0u);
234 num_hardware_compositors_--; 234 num_hardware_compositors_--;
235 if (num_hardware_compositors_ == 0) {
236 // Nullify the video_context_provider_ now so that it is not null only if
237 // there is at least 1 hardware compositor
238 video_context_provider_ = NULL;
239 }
235 } 240 }
236 241
237 bool SynchronousCompositorFactoryImpl::CanCreateMainThreadContext() { 242 bool SynchronousCompositorFactoryImpl::CanCreateMainThreadContext() {
238 base::AutoLock lock(num_hardware_compositor_lock_); 243 base::AutoLock lock(num_hardware_compositor_lock_);
239 return num_hardware_compositors_ > 0; 244 return num_hardware_compositors_ > 0;
240 } 245 }
241 246
242 scoped_refptr<StreamTextureFactorySynchronousImpl::ContextProvider> 247 scoped_refptr<StreamTextureFactorySynchronousImpl::ContextProvider>
243 SynchronousCompositorFactoryImpl::TryCreateStreamTextureFactory() { 248 SynchronousCompositorFactoryImpl::TryCreateStreamTextureFactory() {
244 scoped_refptr<StreamTextureFactorySynchronousImpl::ContextProvider> 249 scoped_refptr<StreamTextureFactorySynchronousImpl::ContextProvider>
245 context_provider; 250 context_provider;
246 // This check only guarantees the main thread context is created after 251 // This check only guarantees the main thread context is created after
247 // a compositor did successfully initialize hardware draw in the past. 252 // a compositor did successfully initialize hardware draw in the past.
248 // In particular this does not guarantee that the main thread context 253 // When all compositors have released hardware draw, main thread context
249 // will fail creation when all compositors release hardware draw. 254 // creation is guaranteed to fail.
250 if (CanCreateMainThreadContext() && !video_context_provider_) { 255 if (CanCreateMainThreadContext() && !video_context_provider_) {
251 DCHECK(service_); 256 DCHECK(service_);
252 DCHECK(share_context_.get()); 257 DCHECK(share_context_.get());
253 258
254 video_context_provider_ = new VideoContextProvider( 259 video_context_provider_ = new VideoContextProvider(
255 CreateContext(service_, share_context_.get())); 260 CreateContext(service_, share_context_.get()));
256 } 261 }
257 return video_context_provider_; 262 return video_context_provider_;
258 } 263 }
259 264
260 void SynchronousCompositorFactoryImpl::SetDeferredGpuService( 265 void SynchronousCompositorFactoryImpl::SetDeferredGpuService(
261 scoped_refptr<gpu::InProcessCommandBuffer::Service> service) { 266 scoped_refptr<gpu::InProcessCommandBuffer::Service> service) {
262 DCHECK(!service_); 267 DCHECK(!service_);
263 service_ = service; 268 service_ = service;
264 } 269 }
265 270
266 void SynchronousCompositorFactoryImpl::SetRecordFullDocument( 271 void SynchronousCompositorFactoryImpl::SetRecordFullDocument(
267 bool record_full_document) { 272 bool record_full_document) {
268 record_full_layer_ = record_full_document; 273 record_full_layer_ = record_full_document;
269 } 274 }
270 275
271 } // namespace content 276 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698