Fix OOP <webview> resize and autosize.
[chromium-blink-merge.git] / ui / ozone / platform / cast / ozone_platform_cast.cc
blobeb91158b203edec0bf96ed022c0cb83f6df7883d
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
3 // found in the LICENSE file.
5 #include "ui/ozone/platform/cast/ozone_platform_cast.h"
7 #include "base/command_line.h"
8 #include "chromecast/public/cast_egl_platform.h"
9 #include "chromecast/public/cast_egl_platform_shlib.h"
10 #include "ui/ozone/common/native_display_delegate_ozone.h"
11 #include "ui/ozone/platform/cast/gpu_platform_support_cast.h"
12 #include "ui/ozone/platform/cast/overlay_manager_cast.h"
13 #include "ui/ozone/platform/cast/platform_window_cast.h"
14 #include "ui/ozone/platform/cast/surface_factory_cast.h"
15 #include "ui/ozone/public/cursor_factory_ozone.h"
16 #include "ui/ozone/public/gpu_platform_support_host.h"
17 #include "ui/ozone/public/input_controller.h"
18 #include "ui/ozone/public/ozone_platform.h"
19 #include "ui/ozone/public/system_input_injector.h"
21 using chromecast::CastEglPlatform;
23 namespace ui {
24 namespace {
26 // Ozone platform implementation for Cast. Implements functionality
27 // common to all Cast implementations:
28 // - Always one window with window size equal to display size
29 // - No input, cursor support
30 // - Relinquish GPU resources flow for switching to external applications
31 // Meanwhile, platform-specific implementation details are abstracted out
32 // to the CastEglPlatform interface.
33 class OzonePlatformCast : public OzonePlatform {
34 public:
35 explicit OzonePlatformCast(scoped_ptr<CastEglPlatform> egl_platform)
36 : egl_platform_(egl_platform.Pass()) {}
37 ~OzonePlatformCast() override {}
39 // OzonePlatform implementation:
40 SurfaceFactoryOzone* GetSurfaceFactoryOzone() override {
41 return surface_factory_.get();
43 OverlayManagerOzone* GetOverlayManager() override {
44 return overlay_manager_.get();
46 CursorFactoryOzone* GetCursorFactoryOzone() override {
47 return cursor_factory_.get();
49 InputController* GetInputController() override {
50 return input_controller_.get();
52 GpuPlatformSupport* GetGpuPlatformSupport() override {
53 return gpu_platform_support_.get();
55 GpuPlatformSupportHost* GetGpuPlatformSupportHost() override {
56 return gpu_platform_support_host_.get();
58 scoped_ptr<SystemInputInjector> CreateSystemInputInjector() override {
59 return nullptr; // no input injection support
61 scoped_ptr<PlatformWindow> CreatePlatformWindow(
62 PlatformWindowDelegate* delegate,
63 const gfx::Rect& bounds) override {
64 return make_scoped_ptr<PlatformWindow>(
65 new PlatformWindowCast(delegate, bounds));
67 scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() override {
68 return make_scoped_ptr(new NativeDisplayDelegateOzone());
70 base::ScopedFD OpenClientNativePixmapDevice() const override {
71 return base::ScopedFD();
74 void InitializeUI() override {
75 overlay_manager_.reset(new OverlayManagerCast());
76 cursor_factory_.reset(new CursorFactoryOzone());
77 input_controller_ = CreateStubInputController();
78 gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost());
80 void InitializeGPU() override {
81 surface_factory_.reset(new SurfaceFactoryCast(egl_platform_.Pass()));
82 gpu_platform_support_.reset(
83 new GpuPlatformSupportCast(surface_factory_.get()));
86 private:
87 scoped_ptr<CastEglPlatform> egl_platform_;
88 scoped_ptr<SurfaceFactoryCast> surface_factory_;
89 scoped_ptr<CursorFactoryOzone> cursor_factory_;
90 scoped_ptr<InputController> input_controller_;
91 scoped_ptr<GpuPlatformSupportCast> gpu_platform_support_;
92 scoped_ptr<GpuPlatformSupportHost> gpu_platform_support_host_;
93 scoped_ptr<OverlayManagerOzone> overlay_manager_;
95 DISALLOW_COPY_AND_ASSIGN(OzonePlatformCast);
98 } // namespace
100 OzonePlatform* CreateOzonePlatformCast() {
101 const std::vector<std::string>& argv =
102 base::CommandLine::ForCurrentProcess()->argv();
103 scoped_ptr<chromecast::CastEglPlatform> platform(
104 chromecast::CastEglPlatformShlib::Create(argv));
105 return new OzonePlatformCast(platform.Pass());
108 } // namespace ui