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

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

Issue 1532923003: Improve GL helpers. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-7
Patch Set: rebase 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/gpu/gl_context_owner.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/shell.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(CommandBufferPtr command_buffer) : weak_factory_(this) {
16 context_ = MGLCreateContext( 16 context_ = MGLCreateContext(
17 MGL_API_VERSION_GLES2, 17 MGL_API_VERSION_GLES2,
18 command_buffer.PassInterface().PassHandle().release().value(), 18 command_buffer.PassInterface().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::Create(Shell* shell) { 28 base::WeakPtr<GLContext> GLContext::CreateOffscreen(
29 ApplicationConnector* connector) {
29 ServiceProviderPtr native_viewport; 30 ServiceProviderPtr native_viewport;
30 shell->ConnectToApplication("mojo:native_viewport_service", 31 connector->ConnectToApplication("mojo:native_viewport_service",
31 GetProxy(&native_viewport), nullptr); 32 GetProxy(&native_viewport), nullptr);
32 GpuPtr gpu_service; 33 GpuPtr gpu_service;
33 ConnectToService(native_viewport.get(), &gpu_service); 34 ConnectToService(native_viewport.get(), &gpu_service);
34 CommandBufferPtr command_buffer; 35 CommandBufferPtr command_buffer;
35 gpu_service->CreateOffscreenGLES2Context(GetProxy(&command_buffer)); 36 gpu_service->CreateOffscreenGLES2Context(GetProxy(&command_buffer));
36 return CreateFromCommandBuffer(command_buffer.Pass()); 37 return CreateFromCommandBuffer(command_buffer.Pass());
37 } 38 }
38 39
39 base::WeakPtr<GLContext> GLContext::CreateFromCommandBuffer( 40 base::WeakPtr<GLContext> GLContext::CreateFromCommandBuffer(
40 CommandBufferPtr command_buffer) { 41 CommandBufferPtr command_buffer) {
41 return (new GLContext(command_buffer.Pass()))->weak_factory_.GetWeakPtr(); 42 return (new GLContext(command_buffer.Pass()))->weak_factory_.GetWeakPtr();
(...skipping 21 matching lines...) Expand all
63 64
64 void GLContext::ContextLostThunk(void* self) { 65 void GLContext::ContextLostThunk(void* self) {
65 static_cast<GLContext*>(self)->OnContextLost(); 66 static_cast<GLContext*>(self)->OnContextLost();
66 } 67 }
67 68
68 void GLContext::OnContextLost() { 69 void GLContext::OnContextLost() {
69 FOR_EACH_OBSERVER(Observer, observers_, OnContextLost()); 70 FOR_EACH_OBSERVER(Observer, observers_, OnContextLost());
70 } 71 }
71 72
72 } // namespace mojo 73 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/gpu/gl_context.h ('k') | mojo/gpu/gl_context_owner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698