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

Side by Side Diff: mojo/gpu/gl_context.cc

Issue 1682113003: Mojo C++ bindings: Generate InterfaceHandle<> instead of InterfacePtr<>. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebase ontop of master, address trung's comments Created 4 years, 10 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/gpu/gl_context.h ('k') | mojo/public/cpp/application/application_impl.h » ('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/gpu/gl_context.h" 5 #include "mojo/gpu/gl_context.h"
6 6
7 #include "mojo/public/cpp/application/connect.h" 7 #include "mojo/public/cpp/application/connect.h"
8 #include "mojo/public/interfaces/application/application_connector.mojom.h" 8 #include "mojo/public/interfaces/application/application_connector.mojom.h"
9 #include "mojo/services/gpu/interfaces/gpu.mojom.h" 9 #include "mojo/services/gpu/interfaces/gpu.mojom.h"
10 10
11 namespace mojo { 11 namespace mojo {
12 12
13 GLContext::Observer::~Observer() {} 13 GLContext::Observer::~Observer() {}
14 14
15 GLContext::GLContext(CommandBufferPtr command_buffer) : weak_factory_(this) { 15 GLContext::GLContext(InterfaceHandle<CommandBuffer> command_buffer)
16 context_ = MGLCreateContext( 16 : weak_factory_(this) {
17 MGL_API_VERSION_GLES2, 17 context_ = MGLCreateContext(MGL_API_VERSION_GLES2,
18 command_buffer.PassInterfaceHandle().PassHandle().release().value(), 18 command_buffer.PassHandle().release().value(),
19 MGL_NO_CONTEXT, &ContextLostThunk, this, 19 MGL_NO_CONTEXT, &ContextLostThunk, this,
20 Environment::GetDefaultAsyncWaiter()); 20 Environment::GetDefaultAsyncWaiter());
21 DCHECK(context_ != MGL_NO_CONTEXT); 21 DCHECK(context_ != MGL_NO_CONTEXT);
22 } 22 }
23 23
24 GLContext::~GLContext() { 24 GLContext::~GLContext() {
25 MGLDestroyContext(context_); 25 MGLDestroyContext(context_);
26 } 26 }
27 27
28 base::WeakPtr<GLContext> GLContext::CreateOffscreen( 28 base::WeakPtr<GLContext> GLContext::CreateOffscreen(
29 ApplicationConnector* connector) { 29 ApplicationConnector* connector) {
30 ServiceProviderPtr native_viewport; 30 ServiceProviderPtr native_viewport;
31 connector->ConnectToApplication("mojo:native_viewport_service", 31 connector->ConnectToApplication("mojo:native_viewport_service",
32 GetProxy(&native_viewport), nullptr); 32 GetProxy(&native_viewport), nullptr);
33 GpuPtr gpu_service; 33 GpuPtr gpu_service;
34 ConnectToService(native_viewport.get(), &gpu_service); 34 ConnectToService(native_viewport.get(), &gpu_service);
35 CommandBufferPtr command_buffer; 35 InterfaceHandle<CommandBuffer> command_buffer;
36 gpu_service->CreateOffscreenGLES2Context(GetProxy(&command_buffer)); 36 gpu_service->CreateOffscreenGLES2Context(GetProxy(&command_buffer));
37 return CreateFromCommandBuffer(command_buffer.Pass()); 37 return CreateFromCommandBuffer(command_buffer.Pass());
38 } 38 }
39 39
40 base::WeakPtr<GLContext> GLContext::CreateFromCommandBuffer( 40 base::WeakPtr<GLContext> GLContext::CreateFromCommandBuffer(
41 CommandBufferPtr command_buffer) { 41 InterfaceHandle<CommandBuffer> command_buffer) {
42 return (new GLContext(command_buffer.Pass()))->weak_factory_.GetWeakPtr(); 42 return (new GLContext(command_buffer.Pass()))->weak_factory_.GetWeakPtr();
43 } 43 }
44 44
45 void GLContext::MakeCurrent() { 45 void GLContext::MakeCurrent() {
46 MGLMakeCurrent(context_); 46 MGLMakeCurrent(context_);
47 } 47 }
48 48
49 bool GLContext::IsCurrent() { 49 bool GLContext::IsCurrent() {
50 return context_ == MGLGetCurrentContext(); 50 return context_ == MGLGetCurrentContext();
51 } 51 }
(...skipping 12 matching lines...) Expand all
64 64
65 void GLContext::ContextLostThunk(void* self) { 65 void GLContext::ContextLostThunk(void* self) {
66 static_cast<GLContext*>(self)->OnContextLost(); 66 static_cast<GLContext*>(self)->OnContextLost();
67 } 67 }
68 68
69 void GLContext::OnContextLost() { 69 void GLContext::OnContextLost() {
70 FOR_EACH_OBSERVER(Observer, observers_, OnContextLost()); 70 FOR_EACH_OBSERVER(Observer, observers_, OnContextLost());
71 } 71 }
72 72
73 } // namespace mojo 73 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/gpu/gl_context.h ('k') | mojo/public/cpp/application/application_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698