OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef CHROMECAST_OZONE_SURFACE_FACTORY_CAST_H_ | |
6 #define CHROMECAST_OZONE_SURFACE_FACTORY_CAST_H_ | |
7 | |
8 #include "base/callback.h" | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "ui/gfx/geometry/size.h" | |
11 #include "ui/ozone/public/surface_factory_ozone.h" | |
12 | |
13 namespace chromecast { | |
14 namespace ozone { | |
15 | |
16 class CastEglPlatform; | |
17 | |
18 // SurfaceFactoryOzone implementation for OzonePlatformCast. | |
19 class SurfaceFactoryCast : public ui::SurfaceFactoryOzone { | |
20 public: | |
21 explicit SurfaceFactoryCast(scoped_ptr<CastEglPlatform> egl_platform); | |
22 ~SurfaceFactoryCast() override; | |
23 | |
24 // ui::SurfaceFactoryOzone implementation: | |
25 intptr_t GetNativeDisplay() override; | |
26 scoped_ptr<ui::SurfaceOzoneEGL> CreateEGLSurfaceForWidget( | |
27 gfx::AcceleratedWidget widget) override; | |
28 const int32* GetEGLSurfaceProperties(const int32* desired_list) override; | |
29 bool LoadEGLGLES2Bindings( | |
30 AddGLLibraryCallback add_gl_library, | |
31 SetGLGetProcAddressProcCallback set_gl_get_proc_address) override; | |
32 | |
33 void SetToRelinquishDisplay(const base::Closure& callback); | |
34 intptr_t GetNativeWindow(); | |
35 bool ResizeDisplay(gfx::Size viewport_size); | |
36 void ChildDestroyed(); | |
37 void SendRelinquishResponse(); | |
38 | |
39 private: | |
40 enum HardwareState { kUninitialized, kInitialized, kFailed }; | |
41 | |
42 // Window is destroyed if both SetToDestroyEGLDisplay() | |
43 // and destructor are called (in either order) before the next | |
44 // SurfaceOzoneEglCast is created in order to preserve the | |
45 // window across surface creation whenever possible. | |
46 enum DestroyWindowPendingState { | |
47 kNoDestroyPending = 0, // Surface does not exist | |
48 kSurfaceExists, // surface and window both exist | |
49 kWindowDestroyPending, // Relinquish before surface Destroy | |
50 kSurfaceDestroyedRecently, // surface Destroy before Relinquish | |
51 }; | |
52 | |
53 void CreateDisplayTypeAndWindowIfNeeded(); | |
54 void DestroyDisplayTypeAndWindow(); | |
55 void InitializeHardware(); | |
56 void ShutdownHardware(); | |
57 | |
58 HardwareState state_; | |
59 DestroyWindowPendingState destroy_window_pending_state_; | |
60 base::Closure relinquish_display_callback_; | |
61 intptr_t display_type_; | |
62 intptr_t window_; | |
63 const gfx::Size default_display_size_; | |
64 gfx::Size display_size_; | |
65 gfx::Size new_display_size_; | |
66 scoped_ptr<CastEglPlatform> egl_platform_; | |
67 | |
68 DISALLOW_COPY_AND_ASSIGN(SurfaceFactoryCast); | |
69 }; | |
70 | |
71 } // namespace ozone | |
72 } // namespace chromecast | |
73 | |
74 #endif // CHROMECAST_OZONE_SURFACE_FACTORY_CAST_H_ | |
OLD | NEW |