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

Side by Side Diff: blimp/client/support/compositor/blimp_context_provider.cc

Issue 2498053004: Add InProcessContextProvider and update InProcessCommandBuffer (Closed)
Patch Set: Revert experiments and fix android_webview Created 4 years, 1 month 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "blimp/client/support/compositor/blimp_context_provider.h" 5 #include "blimp/client/support/compositor/blimp_context_provider.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
11 #include "cc/output/context_cache_controller.h" 11 #include "cc/output/context_cache_controller.h"
12 #include "gpu/command_buffer/client/gles2_implementation.h" 12 #include "gpu/command_buffer/client/gles2_implementation.h"
13 #include "gpu/command_buffer/client/gles2_lib.h" 13 #include "gpu/command_buffer/client/gles2_lib.h"
14 #include "gpu/command_buffer/client/shared_memory_limits.h" 14 #include "gpu/command_buffer/client/shared_memory_limits.h"
15 #include "gpu/ipc/gl_in_process_context.h" 15 #include "gpu/ipc/gl_in_process_context.h"
16 #include "gpu/skia_bindings/grcontext_for_gles2_interface.h" 16 #include "gpu/skia_bindings/grcontext_for_gles2_interface.h"
17 #include "third_party/skia/include/gpu/GrContext.h" 17 #include "third_party/skia/include/gpu/GrContext.h"
18 #include "third_party/skia/include/gpu/gl/GrGLInterface.h" 18 #include "third_party/skia/include/gpu/gl/GrGLInterface.h"
19 19
20 namespace blimp { 20 namespace blimp {
21 namespace client { 21 namespace client {
22 22
23 // static 23 // static
24 scoped_refptr<BlimpContextProvider> BlimpContextProvider::Create( 24 scoped_refptr<BlimpContextProvider> BlimpContextProvider::Create(
25 gfx::AcceleratedWidget widget, 25 gpu::SurfaceHandle widget,
26 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) { 26 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) {
27 return new BlimpContextProvider(widget, gpu_memory_buffer_manager); 27 return new BlimpContextProvider(widget, gpu_memory_buffer_manager);
28 } 28 }
29 29
30 BlimpContextProvider::BlimpContextProvider( 30 BlimpContextProvider::BlimpContextProvider(
31 gfx::AcceleratedWidget widget, 31 gpu::SurfaceHandle widget,
32 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) { 32 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) {
33 context_thread_checker_.DetachFromThread(); 33 context_thread_checker_.DetachFromThread();
34 34
35 gpu::gles2::ContextCreationAttribHelper attribs_for_gles2; 35 gpu::gles2::ContextCreationAttribHelper attribs_for_gles2;
36 attribs_for_gles2.alpha_size = 8; 36 attribs_for_gles2.alpha_size = 8;
37 attribs_for_gles2.depth_size = 0; 37 attribs_for_gles2.depth_size = 0;
38 attribs_for_gles2.stencil_size = 0; 38 attribs_for_gles2.stencil_size = 0;
39 attribs_for_gles2.samples = 0; 39 attribs_for_gles2.samples = 0;
40 attribs_for_gles2.sample_buffers = 0; 40 attribs_for_gles2.sample_buffers = 0;
41 attribs_for_gles2.fail_if_major_perf_caveat = false; 41 attribs_for_gles2.fail_if_major_perf_caveat = false;
42 attribs_for_gles2.bind_generates_resource = false; 42 attribs_for_gles2.bind_generates_resource = false;
43 attribs_for_gles2.context_type = gpu::gles2::CONTEXT_TYPE_OPENGLES2; 43 attribs_for_gles2.context_type = gpu::gles2::CONTEXT_TYPE_OPENGLES2;
44 attribs_for_gles2.lose_context_when_out_of_memory = true; 44 attribs_for_gles2.lose_context_when_out_of_memory = true;
45 45
46 context_.reset(gpu::GLInProcessContext::Create( 46 context_.reset(gpu::GLInProcessContext::Create(
47 nullptr /* service */, nullptr /* surface */, 47 nullptr /* service */, nullptr /* surface */,
48 widget == gfx::kNullAcceleratedWidget /* is_offscreen */, widget, 48 widget == gpu::kNullSurfaceHandle /* is_offscreen */, widget,
49 nullptr /* share_context */, attribs_for_gles2, gpu::SharedMemoryLimits(), 49 nullptr /* share_context */, attribs_for_gles2, gpu::SharedMemoryLimits(),
50 gpu_memory_buffer_manager, nullptr /* memory_limits */, 50 gpu_memory_buffer_manager, nullptr /* memory_limits */,
51 base::ThreadTaskRunnerHandle::Get())); 51 base::ThreadTaskRunnerHandle::Get()));
52 context_->GetImplementation()->SetLostContextCallback( 52 context_->GetImplementation()->SetLostContextCallback(
53 base::Bind(&BlimpContextProvider::OnLostContext, base::Unretained(this))); 53 base::Bind(&BlimpContextProvider::OnLostContext, base::Unretained(this)));
54 cache_controller_.reset(new cc::ContextCacheController( 54 cache_controller_.reset(new cc::ContextCacheController(
55 context_->GetImplementation(), base::ThreadTaskRunnerHandle::Get())); 55 context_->GetImplementation(), base::ThreadTaskRunnerHandle::Get()));
56 } 56 }
57 57
58 BlimpContextProvider::~BlimpContextProvider() { 58 BlimpContextProvider::~BlimpContextProvider() {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 void BlimpContextProvider::OnLostContext() { 120 void BlimpContextProvider::OnLostContext() {
121 DCHECK(context_thread_checker_.CalledOnValidThread()); 121 DCHECK(context_thread_checker_.CalledOnValidThread());
122 if (!lost_context_callback_.is_null()) 122 if (!lost_context_callback_.is_null())
123 lost_context_callback_.Run(); 123 lost_context_callback_.Run();
124 if (gr_context_) 124 if (gr_context_)
125 gr_context_->OnLostContext(); 125 gr_context_->OnLostContext();
126 } 126 }
127 127
128 } // namespace client 128 } // namespace client
129 } // namespace blimp 129 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698