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_PUBLIC_CAST_EGL_PLATFORM_H_
6 #define CHROMECAST_PUBLIC_CAST_EGL_PLATFORM_H_
12 // Interface representing all the hardware-specific elements of an Ozone
13 // implementation for Cast. Supply an implementation of this interface
14 // to OzonePlatformCast to create a complete Ozone implementation.
15 class CastEglPlatform
{
17 typedef void* (*GLGetProcAddressProc
)(const char* name
);
18 typedef void* NativeDisplayType
;
19 typedef void* NativeWindowType
;
21 virtual ~CastEglPlatform() {}
23 // Returns an array of EGL properties, which can be used in any EGL function
24 // used to select a display configuration. Note that all properties should be
25 // immediately followed by the corresponding desired value and array should be
26 // terminated with EGL_NONE. Ownership of the array is not transferred to
27 // caller. desired_list contains list of desired EGL properties and values.
28 virtual const int* GetEGLSurfaceProperties(const int* desired_list
) = 0;
30 // Initialize/ShutdownHardware are called at most once each over the object's
31 // lifetime. Initialize will be called before creating display type or
32 // window. If Initialize fails, return false (Shutdown will still be called).
33 virtual bool InitializeHardware() = 0;
34 virtual void ShutdownHardware() = 0;
36 // These three are called once after hardware is successfully initialized.
37 // The implementation must load the libraries containing EGL and GLES2
38 // bindings (return the pointer obtained from dlopen). It must also supply
39 // a function pointer to eglGetProcAddress or equivalent.
40 virtual void* GetEglLibrary() = 0;
41 virtual void* GetGles2Library() = 0;
42 virtual GLGetProcAddressProc
GetGLProcAddressProc() = 0;
44 // Creates/destroys an EGLNativeDisplayType. These may be called multiple
45 // times over the object's lifetime, for example to release the display when
46 // switching to an external application. There will be at most one display
48 virtual NativeDisplayType
CreateDisplayType(const Size
& size
) = 0;
49 virtual void DestroyDisplayType(NativeDisplayType display_type
) = 0;
51 // Creates/destroys an EGLNativeWindow. There will be at most one window at a
52 // time, created within a valid display type.
53 virtual NativeWindowType
CreateWindow(NativeDisplayType display_type
,
54 const Size
& size
) = 0;
55 virtual void DestroyWindow(NativeWindowType window
) = 0;
58 } // namespace chromecast
60 #endif // CHROMECAST_PUBLIC_CAST_EGL_PLATFORM_H_