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

Side by Side Diff: content/browser/aura/gpu_process_transport_factory.cc

Issue 23247002: Remove base::Callback from ContextProvider creation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
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/browser/aura/gpu_process_transport_factory.h" 5 #include "content/browser/aura/gpu_process_transport_factory.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 ui::Compositor* compositor) { 217 ui::Compositor* compositor) {
218 PerCompositorData* data = per_compositor_data_[compositor]; 218 PerCompositorData* data = per_compositor_data_[compositor];
219 if (!data) 219 if (!data)
220 data = CreatePerCompositorData(compositor); 220 data = CreatePerCompositorData(compositor);
221 221
222 scoped_refptr<ContextProviderCommandBuffer> context_provider; 222 scoped_refptr<ContextProviderCommandBuffer> context_provider;
223 223
224 CommandLine* command_line = CommandLine::ForCurrentProcess(); 224 CommandLine* command_line = CommandLine::ForCurrentProcess();
225 if (!command_line->HasSwitch(switches::kUIEnableSoftwareCompositing)) { 225 if (!command_line->HasSwitch(switches::kUIEnableSoftwareCompositing)) {
226 context_provider = ContextProviderCommandBuffer::Create( 226 context_provider = ContextProviderCommandBuffer::Create(
227 base::Bind(&GpuProcessTransportFactory::CreateContextCommon, 227 GpuProcessTransportFactory::CreateContextCommon(
228 base::Unretained(this), 228 data->swap_client->AsWeakPtr(),
229 data->swap_client->AsWeakPtr(), 229 data->surface_id));
230 data->surface_id));
231 } 230 }
232 if (!context_provider.get()) { 231 if (!context_provider.get()) {
233 if (ui::Compositor::WasInitializedWithThread()) { 232 if (ui::Compositor::WasInitializedWithThread()) {
234 LOG(FATAL) << "Failed to create UI context, but can't use software " 233 LOG(FATAL) << "Failed to create UI context, but can't use software "
235 " compositing with browser threaded compositing. Aborting."; 234 " compositing with browser threaded compositing. Aborting.";
236 } 235 }
237 236
238 scoped_ptr<SoftwareBrowserCompositorOutputSurface> surface = 237 scoped_ptr<SoftwareBrowserCompositorOutputSurface> surface =
239 SoftwareBrowserCompositorOutputSurface::Create( 238 SoftwareBrowserCompositorOutputSurface::Create(
240 CreateSoftwareOutputDevice(compositor)); 239 CreateSoftwareOutputDevice(compositor));
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 void GpuProcessTransportFactory::RemoveObserver( 383 void GpuProcessTransportFactory::RemoveObserver(
385 ImageTransportFactoryObserver* observer) { 384 ImageTransportFactoryObserver* observer) {
386 observer_list_.RemoveObserver(observer); 385 observer_list_.RemoveObserver(observer);
387 } 386 }
388 387
389 scoped_refptr<cc::ContextProvider> 388 scoped_refptr<cc::ContextProvider>
390 GpuProcessTransportFactory::OffscreenContextProviderForMainThread() { 389 GpuProcessTransportFactory::OffscreenContextProviderForMainThread() {
391 if (!shared_contexts_main_thread_.get() || 390 if (!shared_contexts_main_thread_.get() ||
392 shared_contexts_main_thread_->DestroyedOnMainThread()) { 391 shared_contexts_main_thread_->DestroyedOnMainThread()) {
393 shared_contexts_main_thread_ = ContextProviderCommandBuffer::Create( 392 shared_contexts_main_thread_ = ContextProviderCommandBuffer::Create(
394 base::Bind(&GpuProcessTransportFactory:: 393 GpuProcessTransportFactory::CreateOffscreenCommandBufferContext());
395 CreateOffscreenCommandBufferContext,
396 base::Unretained(this)));
397 if (shared_contexts_main_thread_) { 394 if (shared_contexts_main_thread_) {
398 shared_contexts_main_thread_->SetLostContextCallback(base::Bind( 395 shared_contexts_main_thread_->SetLostContextCallback(base::Bind(
399 &GpuProcessTransportFactory:: 396 &GpuProcessTransportFactory::
400 OnLostMainThreadSharedContextInsideCallback, 397 OnLostMainThreadSharedContextInsideCallback,
401 callback_factory_.GetWeakPtr())); 398 callback_factory_.GetWeakPtr()));
402 399
403 if (!shared_contexts_main_thread_->BindToCurrentThread()) 400 if (!shared_contexts_main_thread_->BindToCurrentThread())
404 shared_contexts_main_thread_ = NULL; 401 shared_contexts_main_thread_ = NULL;
405 } 402 }
406 } 403 }
407 return shared_contexts_main_thread_; 404 return shared_contexts_main_thread_;
408 } 405 }
409 406
410 scoped_refptr<cc::ContextProvider> 407 scoped_refptr<cc::ContextProvider>
411 GpuProcessTransportFactory::OffscreenContextProviderForCompositorThread() { 408 GpuProcessTransportFactory::OffscreenContextProviderForCompositorThread() {
412 if (!shared_contexts_compositor_thread_.get() || 409 if (!shared_contexts_compositor_thread_.get() ||
413 shared_contexts_compositor_thread_->DestroyedOnMainThread()) { 410 shared_contexts_compositor_thread_->DestroyedOnMainThread()) {
414 shared_contexts_compositor_thread_ = ContextProviderCommandBuffer::Create( 411 shared_contexts_compositor_thread_ = ContextProviderCommandBuffer::Create(
415 base::Bind(&GpuProcessTransportFactory:: 412 GpuProcessTransportFactory::CreateOffscreenCommandBufferContext());
416 CreateOffscreenCommandBufferContext,
417 base::Unretained(this)));
418 } 413 }
419 return shared_contexts_compositor_thread_; 414 return shared_contexts_compositor_thread_;
420 } 415 }
421 416
422 void GpuProcessTransportFactory::OnLostContext(ui::Compositor* compositor) { 417 void GpuProcessTransportFactory::OnLostContext(ui::Compositor* compositor) {
423 LOG(ERROR) << "Lost UI compositor context."; 418 LOG(ERROR) << "Lost UI compositor context.";
424 PerCompositorData* data = per_compositor_data_[compositor]; 419 PerCompositorData* data = per_compositor_data_[compositor];
425 DCHECK(data); 420 DCHECK(data);
426 421
427 // Prevent callbacks from other contexts in the same share group from 422 // Prevent callbacks from other contexts in the same share group from
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 shared_contexts_main_thread_ = NULL; 501 shared_contexts_main_thread_ = NULL;
507 502
508 scoped_ptr<GLHelper> old_helper(gl_helper_.release()); 503 scoped_ptr<GLHelper> old_helper(gl_helper_.release());
509 504
510 FOR_EACH_OBSERVER(ImageTransportFactoryObserver, 505 FOR_EACH_OBSERVER(ImageTransportFactoryObserver,
511 observer_list_, 506 observer_list_,
512 OnLostResources()); 507 OnLostResources());
513 } 508 }
514 509
515 } // namespace content 510 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698