| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_OZONE_PLATFORM_CAST_SURFACE_FACTORY_CAST_H_ | 5 #ifndef UI_OZONE_PLATFORM_CAST_GL_OZONE_EGL_CAST_H_ |
| 6 #define UI_OZONE_PLATFORM_CAST_SURFACE_FACTORY_CAST_H_ | 6 #define UI_OZONE_PLATFORM_CAST_GL_OZONE_EGL_CAST_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "ui/gfx/geometry/rect.h" | 13 #include "ui/gfx/geometry/rect.h" |
| 14 #include "ui/gfx/geometry/size.h" | 14 #include "ui/gfx/geometry/size.h" |
| 15 #include "ui/gl/gl_surface.h" | 15 #include "ui/gl/gl_surface.h" |
| 16 #include "ui/ozone/public/surface_factory_ozone.h" | 16 #include "ui/ozone/common/gl_ozone_egl.h" |
| 17 | 17 |
| 18 namespace chromecast { | 18 namespace chromecast { |
| 19 class CastEglPlatform; | 19 class CastEglPlatform; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace ui { | 22 namespace ui { |
| 23 | 23 |
| 24 // SurfaceFactoryOzone implementation for OzonePlatformCast. | 24 // GL implementation using EGL for Ozone cast platform. |
| 25 class SurfaceFactoryCast : public SurfaceFactoryOzone { | 25 class GLOzoneEglCast : public GLOzoneEGL { |
| 26 public: | 26 public: |
| 27 SurfaceFactoryCast(); | 27 explicit GLOzoneEglCast( |
| 28 explicit SurfaceFactoryCast( | |
| 29 std::unique_ptr<chromecast::CastEglPlatform> egl_platform); | 28 std::unique_ptr<chromecast::CastEglPlatform> egl_platform); |
| 30 ~SurfaceFactoryCast() override; | 29 ~GLOzoneEglCast() override; |
| 31 | 30 |
| 32 // SurfaceFactoryOzone implementation: | 31 // GLOzoneEGL implementation: |
| 33 scoped_refptr<gl::GLSurface> CreateViewGLSurface( | 32 scoped_refptr<gl::GLSurface> CreateViewGLSurface( |
| 34 gl::GLImplementation implementation, | |
| 35 gfx::AcceleratedWidget widget) override; | 33 gfx::AcceleratedWidget widget) override; |
| 36 scoped_refptr<gl::GLSurface> CreateOffscreenGLSurface( | 34 scoped_refptr<gl::GLSurface> CreateOffscreenGLSurface( |
| 37 gl::GLImplementation implementation, | |
| 38 const gfx::Size& size) override; | 35 const gfx::Size& size) override; |
| 39 std::unique_ptr<SurfaceOzoneCanvas> CreateCanvasForWidget( | |
| 40 gfx::AcceleratedWidget widget) override; | |
| 41 intptr_t GetNativeDisplay() override; | 36 intptr_t GetNativeDisplay() override; |
| 42 scoped_refptr<NativePixmap> CreateNativePixmap( | 37 bool LoadGLES2Bindings() override; |
| 43 gfx::AcceleratedWidget widget, | |
| 44 gfx::Size size, | |
| 45 gfx::BufferFormat format, | |
| 46 gfx::BufferUsage usage) override; | |
| 47 bool LoadEGLGLES2Bindings() override; | |
| 48 | 38 |
| 49 intptr_t GetNativeWindow(); | 39 intptr_t GetNativeWindow(); |
| 50 bool ResizeDisplay(gfx::Size viewport_size); | 40 bool ResizeDisplay(gfx::Size viewport_size); |
| 51 void ChildDestroyed(); | 41 void ChildDestroyed(); |
| 52 void TerminateDisplay(); | 42 void TerminateDisplay(); |
| 53 void ShutdownHardware(); | 43 void ShutdownHardware(); |
| 54 | 44 |
| 55 // API for keeping track of overlays per frame for logging purposes | 45 // API for keeping track of overlays per frame for logging purposes |
| 56 void OnSwapBuffers(); | 46 void OnSwapBuffers(); |
| 57 void OnOverlayScheduled(const gfx::Rect& display_bounds); | 47 void OnOverlayScheduled(const gfx::Rect& display_bounds); |
| 58 | 48 |
| 59 private: | 49 private: |
| 60 enum HardwareState { kUninitialized, kInitialized, kFailed }; | 50 enum HardwareState { kUninitialized, kInitialized, kFailed }; |
| 61 | 51 |
| 62 void CreateDisplayTypeAndWindowIfNeeded(); | 52 void CreateDisplayTypeAndWindowIfNeeded(); |
| 63 void DestroyDisplayTypeAndWindow(); | 53 void DestroyDisplayTypeAndWindow(); |
| 64 void DestroyWindow(); | 54 void DestroyWindow(); |
| 65 void InitializeHardware(); | 55 void InitializeHardware(); |
| 66 | 56 |
| 67 HardwareState state_; | 57 HardwareState state_ = kUninitialized; |
| 68 void* display_type_; | 58 void* display_type_ = 0; |
| 69 bool have_display_type_; | 59 bool have_display_type_ = false; |
| 70 void* window_; | 60 void* window_ = 0; |
| 71 gfx::Size display_size_; | 61 gfx::Size display_size_; |
| 72 std::unique_ptr<chromecast::CastEglPlatform> egl_platform_; | 62 std::unique_ptr<chromecast::CastEglPlatform> egl_platform_; |
| 73 | 63 |
| 74 // Overlays scheduled in current and previous frames: | 64 // Overlays scheduled in current and previous frames: |
| 75 int overlay_count_; | 65 int overlay_count_ = 0; |
| 76 gfx::Rect overlay_bounds_; | 66 gfx::Rect overlay_bounds_; |
| 77 int previous_frame_overlay_count_; | 67 int previous_frame_overlay_count_ = 0; |
| 78 gfx::Rect previous_frame_overlay_bounds_; | 68 gfx::Rect previous_frame_overlay_bounds_; |
| 79 | 69 |
| 80 DISALLOW_COPY_AND_ASSIGN(SurfaceFactoryCast); | 70 DISALLOW_COPY_AND_ASSIGN(GLOzoneEglCast); |
| 81 }; | 71 }; |
| 82 | 72 |
| 83 } // namespace ui | 73 } // namespace ui |
| 84 | 74 |
| 85 #endif // UI_OZONE_PLATFORM_CAST_SURFACE_FACTORY_CAST_H_ | 75 #endif // UI_OZONE_PLATFORM_CAST_GL_OZONE_EGL_CAST_H_ |
| OLD | NEW |