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

Side by Side Diff: mojo/cc/context_provider_mojo.cc

Issue 993253003: Modify build_gles2_cmd_buffer.py to generate a class that implements gpu::GLES2Interace and for eac… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months 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
« no previous file with comments | « mojo/cc/context_provider_mojo.h ('k') | mojo/gpu/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "third_party/mojo/src/mojo/public/cpp/environment/environment.h" 9 #include "third_party/mojo/src/mojo/public/cpp/environment/environment.h"
9 10
10 namespace mojo { 11 namespace mojo {
11 12
12 ContextProviderMojo::ContextProviderMojo( 13 ContextProviderMojo::ContextProviderMojo(
13 ScopedMessagePipeHandle command_buffer_handle) 14 ScopedMessagePipeHandle command_buffer_handle)
14 : command_buffer_handle_(command_buffer_handle.Pass()), 15 : command_buffer_handle_(command_buffer_handle.Pass()),
15 context_lost_(false) { 16 context_lost_(false) {
16 } 17 }
17 18
18 bool ContextProviderMojo::BindToCurrentThread() { 19 bool ContextProviderMojo::BindToCurrentThread() {
19 DCHECK(command_buffer_handle_.is_valid()); 20 DCHECK(command_buffer_handle_.is_valid());
20 context_ = MojoGLES2CreateContext(command_buffer_handle_.release().value(), 21 context_ = MojoGLES2CreateContext(command_buffer_handle_.release().value(),
21 &ContextLostThunk, 22 &ContextLostThunk,
22 this, 23 this,
23 Environment::GetDefaultAsyncWaiter()); 24 Environment::GetDefaultAsyncWaiter());
25 context_gl_.reset(new MojoGLES2Impl(context_));
24 return !!context_; 26 return !!context_;
25 } 27 }
26 28
27 gpu::gles2::GLES2Interface* ContextProviderMojo::ContextGL() { 29 gpu::gles2::GLES2Interface* ContextProviderMojo::ContextGL() {
28 if (!context_) 30 return context_gl_.get();
29 return NULL;
30 return static_cast<gpu::gles2::GLES2Interface*>(
31 MojoGLES2GetGLES2Interface(context_));
32 } 31 }
33 32
34 gpu::ContextSupport* ContextProviderMojo::ContextSupport() { 33 gpu::ContextSupport* ContextProviderMojo::ContextSupport() {
35 if (!context_) 34 if (!context_)
36 return NULL; 35 return NULL;
37 return static_cast<gpu::ContextSupport*>( 36 return static_cast<gpu::ContextSupport*>(
38 MojoGLES2GetContextSupport(context_)); 37 MojoGLES2GetContextSupport(context_));
39 } 38 }
40 39
41 class GrContext* ContextProviderMojo::GrContext() { return NULL; } 40 class GrContext* ContextProviderMojo::GrContext() { return NULL; }
42 41
43 cc::ContextProvider::Capabilities ContextProviderMojo::ContextCapabilities() { 42 cc::ContextProvider::Capabilities ContextProviderMojo::ContextCapabilities() {
44 return capabilities_; 43 return capabilities_;
45 } 44 }
46 45
47 void ContextProviderMojo::SetupLock() { 46 void ContextProviderMojo::SetupLock() {
48 } 47 }
49 48
50 base::Lock* ContextProviderMojo::GetLock() { 49 base::Lock* ContextProviderMojo::GetLock() {
51 return &context_lock_; 50 return &context_lock_;
52 } 51 }
53 52
54 bool ContextProviderMojo::IsContextLost() { 53 bool ContextProviderMojo::IsContextLost() {
55 return context_lost_; 54 return context_lost_;
56 } 55 }
57 bool ContextProviderMojo::DestroyedOnMainThread() { return !context_; } 56 bool ContextProviderMojo::DestroyedOnMainThread() { return !context_; }
58 57
59 ContextProviderMojo::~ContextProviderMojo() { 58 ContextProviderMojo::~ContextProviderMojo() {
59 context_gl_.reset();
60 if (context_) 60 if (context_)
61 MojoGLES2DestroyContext(context_); 61 MojoGLES2DestroyContext(context_);
62 } 62 }
63 63
64 void ContextProviderMojo::ContextLost() { 64 void ContextProviderMojo::ContextLost() {
65 context_lost_ = true; 65 context_lost_ = true;
66 } 66 }
67 67
68 } // namespace mojo 68 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/cc/context_provider_mojo.h ('k') | mojo/gpu/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698