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

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

Issue 1307883004: Use C OpenGL interface in mojo::GLContext (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 4 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/mojo_gles2_impl_autogen.cc » ('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/shell.mojom.h"
9 #include "mojo/services/gpu/public/interfaces/gpu.mojom.h" 9 #include "mojo/services/gpu/public/interfaces/gpu.mojom.h"
10 #include "mojo/gpu/mojo_gles2_impl_autogen.h"
10 11
11 namespace mojo { 12 namespace mojo {
12 13
13 GLContext::Observer::~Observer() { 14 GLContext::Observer::~Observer() {
14 } 15 }
15 16
16 GLContext::GLContext(Shell* shell) : weak_factory_(this) { 17 GLContext::GLContext(Shell* shell) : weak_factory_(this) {
17 ServiceProviderPtr native_viewport; 18 ServiceProviderPtr native_viewport;
18 shell->ConnectToApplication("mojo:native_viewport_service", 19 shell->ConnectToApplication("mojo:native_viewport_service",
19 GetProxy(&native_viewport), nullptr); 20 GetProxy(&native_viewport), nullptr);
20 GpuPtr gpu_service; 21 GpuPtr gpu_service;
21 ConnectToService(native_viewport.get(), &gpu_service); 22 ConnectToService(native_viewport.get(), &gpu_service);
22 CommandBufferPtr command_buffer; 23 CommandBufferPtr command_buffer;
23 gpu_service->CreateOffscreenGLES2Context(GetProxy(&command_buffer)); 24 gpu_service->CreateOffscreenGLES2Context(GetProxy(&command_buffer));
24 context_ = MojoGLES2CreateContext( 25 context_ = MojoGLES2CreateContext(
25 command_buffer.PassInterface().PassHandle().release().value(), 26 command_buffer.PassInterface().PassHandle().release().value(),
26 &ContextLostThunk, this, Environment::GetDefaultAsyncWaiter()); 27 &ContextLostThunk, this, Environment::GetDefaultAsyncWaiter());
27 gl_ = static_cast<gpu::gles2::GLES2Interface*>( 28 gl_impl_.reset(new MojoGLES2Impl(context_));
28 MojoGLES2GetGLES2Interface(context_));
29 } 29 }
30 30
31 GLContext::~GLContext() { 31 GLContext::~GLContext() {
32 MojoGLES2DestroyContext(context_); 32 MojoGLES2DestroyContext(context_);
33 } 33 }
34 34
35 base::WeakPtr<GLContext> GLContext::Create(Shell* shell) { 35 base::WeakPtr<GLContext> GLContext::Create(Shell* shell) {
36 return (new GLContext(shell))->weak_factory_.GetWeakPtr(); 36 return (new GLContext(shell))->weak_factory_.GetWeakPtr();
37 } 37 }
38 38
39 void GLContext::MakeCurrent() { 39 void GLContext::MakeCurrent() {
40 MojoGLES2MakeCurrent(context_); 40 MojoGLES2MakeCurrent(context_);
41 } 41 }
42 42
43 void GLContext::Destroy() { 43 void GLContext::Destroy() {
44 delete this; 44 delete this;
45 } 45 }
46 46
47 gpu::gles2::GLES2Interface* GLContext::gl() const {
48 return gl_impl_.get();
viettrungluu 2015/08/24 17:51:06 It should be OK to inline this.
49 }
50
47 void GLContext::AddObserver(Observer* observer) { 51 void GLContext::AddObserver(Observer* observer) {
48 observers_.AddObserver(observer); 52 observers_.AddObserver(observer);
49 } 53 }
50 54
51 void GLContext::RemoveObserver(Observer* observer) { 55 void GLContext::RemoveObserver(Observer* observer) {
52 observers_.RemoveObserver(observer); 56 observers_.RemoveObserver(observer);
53 } 57 }
54 58
55 void GLContext::ContextLostThunk(void* self) { 59 void GLContext::ContextLostThunk(void* self) {
56 static_cast<GLContext*>(self)->OnContextLost(); 60 static_cast<GLContext*>(self)->OnContextLost();
57 } 61 }
58 62
59 void GLContext::OnContextLost() { 63 void GLContext::OnContextLost() {
60 FOR_EACH_OBSERVER(Observer, observers_, OnContextLost()); 64 FOR_EACH_OBSERVER(Observer, observers_, OnContextLost());
61 } 65 }
62 66
63 } // namespace mojo 67 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/gpu/gl_context.h ('k') | mojo/gpu/mojo_gles2_impl_autogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698