Chromium Code Reviews| 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 "services/native_viewport/native_viewport_impl.h" | 5 #include "services/native_viewport/native_viewport_impl.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "mojo/converters/geometry/geometry_type_converters.h" | 12 #include "mojo/converters/geometry/geometry_type_converters.h" |
| 13 #include "mojo/converters/native_viewport/surface_configuration_type_converters. h" | |
| 13 #include "mojo/public/cpp/application/interface_factory.h" | 14 #include "mojo/public/cpp/application/interface_factory.h" |
| 14 #include "services/gles2/gpu_state.h" | 15 #include "services/gles2/gpu_state.h" |
| 15 #include "services/native_viewport/platform_viewport_headless.h" | 16 #include "services/native_viewport/platform_viewport_headless.h" |
| 16 #include "ui/events/event.h" | 17 #include "ui/events/event.h" |
| 18 #include "ui/gl/gl_implementation.h" | |
| 19 #include "ui/gl/gl_surface.h" | |
| 20 #include "ui/gl/gl_surface_egl.h" | |
|
abarth-chromium
2015/06/09 00:30:21
Do we need gl_implementation.h and gl_surface_egl.
iansf
2015/06/09 01:52:04
Done.
| |
| 17 | 21 |
| 18 namespace native_viewport { | 22 namespace native_viewport { |
| 19 | 23 |
| 20 NativeViewportImpl::NativeViewportImpl( | 24 NativeViewportImpl::NativeViewportImpl( |
| 21 bool is_headless, | 25 bool is_headless, |
| 22 const scoped_refptr<gles2::GpuState>& gpu_state, | 26 const scoped_refptr<gles2::GpuState>& gpu_state, |
| 23 mojo::InterfaceRequest<mojo::NativeViewport> request) | 27 mojo::InterfaceRequest<mojo::NativeViewport> request) |
| 24 : is_headless_(is_headless), | 28 : is_headless_(is_headless), |
| 25 context_provider_(gpu_state), | 29 context_provider_(gpu_state), |
| 26 sent_metrics_(false), | 30 sent_metrics_(false), |
| 27 metrics_(mojo::ViewportMetrics::New()), | 31 metrics_(mojo::ViewportMetrics::New()), |
| 28 binding_(this, request.Pass()), | 32 binding_(this, request.Pass()), |
| 29 weak_factory_(this) { | 33 weak_factory_(this) { |
| 30 binding_.set_error_handler(this); | 34 binding_.set_error_handler(this); |
| 31 } | 35 } |
| 32 | 36 |
| 33 NativeViewportImpl::~NativeViewportImpl() { | 37 NativeViewportImpl::~NativeViewportImpl() { |
| 34 // Destroy the NativeViewport early on as it may call us back during | 38 // Destroy the NativeViewport early on as it may call us back during |
| 35 // destruction and we want to be in a known state. | 39 // destruction and we want to be in a known state. |
| 36 platform_viewport_.reset(); | 40 platform_viewport_.reset(); |
| 37 } | 41 } |
| 38 | 42 |
| 39 void NativeViewportImpl::Create(mojo::SizePtr size, | 43 void NativeViewportImpl::Create( |
| 40 const CreateCallback& callback) { | 44 mojo::SizePtr size, |
| 45 mojo::SurfaceConfigurationPtr requested_configuration, | |
| 46 const CreateCallback& callback) { | |
| 41 create_callback_ = callback; | 47 create_callback_ = callback; |
| 42 metrics_->size = size.Clone(); | 48 metrics_->size = size.Clone(); |
| 49 context_provider_.SetSurfaceConfiguration( | |
| 50 requested_configuration.To<gfx::SurfaceConfiguration>()); | |
| 43 if (is_headless_) | 51 if (is_headless_) |
| 44 platform_viewport_ = PlatformViewportHeadless::Create(this); | 52 platform_viewport_ = PlatformViewportHeadless::Create(this); |
| 45 else | 53 else |
| 46 platform_viewport_ = PlatformViewport::Create(this); | 54 platform_viewport_ = PlatformViewport::Create(this); |
| 47 platform_viewport_->Init(gfx::Rect(size.To<gfx::Size>())); | 55 platform_viewport_->Init(gfx::Rect(size.To<gfx::Size>())); |
| 48 } | 56 } |
| 49 | 57 |
| 50 void NativeViewportImpl::RequestMetrics( | 58 void NativeViewportImpl::RequestMetrics( |
| 51 const RequestMetricsCallback& callback) { | 59 const RequestMetricsCallback& callback) { |
| 52 if (!sent_metrics_) { | 60 if (!sent_metrics_) { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 void NativeViewportImpl::OnConnectionError() { | 163 void NativeViewportImpl::OnConnectionError() { |
| 156 binding_.set_error_handler(nullptr); | 164 binding_.set_error_handler(nullptr); |
| 157 delete this; | 165 delete this; |
| 158 } | 166 } |
| 159 | 167 |
| 160 void NativeViewportImpl::AckEvent(int32 pointer_id) { | 168 void NativeViewportImpl::AckEvent(int32 pointer_id) { |
| 161 pointers_waiting_on_ack_.erase(pointer_id); | 169 pointers_waiting_on_ack_.erase(pointer_id); |
| 162 } | 170 } |
| 163 | 171 |
| 164 } // namespace native_viewport | 172 } // namespace native_viewport |
| OLD | NEW |