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 "mojo/cc/context_provider_mojo.h" | 5 #include "mojo/cc/context_provider_mojo.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "mojo/gpu/mojo_gles2_impl_autogen.h" | 8 #include "mojo/gpu/mojo_gles2_impl_autogen.h" |
9 #include "third_party/mojo/src/mojo/public/cpp/environment/environment.h" | 9 #include "third_party/mojo/src/mojo/public/cpp/environment/environment.h" |
10 | 10 |
11 namespace mojo { | 11 namespace mojo { |
12 | 12 |
13 ContextProviderMojo::ContextProviderMojo( | 13 ContextProviderMojo::ContextProviderMojo( |
14 ScopedMessagePipeHandle command_buffer_handle) | 14 ScopedMessagePipeHandle command_buffer_handle) |
15 : command_buffer_handle_(command_buffer_handle.Pass()), | 15 : command_buffer_handle_(command_buffer_handle.Pass()) { |
16 context_lost_(false) { | |
17 } | 16 } |
18 | 17 |
19 bool ContextProviderMojo::BindToCurrentThread() { | 18 bool ContextProviderMojo::BindToCurrentThread() { |
20 DCHECK(command_buffer_handle_.is_valid()); | 19 DCHECK(command_buffer_handle_.is_valid()); |
21 context_ = MojoGLES2CreateContext(command_buffer_handle_.release().value(), | 20 context_ = MojoGLES2CreateContext(command_buffer_handle_.release().value(), |
22 &ContextLostThunk, | 21 &ContextLostThunk, |
23 this, | 22 this, |
24 Environment::GetDefaultAsyncWaiter()); | 23 Environment::GetDefaultAsyncWaiter()); |
25 context_gl_.reset(new MojoGLES2Impl(context_)); | 24 context_gl_.reset(new MojoGLES2Impl(context_)); |
26 return !!context_; | 25 return !!context_; |
(...skipping 19 matching lines...) Expand all Loading... |
46 return capabilities_; | 45 return capabilities_; |
47 } | 46 } |
48 | 47 |
49 void ContextProviderMojo::SetupLock() { | 48 void ContextProviderMojo::SetupLock() { |
50 } | 49 } |
51 | 50 |
52 base::Lock* ContextProviderMojo::GetLock() { | 51 base::Lock* ContextProviderMojo::GetLock() { |
53 return &context_lock_; | 52 return &context_lock_; |
54 } | 53 } |
55 | 54 |
56 bool ContextProviderMojo::IsContextLost() { | |
57 return context_lost_; | |
58 } | |
59 bool ContextProviderMojo::DestroyedOnMainThread() { return !context_; } | 55 bool ContextProviderMojo::DestroyedOnMainThread() { return !context_; } |
60 | 56 |
61 ContextProviderMojo::~ContextProviderMojo() { | 57 ContextProviderMojo::~ContextProviderMojo() { |
62 context_gl_.reset(); | 58 context_gl_.reset(); |
63 if (context_) | 59 if (context_) |
64 MojoGLES2DestroyContext(context_); | 60 MojoGLES2DestroyContext(context_); |
65 } | 61 } |
66 | 62 |
67 void ContextProviderMojo::ContextLost() { | 63 void ContextProviderMojo::ContextLost() { |
68 context_lost_ = true; | |
69 } | 64 } |
70 | 65 |
71 } // namespace mojo | 66 } // namespace mojo |
OLD | NEW |