| OLD | NEW |
| 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(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.PassInterfaceHandle().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( |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |