Fix OOP <webview> resize and autosize.
[chromium-blink-merge.git] / ui / ozone / platform / cast / surface_factory_cast.h
blob65466ce3f348a5b323418f23c1240978dfe331bd
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 scoped_refptr<NativePixmap> CreateNativePixmap(
32 gfx::AcceleratedWidget w,
33 gfx::Size size,
34 gfx::BufferFormat format,
35 gfx::BufferUsage usage) override;
36 bool LoadEGLGLES2Bindings(
37 AddGLLibraryCallback add_gl_library,
38 SetGLGetProcAddressProcCallback set_gl_get_proc_address) override;
40 void SetToRelinquishDisplay(const base::Closure& callback);
41 intptr_t GetNativeWindow();
42 bool ResizeDisplay(gfx::Size viewport_size);
43 void ChildDestroyed();
44 void SendRelinquishResponse();
46 private:
47 enum HardwareState { kUninitialized, kInitialized, kFailed };
49 // Window is destroyed if both SetToDestroyEGLDisplay()
50 // and destructor are called (in either order) before the next
51 // SurfaceOzoneEglCast is created in order to preserve the
52 // window across surface creation whenever possible.
53 enum DestroyWindowPendingState {
54 kNoDestroyPending = 0, // Surface does not exist
55 kSurfaceExists, // surface and window both exist
56 kWindowDestroyPending, // Relinquish before surface Destroy
57 kSurfaceDestroyedRecently, // surface Destroy before Relinquish
60 void CreateDisplayTypeAndWindowIfNeeded();
61 void DestroyDisplayTypeAndWindow();
62 void DestroyWindow();
63 void InitializeHardware();
64 void ShutdownHardware();
66 HardwareState state_;
67 DestroyWindowPendingState destroy_window_pending_state_;
68 base::Closure relinquish_display_callback_;
69 void* display_type_;
70 bool have_display_type_;
71 void* window_;
72 gfx::Size display_size_;
73 gfx::Size new_display_size_;
74 scoped_ptr<chromecast::CastEglPlatform> egl_platform_;
76 DISALLOW_COPY_AND_ASSIGN(SurfaceFactoryCast);
79 } // namespace ui
81 #endif // UI_OZONE_PLATFORM_CAST_SURFACE_FACTORY_CAST_H_