OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "services/ui/public/cpp/context_provider.h" | |
6 | |
7 #include <stdint.h> | |
8 | |
9 #include "base/logging.h" | |
10 #include "cc/output/context_cache_controller.h" | |
11 #include "gpu/ipc/client/gpu_channel_host.h" | |
12 #include "services/ui/public/cpp/gles2_context.h" | |
13 | |
14 namespace ui { | |
15 | |
16 ContextProvider::ContextProvider( | |
17 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host) | |
18 : gpu_channel_host_(std::move(gpu_channel_host)) {} | |
19 | |
20 bool ContextProvider::BindToCurrentThread() { | |
21 context_ = GLES2Context::CreateOffscreenContext( | |
22 gpu_channel_host_, base::ThreadTaskRunnerHandle::Get()); | |
23 if (context_) { | |
24 cache_controller_.reset(new cc::ContextCacheController( | |
25 context_->context_support(), base::ThreadTaskRunnerHandle::Get())); | |
26 } | |
27 return !!context_; | |
28 } | |
29 | |
30 gpu::gles2::GLES2Interface* ContextProvider::ContextGL() { | |
31 return context_->interface(); | |
32 } | |
33 | |
34 gpu::ContextSupport* ContextProvider::ContextSupport() { | |
35 if (!context_) | |
36 return NULL; | |
37 return context_->context_support(); | |
38 } | |
39 | |
40 class GrContext* ContextProvider::GrContext() { | |
41 return NULL; | |
42 } | |
43 | |
44 cc::ContextCacheController* ContextProvider::CacheController() { | |
45 return cache_controller_.get(); | |
46 } | |
47 | |
48 void ContextProvider::InvalidateGrContext(uint32_t state) {} | |
49 | |
50 gpu::Capabilities ContextProvider::ContextCapabilities() { | |
51 return gpu::Capabilities(); | |
52 } | |
53 | |
54 base::Lock* ContextProvider::GetLock() { | |
55 // This context provider is not used on multiple threads. | |
56 NOTREACHED(); | |
57 return nullptr; | |
58 } | |
59 | |
60 ContextProvider::~ContextProvider() { | |
61 } | |
62 | |
63 } // namespace ui | |
OLD | NEW |