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 if (context_) { |
| 23 cache_controller_.reset( |
| 24 new cc::ContextCacheController(context_->context_support())); |
| 25 } |
21 return !!context_; | 26 return !!context_; |
22 } | 27 } |
23 | 28 |
24 gpu::gles2::GLES2Interface* ContextProvider::ContextGL() { | 29 gpu::gles2::GLES2Interface* ContextProvider::ContextGL() { |
25 return context_->interface(); | 30 return context_->interface(); |
26 } | 31 } |
27 | 32 |
28 gpu::ContextSupport* ContextProvider::ContextSupport() { | 33 gpu::ContextSupport* ContextProvider::ContextSupport() { |
29 if (!context_) | 34 if (!context_) |
30 return NULL; | 35 return NULL; |
31 return context_->context_support(); | 36 return context_->context_support(); |
32 } | 37 } |
33 | 38 |
34 class GrContext* ContextProvider::GrContext() { | 39 class GrContext* ContextProvider::GrContext() { |
35 return NULL; | 40 return NULL; |
36 } | 41 } |
37 | 42 |
| 43 cc::ContextCacheController* ContextProvider::CacheController() { |
| 44 return cache_controller_.get(); |
| 45 } |
| 46 |
38 void ContextProvider::InvalidateGrContext(uint32_t state) {} | 47 void ContextProvider::InvalidateGrContext(uint32_t state) {} |
39 | 48 |
40 gpu::Capabilities ContextProvider::ContextCapabilities() { | 49 gpu::Capabilities ContextProvider::ContextCapabilities() { |
41 gpu::Capabilities capabilities; | 50 gpu::Capabilities capabilities; |
42 // Enabled the CHROMIUM_image extension to use GpuMemoryBuffers. The | 51 // Enabled the CHROMIUM_image extension to use GpuMemoryBuffers. The |
43 // implementation of which is used in CommandBufferDriver. | 52 // implementation of which is used in CommandBufferDriver. |
44 capabilities.image = true; | 53 capabilities.image = true; |
45 return capabilities; | 54 return capabilities; |
46 } | 55 } |
47 | 56 |
48 base::Lock* ContextProvider::GetLock() { | 57 base::Lock* ContextProvider::GetLock() { |
49 // This context provider is not used on multiple threads. | 58 // This context provider is not used on multiple threads. |
50 NOTREACHED(); | 59 NOTREACHED(); |
51 return nullptr; | 60 return nullptr; |
52 } | 61 } |
53 | 62 |
54 ContextProvider::~ContextProvider() { | 63 ContextProvider::~ContextProvider() { |
55 } | 64 } |
56 | 65 |
57 } // namespace ui | 66 } // namespace ui |
OLD | NEW |