OLD | NEW |
---|---|
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 "services/ui/public/cpp/context_provider.h" | 5 #include "services/ui/public/cpp/context_provider.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "cc/output/context_cache_controller.h" | |
10 #include "gpu/ipc/client/gpu_channel_host.h" | 11 #include "gpu/ipc/client/gpu_channel_host.h" |
11 #include "services/ui/public/cpp/gles2_context.h" | 12 #include "services/ui/public/cpp/gles2_context.h" |
12 | 13 |
13 namespace ui { | 14 namespace ui { |
14 | 15 |
15 ContextProvider::ContextProvider( | 16 ContextProvider::ContextProvider( |
16 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host) | 17 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host) |
17 : gpu_channel_host_(std::move(gpu_channel_host)) {} | 18 : gpu_channel_host_(std::move(gpu_channel_host)) {} |
18 | 19 |
19 bool ContextProvider::BindToCurrentThread() { | 20 bool ContextProvider::BindToCurrentThread() { |
20 context_ = GLES2Context::CreateOffscreenContext(gpu_channel_host_); | 21 context_ = GLES2Context::CreateOffscreenContext(gpu_channel_host_); |
22 cache_controller_.reset( | |
23 new cc::ContextCacheController(context_->context_support())); | |
21 return !!context_; | 24 return !!context_; |
danakj
2016/08/26 23:49:09
This suggests context_ can be null. Either your co
ericrk
2016/08/29 22:43:23
Yeah, it can be null, good point.
| |
22 } | 25 } |
23 | 26 |
24 gpu::gles2::GLES2Interface* ContextProvider::ContextGL() { | 27 gpu::gles2::GLES2Interface* ContextProvider::ContextGL() { |
25 return context_->interface(); | 28 return context_->interface(); |
26 } | 29 } |
27 | 30 |
28 gpu::ContextSupport* ContextProvider::ContextSupport() { | 31 gpu::ContextSupport* ContextProvider::ContextSupport() { |
29 if (!context_) | 32 if (!context_) |
30 return NULL; | 33 return NULL; |
31 return context_->context_support(); | 34 return context_->context_support(); |
32 } | 35 } |
33 | 36 |
34 class GrContext* ContextProvider::GrContext() { | 37 class GrContext* ContextProvider::GrContext() { |
35 return NULL; | 38 return NULL; |
36 } | 39 } |
37 | 40 |
41 cc::ContextCacheController* ContextProvider::CacheController() { | |
42 return cache_controller_.get(); | |
43 } | |
44 | |
38 void ContextProvider::InvalidateGrContext(uint32_t state) {} | 45 void ContextProvider::InvalidateGrContext(uint32_t state) {} |
39 | 46 |
40 gpu::Capabilities ContextProvider::ContextCapabilities() { | 47 gpu::Capabilities ContextProvider::ContextCapabilities() { |
41 gpu::Capabilities capabilities; | 48 gpu::Capabilities capabilities; |
42 // Enabled the CHROMIUM_image extension to use GpuMemoryBuffers. The | 49 // Enabled the CHROMIUM_image extension to use GpuMemoryBuffers. The |
43 // implementation of which is used in CommandBufferDriver. | 50 // implementation of which is used in CommandBufferDriver. |
44 capabilities.image = true; | 51 capabilities.image = true; |
45 return capabilities; | 52 return capabilities; |
46 } | 53 } |
47 | 54 |
48 base::Lock* ContextProvider::GetLock() { | 55 base::Lock* ContextProvider::GetLock() { |
49 // This context provider is not used on multiple threads. | 56 // This context provider is not used on multiple threads. |
50 NOTREACHED(); | 57 NOTREACHED(); |
51 return nullptr; | 58 return nullptr; |
52 } | 59 } |
53 | 60 |
54 ContextProvider::~ContextProvider() { | 61 ContextProvider::~ContextProvider() { |
55 } | 62 } |
56 | 63 |
57 } // namespace ui | 64 } // namespace ui |
OLD | NEW |