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 CHROMECAST_OZONE_CAST_EGL_PLATFORM_H_
6 #define CHROMECAST_OZONE_CAST_EGL_PLATFORM_H_
8 #include "ui/ozone/public/surface_factory_ozone.h"
14 namespace chromecast
{
17 // Interface representing all the hardware-specific elements of an Ozone
18 // implementation for Cast. Supply an implementation of this interface
19 // to OzonePlatformCast to create a complete Ozone implementation.
20 class CastEglPlatform
{
22 typedef ui::SurfaceFactoryOzone::AddGLLibraryCallback AddGLLibraryCallback
;
23 typedef ui::SurfaceFactoryOzone::SetGLGetProcAddressProcCallback
24 SetGLGetProcAddressProcCallback
;
26 virtual ~CastEglPlatform() {}
28 // Default display size is used for initial display and also as a minimum
29 // resolution for applications.
30 virtual gfx::Size
GetDefaultDisplaySize() const = 0;
32 // Returns an array of EGL properties, which can be used in any EGL function
33 // used to select a display configuration. Note that all properties should be
34 // immediately followed by the corresponding desired value and array should be
35 // terminated with EGL_NONE. Ownership of the array is not transferred to
36 // caller. desired_list contains list of desired EGL properties and values.
37 virtual const int32
* GetEGLSurfaceProperties(const int32
* desired_list
) = 0;
39 // Initialize/ShutdownHardware are called at most once each over the object's
40 // lifetime. Initialize will be called before creating display type or
41 // window. If Initialize fails, return false (Shutdown will still be called).
42 virtual bool InitializeHardware() = 0;
43 virtual void ShutdownHardware() = 0;
45 // Called once after hardware successfully initialized. Implementation needs
46 // to add the EGL and GLES2 libraries through add_gl_library and also supply
47 // a pointer to eglGetProcAddress (or equivalent function).
48 virtual bool LoadEGLGLES2Bindings(
49 AddGLLibraryCallback add_gl_library
,
50 SetGLGetProcAddressProcCallback set_gl_get_proc_address
) = 0;
52 // Create/destroy an EGLNativeDisplayType. These may be called multiple times
53 // over the object's lifetime, for example to release the display when
54 // switching to an external application. There will be at most one display
56 virtual intptr_t CreateDisplayType(const gfx::Size
& size
) = 0;
57 virtual void DestroyDisplayType(intptr_t display_type
) = 0;
59 // Create/destroy an EGLNativeWindow. There will be at most one window at a
60 // time, created within a valid display type.
61 virtual intptr_t CreateWindow(intptr_t display_type
,
62 const gfx::Size
& size
) = 0;
63 virtual void DestroyWindow(intptr_t window
) = 0;
67 } // namespace chromecast
69 #endif // CHROMECAST_OZONE_CAST_EGL_PLATFORM_H_