OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "services/gfx/compositor/backend/gpu_rasterizer.h" | 5 #include "services/gfx/compositor/backend/gpu_rasterizer.h" |
6 | 6 |
7 #ifndef GL_GLEXT_PROTOTYPES | 7 #ifndef GL_GLEXT_PROTOTYPES |
8 #define GL_GLEXT_PROTOTYPES | 8 #define GL_GLEXT_PROTOTYPES |
9 #endif | 9 #endif |
10 | 10 |
11 #include <GLES2/gl2.h> | 11 #include <GLES2/gl2.h> |
12 #include <GLES2/gl2extmojo.h> | 12 #include <GLES2/gl2extmojo.h> |
13 #include <MGL/mgl.h> | 13 #include <MGL/mgl.h> |
14 #include <MGL/mgl_onscreen.h> | 14 #include <MGL/mgl_onscreen.h> |
| 15 #include <utility> |
15 | 16 |
16 #include "base/bind.h" | 17 #include "base/bind.h" |
17 #include "base/location.h" | 18 #include "base/location.h" |
18 #include "base/logging.h" | 19 #include "base/logging.h" |
19 #include "services/gfx/compositor/backend/vsync_scheduler.h" | 20 #include "services/gfx/compositor/backend/vsync_scheduler.h" |
20 #include "services/gfx/compositor/render/render_frame.h" | 21 #include "services/gfx/compositor/render/render_frame.h" |
21 | 22 |
22 namespace compositor { | 23 namespace compositor { |
23 | 24 |
24 GpuRasterizer::GpuRasterizer(mojo::ContextProviderPtr context_provider, | 25 GpuRasterizer::GpuRasterizer(mojo::ContextProviderPtr context_provider, |
(...skipping 18 matching lines...) Expand all Loading... |
43 | 44 |
44 void GpuRasterizer::CreateContext() { | 45 void GpuRasterizer::CreateContext() { |
45 mojo::ViewportParameterListenerPtr viewport_parameter_listener; | 46 mojo::ViewportParameterListenerPtr viewport_parameter_listener; |
46 viewport_parameter_listener_binding_.Bind( | 47 viewport_parameter_listener_binding_.Bind( |
47 GetProxy(&viewport_parameter_listener)); | 48 GetProxy(&viewport_parameter_listener)); |
48 context_provider_->Create( | 49 context_provider_->Create( |
49 viewport_parameter_listener.Pass(), | 50 viewport_parameter_listener.Pass(), |
50 base::Bind(&GpuRasterizer::InitContext, base::Unretained(this))); | 51 base::Bind(&GpuRasterizer::InitContext, base::Unretained(this))); |
51 } | 52 } |
52 | 53 |
53 void GpuRasterizer::InitContext(mojo::CommandBufferPtr command_buffer) { | 54 void GpuRasterizer::InitContext( |
| 55 mojo::InterfaceHandle<mojo::CommandBuffer> command_buffer) { |
54 DCHECK(!gl_context_); | 56 DCHECK(!gl_context_); |
55 DCHECK(!ganesh_context_); | 57 DCHECK(!ganesh_context_); |
56 DCHECK(!ganesh_surface_); | 58 DCHECK(!ganesh_surface_); |
57 | 59 |
58 if (!command_buffer) { | 60 if (!command_buffer) { |
59 LOG(ERROR) << "Could not create GL context."; | 61 LOG(ERROR) << "Could not create GL context."; |
60 PostErrorCallback(); | 62 PostErrorCallback(); |
61 return; | 63 return; |
62 } | 64 } |
63 | 65 |
64 gl_context_ = mojo::GLContext::CreateFromCommandBuffer(command_buffer.Pass()); | 66 gl_context_ = mojo::GLContext::CreateFromCommandBuffer( |
| 67 mojo::CommandBufferPtr::Create(std::move(command_buffer))); |
65 gl_context_->AddObserver(this); | 68 gl_context_->AddObserver(this); |
66 ganesh_context_.reset(new mojo::skia::GaneshContext(gl_context_)); | 69 ganesh_context_.reset(new mojo::skia::GaneshContext(gl_context_)); |
67 | 70 |
68 if (current_frame_) | 71 if (current_frame_) |
69 Draw(); | 72 Draw(); |
70 } | 73 } |
71 | 74 |
72 void GpuRasterizer::DestroyContext() { | 75 void GpuRasterizer::DestroyContext() { |
73 if (gl_context_) { | 76 if (gl_context_) { |
74 scheduler_->Stop(); | 77 scheduler_->Stop(); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 | 165 |
163 // Swap buffers. | 166 // Swap buffers. |
164 MGLSwapBuffers(); | 167 MGLSwapBuffers(); |
165 } | 168 } |
166 | 169 |
167 void GpuRasterizer::PostErrorCallback() { | 170 void GpuRasterizer::PostErrorCallback() { |
168 task_runner_->PostTask(FROM_HERE, error_callback_); | 171 task_runner_->PostTask(FROM_HERE, error_callback_); |
169 } | 172 } |
170 | 173 |
171 } // namespace compositor | 174 } // namespace compositor |
OLD | NEW |