| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/native_viewport/platform_viewport.h" | 5 #include "components/native_viewport/platform_viewport.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "mojo/converters/geometry/geometry_type_converters.h" | 8 #include "mojo/converters/geometry/geometry_type_converters.h" |
| 9 #include "mojo/converters/input_events/input_events_type_converters.h" | 9 #include "mojo/converters/input_events/input_events_type_converters.h" |
| 10 #include "ui/events/event.h" | 10 #include "ui/events/event.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 ~PlatformViewportWin() { | 34 ~PlatformViewportWin() { |
| 35 // Destroy the platform-window while |this| is still alive. | 35 // Destroy the platform-window while |this| is still alive. |
| 36 platform_window_.reset(); | 36 platform_window_.reset(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 private: | 39 private: |
| 40 // Overridden from PlatformViewport: | 40 // Overridden from PlatformViewport: |
| 41 void Init(const gfx::Rect& bounds) override { | 41 void Init(const gfx::Rect& bounds) override { |
| 42 metrics_ = mojo::ViewportMetrics::New(); | 42 metrics_ = mojo::ViewportMetrics::New(); |
| 43 // TODO(sky): make density real. |
| 44 metrics_->device_pixel_ratio = 1.f; |
| 43 metrics_->size = mojo::Size::From(bounds.size()); | 45 metrics_->size = mojo::Size::From(bounds.size()); |
| 44 platform_window_.reset(new ui::WinWindow(this, bounds)); | 46 platform_window_.reset(new ui::WinWindow(this, bounds)); |
| 45 } | 47 } |
| 46 | 48 |
| 47 void Show() override { | 49 void Show() override { |
| 48 platform_window_->Show(); | 50 platform_window_->Show(); |
| 49 } | 51 } |
| 50 | 52 |
| 51 void Hide() override { | 53 void Hide() override { |
| 52 platform_window_->Hide(); | 54 platform_window_->Hide(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 } | 112 } |
| 111 | 113 |
| 112 void OnWindowStateChanged(ui::PlatformWindowState state) override { | 114 void OnWindowStateChanged(ui::PlatformWindowState state) override { |
| 113 } | 115 } |
| 114 | 116 |
| 115 void OnLostCapture() override { | 117 void OnLostCapture() override { |
| 116 } | 118 } |
| 117 | 119 |
| 118 void OnAcceleratedWidgetAvailable( | 120 void OnAcceleratedWidgetAvailable( |
| 119 gfx::AcceleratedWidget widget) override { | 121 gfx::AcceleratedWidget widget) override { |
| 120 delegate_->OnAcceleratedWidgetAvailable(widget); | 122 delegate_->OnAcceleratedWidgetAvailable(widget, |
| 123 metrics_->device_pixel_ratio); |
| 121 } | 124 } |
| 122 | 125 |
| 123 void OnActivationChanged(bool active) override {} | 126 void OnActivationChanged(bool active) override {} |
| 124 | 127 |
| 125 scoped_ptr<ui::PlatformWindow> platform_window_; | 128 scoped_ptr<ui::PlatformWindow> platform_window_; |
| 126 Delegate* delegate_; | 129 Delegate* delegate_; |
| 127 mojo::ViewportMetricsPtr metrics_; | 130 mojo::ViewportMetricsPtr metrics_; |
| 128 | 131 |
| 129 DISALLOW_COPY_AND_ASSIGN(PlatformViewportWin); | 132 DISALLOW_COPY_AND_ASSIGN(PlatformViewportWin); |
| 130 }; | 133 }; |
| 131 | 134 |
| 132 // static | 135 // static |
| 133 scoped_ptr<PlatformViewport> PlatformViewport::Create(Delegate* delegate) { | 136 scoped_ptr<PlatformViewport> PlatformViewport::Create(Delegate* delegate) { |
| 134 return scoped_ptr<PlatformViewport>(new PlatformViewportWin(delegate)).Pass(); | 137 return scoped_ptr<PlatformViewport>(new PlatformViewportWin(delegate)).Pass(); |
| 135 } | 138 } |
| 136 | 139 |
| 137 } // namespace native_viewport | 140 } // namespace native_viewport |
| OLD | NEW |