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

Side by Side Diff: components/surfaces/surfaces_context_provider.cc

Issue 1138293002: core_services: Add mojo:surfaces_service to core_services. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
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 "components/surfaces/context_provider_mojo.h" 5 #include "components/surfaces/surfaces_context_provider.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "third_party/mojo/src/mojo/public/cpp/environment/environment.h" 8 #include "third_party/mojo/src/mojo/public/cpp/environment/environment.h"
9 9
10 namespace mojo { 10 namespace surfaces {
11 11
12 ContextProviderMojo::ContextProviderMojo( 12 SurfacesContextProvider::SurfacesContextProvider(
13 ScopedMessagePipeHandle command_buffer_handle) 13 mojo::ScopedMessagePipeHandle command_buffer_handle)
14 : command_buffer_handle_(command_buffer_handle.Pass()), 14 : command_buffer_handle_(command_buffer_handle.Pass()),
15 context_(nullptr), 15 context_(nullptr),
16 context_lost_(false) { 16 context_lost_(false) {
17 } 17 }
18 18
19 bool ContextProviderMojo::BindToCurrentThread() { 19 bool SurfacesContextProvider::BindToCurrentThread() {
20 DCHECK(command_buffer_handle_.is_valid()); 20 DCHECK(command_buffer_handle_.is_valid());
21 context_ = MojoGLES2CreateContext(command_buffer_handle_.release().value(), 21 context_ = MojoGLES2CreateContext(command_buffer_handle_.release().value(),
22 &ContextLostThunk, this, 22 &ContextLostThunk, this,
23 Environment::GetDefaultAsyncWaiter()); 23 mojo::Environment::GetDefaultAsyncWaiter());
24 DCHECK(context_); 24 DCHECK(context_);
25 return !!context_; 25 return !!context_;
26 } 26 }
27 27
28 gpu::gles2::GLES2Interface* ContextProviderMojo::ContextGL() { 28 gpu::gles2::GLES2Interface* SurfacesContextProvider::ContextGL() {
29 if (!context_) 29 if (!context_)
30 return nullptr; 30 return nullptr;
31 return static_cast<gpu::gles2::GLES2Interface*>( 31 return static_cast<gpu::gles2::GLES2Interface*>(
32 MojoGLES2GetGLES2Interface(context_)); 32 MojoGLES2GetGLES2Interface(context_));
33 } 33 }
34 34
35 gpu::ContextSupport* ContextProviderMojo::ContextSupport() { 35 gpu::ContextSupport* SurfacesContextProvider::ContextSupport() {
36 if (!context_) 36 if (!context_)
37 return nullptr; 37 return nullptr;
38 return static_cast<gpu::ContextSupport*>( 38 return static_cast<gpu::ContextSupport*>(
39 MojoGLES2GetContextSupport(context_)); 39 MojoGLES2GetContextSupport(context_));
40 } 40 }
41 41
42 class GrContext* ContextProviderMojo::GrContext() { 42 class GrContext* SurfacesContextProvider::GrContext() {
43 return NULL; 43 return NULL;
44 } 44 }
45 45
46 void ContextProviderMojo::InvalidateGrContext(uint32_t state) { 46 void SurfacesContextProvider::InvalidateGrContext(uint32_t state) {
47 } 47 }
48 48
49 cc::ContextProvider::Capabilities ContextProviderMojo::ContextCapabilities() { 49 cc::ContextProvider::Capabilities
50 SurfacesContextProvider::ContextCapabilities() {
50 return capabilities_; 51 return capabilities_;
51 } 52 }
52 53
53 void ContextProviderMojo::SetupLock() { 54 void SurfacesContextProvider::SetupLock() {
54 } 55 }
55 56
56 base::Lock* ContextProviderMojo::GetLock() { 57 base::Lock* SurfacesContextProvider::GetLock() {
57 return &context_lock_; 58 return &context_lock_;
58 } 59 }
59 60
60 bool ContextProviderMojo::IsContextLost() { 61 bool SurfacesContextProvider::IsContextLost() {
61 return context_lost_; 62 return context_lost_;
62 } 63 }
63 bool ContextProviderMojo::DestroyedOnMainThread() { 64 bool SurfacesContextProvider::DestroyedOnMainThread() {
64 return !context_; 65 return !context_;
65 } 66 }
66 67
67 void ContextProviderMojo::SetLostContextCallback( 68 void SurfacesContextProvider::SetLostContextCallback(
68 const LostContextCallback& lost_context_callback) { 69 const LostContextCallback& lost_context_callback) {
69 lost_context_callback_ = lost_context_callback; 70 lost_context_callback_ = lost_context_callback;
70 } 71 }
71 72
72 ContextProviderMojo::~ContextProviderMojo() { 73 SurfacesContextProvider::~SurfacesContextProvider() {
73 if (context_) 74 if (context_)
74 MojoGLES2DestroyContext(context_); 75 MojoGLES2DestroyContext(context_);
75 } 76 }
76 77
77 void ContextProviderMojo::ContextLost() { 78 void SurfacesContextProvider::ContextLost() {
78 context_lost_ = true; 79 context_lost_ = true;
79 if (!lost_context_callback_.is_null()) 80 if (!lost_context_callback_.is_null())
80 lost_context_callback_.Run(); 81 lost_context_callback_.Run();
81 } 82 }
82 83
83 } // namespace mojo 84 } // namespace surfaces
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698