| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 #include "ui/ozone/platform/cast/surface_factory_cast.h" | 5 #include "ui/ozone/platform/cast/surface_factory_cast.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "chromecast/public/cast_egl_platform.h" | 11 #include "chromecast/public/cast_egl_platform.h" |
| 12 #include "third_party/skia/include/core/SkSurface.h" | 12 #include "third_party/skia/include/core/SkSurface.h" |
| 13 #include "ui/gfx/geometry/rect.h" | 13 #include "ui/gfx/geometry/rect.h" |
| 14 #include "ui/gfx/vsync_provider.h" | 14 #include "ui/gfx/vsync_provider.h" |
| 15 #include "ui/ozone/common/gl_ozone_osmesa.h" |
| 15 #include "ui/ozone/public/native_pixmap.h" | 16 #include "ui/ozone/public/native_pixmap.h" |
| 16 #include "ui/ozone/public/surface_ozone_canvas.h" | 17 #include "ui/ozone/public/surface_ozone_canvas.h" |
| 17 | 18 |
| 18 namespace ui { | 19 namespace ui { |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 class DummySurface : public SurfaceOzoneCanvas { | 23 class DummySurface : public SurfaceOzoneCanvas { |
| 23 public: | 24 public: |
| 24 DummySurface() {} | 25 DummySurface() {} |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 private: | 81 private: |
| 81 ~CastPixmap() override {} | 82 ~CastPixmap() override {} |
| 82 | 83 |
| 83 GLOzoneEglCast* parent_; | 84 GLOzoneEglCast* parent_; |
| 84 | 85 |
| 85 DISALLOW_COPY_AND_ASSIGN(CastPixmap); | 86 DISALLOW_COPY_AND_ASSIGN(CastPixmap); |
| 86 }; | 87 }; |
| 87 | 88 |
| 88 } // namespace | 89 } // namespace |
| 89 | 90 |
| 90 SurfaceFactoryCast::SurfaceFactoryCast() {} | 91 SurfaceFactoryCast::SurfaceFactoryCast() : SurfaceFactoryCast(nullptr) {} |
| 91 | 92 |
| 92 SurfaceFactoryCast::SurfaceFactoryCast( | 93 SurfaceFactoryCast::SurfaceFactoryCast( |
| 93 std::unique_ptr<chromecast::CastEglPlatform> egl_platform) | 94 std::unique_ptr<chromecast::CastEglPlatform> egl_platform) |
| 94 : egl_implementation_( | 95 : osmesa_implementation_(base::MakeUnique<GLOzoneOSMesa>()) { |
| 95 base::MakeUnique<GLOzoneEglCast>(std::move(egl_platform))) {} | 96 if (egl_platform) { |
| 97 egl_implementation_ = |
| 98 base::MakeUnique<GLOzoneEglCast>(std::move(egl_platform)); |
| 99 } |
| 100 } |
| 96 | 101 |
| 97 SurfaceFactoryCast::~SurfaceFactoryCast() {} | 102 SurfaceFactoryCast::~SurfaceFactoryCast() {} |
| 98 | 103 |
| 99 std::vector<gl::GLImplementation> | 104 std::vector<gl::GLImplementation> |
| 100 SurfaceFactoryCast::GetAllowedGLImplementations() { | 105 SurfaceFactoryCast::GetAllowedGLImplementations() { |
| 101 std::vector<gl::GLImplementation> impls; | 106 std::vector<gl::GLImplementation> impls; |
| 102 if (egl_implementation_) | 107 if (egl_implementation_) |
| 103 impls.push_back(gl::kGLImplementationEGLGLES2); | 108 impls.push_back(gl::kGLImplementationEGLGLES2); |
| 104 impls.push_back(gl::kGLImplementationOSMesaGL); | 109 impls.push_back(gl::kGLImplementationOSMesaGL); |
| 105 return impls; | 110 return impls; |
| 106 } | 111 } |
| 107 | 112 |
| 108 GLOzone* SurfaceFactoryCast::GetGLOzone(gl::GLImplementation implementation) { | 113 GLOzone* SurfaceFactoryCast::GetGLOzone(gl::GLImplementation implementation) { |
| 109 switch (implementation) { | 114 switch (implementation) { |
| 110 case gl::kGLImplementationEGLGLES2: | 115 case gl::kGLImplementationEGLGLES2: |
| 111 return egl_implementation_.get(); | 116 return egl_implementation_.get(); |
| 117 case gl::kGLImplementationOSMesaGL: |
| 118 return osmesa_implementation_.get(); |
| 112 default: | 119 default: |
| 113 return nullptr; | 120 return nullptr; |
| 114 } | 121 } |
| 115 } | 122 } |
| 116 | 123 |
| 117 std::unique_ptr<SurfaceOzoneCanvas> SurfaceFactoryCast::CreateCanvasForWidget( | 124 std::unique_ptr<SurfaceOzoneCanvas> SurfaceFactoryCast::CreateCanvasForWidget( |
| 118 gfx::AcceleratedWidget widget) { | 125 gfx::AcceleratedWidget widget) { |
| 119 // Software canvas support only in headless mode | 126 // Software canvas support only in headless mode |
| 120 if (egl_implementation_) | 127 if (egl_implementation_) |
| 121 return nullptr; | 128 return nullptr; |
| 122 return base::WrapUnique<SurfaceOzoneCanvas>(new DummySurface()); | 129 return base::WrapUnique<SurfaceOzoneCanvas>(new DummySurface()); |
| 123 } | 130 } |
| 124 | 131 |
| 125 scoped_refptr<NativePixmap> SurfaceFactoryCast::CreateNativePixmap( | 132 scoped_refptr<NativePixmap> SurfaceFactoryCast::CreateNativePixmap( |
| 126 gfx::AcceleratedWidget widget, | 133 gfx::AcceleratedWidget widget, |
| 127 gfx::Size size, | 134 gfx::Size size, |
| 128 gfx::BufferFormat format, | 135 gfx::BufferFormat format, |
| 129 gfx::BufferUsage usage) { | 136 gfx::BufferUsage usage) { |
| 130 return make_scoped_refptr(new CastPixmap(egl_implementation_.get())); | 137 return make_scoped_refptr(new CastPixmap(egl_implementation_.get())); |
| 131 } | 138 } |
| 132 | 139 |
| 133 } // namespace ui | 140 } // namespace ui |
| OLD | NEW |