OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef CHROMECAST_PUBLIC_CAST_EGL_PLATFORM_H_ |
| 6 #define CHROMECAST_PUBLIC_CAST_EGL_PLATFORM_H_ |
| 7 |
| 8 namespace chromecast { |
| 9 |
| 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 { |
| 14 public: |
| 15 |
| 16 struct Size { |
| 17 Size(int w, int h) |
| 18 : width(w), |
| 19 height(h) {} |
| 20 const int width; |
| 21 const int height; |
| 22 }; |
| 23 |
| 24 typedef void* (*GLGetProcAddressProc)(const char* name); |
| 25 typedef void* NativeDisplayType; |
| 26 typedef void* NativeWindowType; |
| 27 |
| 28 virtual ~CastEglPlatform() {} |
| 29 |
| 30 // Default display size is used for initial display and also as a minimum |
| 31 // resolution for applications. |
| 32 virtual Size GetDefaultDisplaySize() const = 0; |
| 33 |
| 34 // Returns an array of EGL properties, which can be used in any EGL function |
| 35 // used to select a display configuration. Note that all properties should be |
| 36 // immediately followed by the corresponding desired value and array should be |
| 37 // terminated with EGL_NONE. Ownership of the array is not transferred to |
| 38 // caller. desired_list contains list of desired EGL properties and values. |
| 39 virtual const int* GetEGLSurfaceProperties(const int* desired_list) = 0; |
| 40 |
| 41 // Initialize/ShutdownHardware are called at most once each over the object's |
| 42 // lifetime. Initialize will be called before creating display type or |
| 43 // window. If Initialize fails, return false (Shutdown will still be called). |
| 44 virtual bool InitializeHardware() = 0; |
| 45 virtual void ShutdownHardware() = 0; |
| 46 |
| 47 // These three are called once after hardware is successfully initialized. |
| 48 // The implementation must load the libraries containing EGL and GLES2 |
| 49 // bindings (return the pointer obtained from dlopen). It must also supply |
| 50 // a function pointer to eglGetProcAddress or equivalent. |
| 51 virtual void* GetEglLibrary() = 0; |
| 52 virtual void* GetGles2Library() = 0; |
| 53 virtual GLGetProcAddressProc GetGLProcAddressProc() = 0; |
| 54 |
| 55 // Creates/destroys an EGLNativeDisplayType. These may be called multiple |
| 56 // times over the object's lifetime, for example to release the display when |
| 57 // switching to an external application. There will be at most one display |
| 58 // type at a time. |
| 59 virtual NativeDisplayType CreateDisplayType(const Size& size) = 0; |
| 60 virtual void DestroyDisplayType(NativeDisplayType display_type) = 0; |
| 61 |
| 62 // Creates/destroys an EGLNativeWindow. There will be at most one window at a |
| 63 // time, created within a valid display type. |
| 64 virtual NativeWindowType CreateWindow(NativeDisplayType display_type, |
| 65 const Size& size) = 0; |
| 66 virtual void DestroyWindow(NativeWindowType window) = 0; |
| 67 }; |
| 68 |
| 69 } // namespace chromecast |
| 70 |
| 71 #endif // CHROMECAST_PUBLIC_CAST_EGL_PLATFORM_H_ |
OLD | NEW |