Revert of Roll src/third_party/WebKit e0eac24:489c548 (svn 193311:193320) (patchset...
[chromium-blink-merge.git] / ui / ozone / platform / cast / surface_factory_cast.h
blobaaa8d2a52a49182a6e75bf9d3d4e621c44c30296
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 #ifndef UI_OZONE_PLATFORM_CAST_SURFACE_FACTORY_CAST_H_
6 #define UI_OZONE_PLATFORM_CAST_SURFACE_FACTORY_CAST_H_
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"
13 namespace chromecast {
14 class CastEglPlatform;
17 namespace ui {
19 // SurfaceFactoryOzone implementation for OzonePlatformCast.
20 class SurfaceFactoryCast : public SurfaceFactoryOzone {
21 public:
22 explicit SurfaceFactoryCast(
23 scoped_ptr<chromecast::CastEglPlatform> egl_platform);
24 ~SurfaceFactoryCast() override;
26 // SurfaceFactoryOzone implementation:
27 intptr_t GetNativeDisplay() override;
28 scoped_ptr<SurfaceOzoneEGL> CreateEGLSurfaceForWidget(
29 gfx::AcceleratedWidget widget) override;
30 const int32* GetEGLSurfaceProperties(const int32* desired_list) override;
31 bool LoadEGLGLES2Bindings(
32 AddGLLibraryCallback add_gl_library,
33 SetGLGetProcAddressProcCallback set_gl_get_proc_address) override;
35 void SetToRelinquishDisplay(const base::Closure& callback);
36 intptr_t GetNativeWindow();
37 bool ResizeDisplay(gfx::Size viewport_size);
38 void ChildDestroyed();
39 void SendRelinquishResponse();
41 private:
42 enum HardwareState { kUninitialized, kInitialized, kFailed };
44 // Window is destroyed if both SetToDestroyEGLDisplay()
45 // and destructor are called (in either order) before the next
46 // SurfaceOzoneEglCast is created in order to preserve the
47 // window across surface creation whenever possible.
48 enum DestroyWindowPendingState {
49 kNoDestroyPending = 0, // Surface does not exist
50 kSurfaceExists, // surface and window both exist
51 kWindowDestroyPending, // Relinquish before surface Destroy
52 kSurfaceDestroyedRecently, // surface Destroy before Relinquish
55 void CreateDisplayTypeAndWindowIfNeeded();
56 void DestroyDisplayTypeAndWindow();
57 void InitializeHardware();
58 void ShutdownHardware();
60 HardwareState state_;
61 DestroyWindowPendingState destroy_window_pending_state_;
62 base::Closure relinquish_display_callback_;
63 void* display_type_;
64 void* window_;
65 const gfx::Size default_display_size_;
66 gfx::Size display_size_;
67 gfx::Size new_display_size_;
68 scoped_ptr<chromecast::CastEglPlatform> egl_platform_;
70 DISALLOW_COPY_AND_ASSIGN(SurfaceFactoryCast);
73 } // namespace ui
75 #endif // UI_OZONE_PLATFORM_CAST_SURFACE_FACTORY_CAST_H_