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