Fix search results being clipped in app list.
[chromium-blink-merge.git] / ui / ozone / platform / cast / ozone_platform_cast.cc
blobd3a1ea965c39017e121c70b89a3ab3b2f7ede9cf
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/platform_window_cast.h"
13 #include "ui/ozone/platform/cast/surface_factory_cast.h"
14 #include "ui/ozone/public/cursor_factory_ozone.h"
15 #include "ui/ozone/public/gpu_platform_support_host.h"
16 #include "ui/ozone/public/input_controller.h"
17 #include "ui/ozone/public/ozone_platform.h"
18 #include "ui/ozone/public/system_input_injector.h"
20 using chromecast::CastEglPlatform;
22 namespace ui {
23 namespace {
25 // Ozone platform implementation for Cast. Implements functionality
26 // common to all Cast implementations:
27 // - Always one window with window size equal to display size
28 // - No input, cursor support
29 // - Relinquish GPU resources flow for switching to external applications
30 // Meanwhile, platform-specific implementation details are abstracted out
31 // to the CastEglPlatform interface.
32 class OzonePlatformCast : public OzonePlatform {
33 public:
34 explicit OzonePlatformCast(scoped_ptr<CastEglPlatform> egl_platform)
35 : egl_platform_(egl_platform.Pass()) {}
36 ~OzonePlatformCast() override {}
38 // OzonePlatform implementation:
39 SurfaceFactoryOzone* GetSurfaceFactoryOzone() override {
40 return surface_factory_.get();
42 CursorFactoryOzone* GetCursorFactoryOzone() override {
43 return cursor_factory_.get();
45 InputController* GetInputController() override {
46 return input_controller_.get();
48 GpuPlatformSupport* GetGpuPlatformSupport() override {
49 return gpu_platform_support_.get();
51 GpuPlatformSupportHost* GetGpuPlatformSupportHost() override {
52 return gpu_platform_support_host_.get();
54 scoped_ptr<SystemInputInjector> CreateSystemInputInjector() override {
55 return nullptr; // no input injection support
57 scoped_ptr<PlatformWindow> CreatePlatformWindow(
58 PlatformWindowDelegate* delegate,
59 const gfx::Rect& bounds) override {
60 return make_scoped_ptr<PlatformWindow>(
61 new PlatformWindowCast(delegate, bounds));
63 scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() override {
64 return make_scoped_ptr(new NativeDisplayDelegateOzone());
67 void InitializeUI() override {
68 if (!surface_factory_) {
69 surface_factory_.reset(new SurfaceFactoryCast(egl_platform_.Pass()));
71 cursor_factory_.reset(new CursorFactoryOzone());
72 input_controller_ = CreateStubInputController();
73 gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost());
75 void InitializeGPU() override {
76 if (!surface_factory_) {
77 surface_factory_.reset(new SurfaceFactoryCast(egl_platform_.Pass()));
79 gpu_platform_support_.reset(
80 new GpuPlatformSupportCast(surface_factory_.get()));
83 private:
84 scoped_ptr<CastEglPlatform> egl_platform_;
85 scoped_ptr<SurfaceFactoryCast> surface_factory_;
86 scoped_ptr<CursorFactoryOzone> cursor_factory_;
87 scoped_ptr<InputController> input_controller_;
88 scoped_ptr<GpuPlatformSupportCast> gpu_platform_support_;
89 scoped_ptr<GpuPlatformSupportHost> gpu_platform_support_host_;
91 DISALLOW_COPY_AND_ASSIGN(OzonePlatformCast);
94 } // namespace
96 OzonePlatform* CreateOzonePlatformCast() {
97 const std::vector<std::string>& argv =
98 base::CommandLine::ForCurrentProcess()->argv();
99 scoped_ptr<chromecast::CastEglPlatform> platform(
100 chromecast::CastEglPlatformShlib::Create(argv));
101 return new OzonePlatformCast(platform.Pass());
104 } // namespace ui