Chromium Code Reviews| 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 <EGL/egl.h> | 7 #include <EGL/egl.h> |
| 8 #include <dlfcn.h> | 8 #include <dlfcn.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/callback_helpers.h" | 12 #include "base/callback_helpers.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
| 17 #include "chromecast/base/chromecast_switches.h" | 17 #include "chromecast/base/chromecast_switches.h" |
| 18 #include "chromecast/public/cast_egl_platform.h" | 18 #include "chromecast/public/cast_egl_platform.h" |
| 19 #include "chromecast/public/graphics_types.h" | 19 #include "chromecast/public/graphics_types.h" |
| 20 #include "third_party/skia/include/core/SkSurface.h" | 20 #include "third_party/skia/include/core/SkSurface.h" |
| 21 #include "ui/gfx/geometry/quad_f.h" | 21 #include "ui/gfx/geometry/quad_f.h" |
| 22 #include "ui/gfx/vsync_provider.h" | 22 #include "ui/gfx/vsync_provider.h" |
| 23 #include "ui/ozone/platform/cast/surface_ozone_egl_cast.h" | 23 #include "ui/ozone/platform/cast/gl_surface_cast.h" |
| 24 #include "ui/ozone/public/native_pixmap.h" | 24 #include "ui/ozone/public/native_pixmap.h" |
| 25 #include "ui/ozone/public/surface_ozone_canvas.h" | 25 #include "ui/ozone/public/surface_ozone_canvas.h" |
| 26 | 26 |
| 27 using chromecast::CastEglPlatform; | 27 using chromecast::CastEglPlatform; |
| 28 | 28 |
| 29 namespace ui { | 29 namespace ui { |
| 30 | 30 |
| 31 namespace { | 31 namespace { |
| 32 | 32 |
| 33 typedef EGLDisplay (*EGLGetDisplayFn)(NativeDisplayType); | 33 typedef EGLDisplay (*EGLGetDisplayFn)(NativeDisplayType); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 previous_frame_overlay_count_ = overlay_count_; | 160 previous_frame_overlay_count_ = overlay_count_; |
| 161 previous_frame_overlay_bounds_ = overlay_bounds_; | 161 previous_frame_overlay_bounds_ = overlay_bounds_; |
| 162 overlay_count_ = 0; | 162 overlay_count_ = 0; |
| 163 } | 163 } |
| 164 | 164 |
| 165 void SurfaceFactoryCast::OnOverlayScheduled(const gfx::Rect& display_bounds) { | 165 void SurfaceFactoryCast::OnOverlayScheduled(const gfx::Rect& display_bounds) { |
| 166 ++overlay_count_; | 166 ++overlay_count_; |
| 167 overlay_bounds_ = display_bounds; | 167 overlay_bounds_ = display_bounds; |
| 168 } | 168 } |
| 169 | 169 |
| 170 bool SurfaceFactoryCast::UseNewSurfaceAPI() { | |
| 171 return true; | |
| 172 } | |
| 173 | |
| 174 scoped_refptr<gl::GLSurface> SurfaceFactoryCast::CreateViewGLSurface( | |
| 175 gl::GLImplementation implementation, | |
| 176 gfx::AcceleratedWidget widget) { | |
| 177 if (implementation != gl::kGLImplementationEGLGLES2) { | |
| 178 NOTREACHED(); | |
| 179 return nullptr; | |
| 180 } | |
| 181 | |
| 182 // Verify requested widget dimensions match our current display size. | |
| 183 DCHECK_EQ(widget >> 16, display_size_.width()); | |
| 184 DCHECK_EQ(widget & 0xffff, display_size_.height()); | |
| 185 | |
| 186 return gl::InitializeGLSurface(new GLSurfaceCast(widget, this)); | |
| 187 } | |
| 188 | |
| 189 scoped_refptr<gl::GLSurface> SurfaceFactoryCast::CreateOffscreenGLSurface( | |
| 190 gl::GLImplementation implementation, | |
| 191 const gfx::Size& size) { | |
| 192 if (implementation != gl::kGLImplementationEGLGLES2) { | |
| 193 NOTREACHED(); | |
| 194 return nullptr; | |
| 195 } | |
| 196 | |
| 197 return gl::InitializeGLSurface(new gl::SurfacelessEGL(size)); | |
|
halliwell
2016/07/27 14:34:18
Is this right? Currently we go through the pbuffe
kylechar
2016/07/27 14:39:49
Oops. Good catch, I will upload the new patch for
| |
| 198 } | |
| 199 | |
| 170 std::unique_ptr<SurfaceOzoneCanvas> SurfaceFactoryCast::CreateCanvasForWidget( | 200 std::unique_ptr<SurfaceOzoneCanvas> SurfaceFactoryCast::CreateCanvasForWidget( |
| 171 gfx::AcceleratedWidget widget) { | 201 gfx::AcceleratedWidget widget) { |
| 172 // Software canvas support only in headless mode | 202 // Software canvas support only in headless mode |
| 173 if (egl_platform_) | 203 if (egl_platform_) |
| 174 return nullptr; | 204 return nullptr; |
| 175 return base::WrapUnique<SurfaceOzoneCanvas>(new DummySurface()); | 205 return base::WrapUnique<SurfaceOzoneCanvas>(new DummySurface()); |
| 176 } | 206 } |
| 177 | 207 |
| 178 intptr_t SurfaceFactoryCast::GetNativeDisplay() { | 208 intptr_t SurfaceFactoryCast::GetNativeDisplay() { |
| 179 CreateDisplayTypeAndWindowIfNeeded(); | 209 CreateDisplayTypeAndWindowIfNeeded(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 | 252 |
| 223 void SurfaceFactoryCast::DestroyDisplayTypeAndWindow() { | 253 void SurfaceFactoryCast::DestroyDisplayTypeAndWindow() { |
| 224 DestroyWindow(); | 254 DestroyWindow(); |
| 225 if (have_display_type_) { | 255 if (have_display_type_) { |
| 226 egl_platform_->DestroyDisplayType(display_type_); | 256 egl_platform_->DestroyDisplayType(display_type_); |
| 227 display_type_ = 0; | 257 display_type_ = 0; |
| 228 have_display_type_ = false; | 258 have_display_type_ = false; |
| 229 } | 259 } |
| 230 } | 260 } |
| 231 | 261 |
| 232 std::unique_ptr<SurfaceOzoneEGL> SurfaceFactoryCast::CreateEGLSurfaceForWidget( | |
| 233 gfx::AcceleratedWidget widget) { | |
| 234 // Verify requested widget dimensions match our current display size. | |
| 235 DCHECK_EQ(widget >> 16, display_size_.width()); | |
| 236 DCHECK_EQ(widget & 0xffff, display_size_.height()); | |
| 237 return base::WrapUnique<SurfaceOzoneEGL>(new SurfaceOzoneEglCast(this)); | |
| 238 } | |
| 239 | |
| 240 void SurfaceFactoryCast::ChildDestroyed() { | 262 void SurfaceFactoryCast::ChildDestroyed() { |
| 241 if (egl_platform_->MultipleSurfaceUnsupported()) | 263 if (egl_platform_->MultipleSurfaceUnsupported()) |
| 242 DestroyWindow(); | 264 DestroyWindow(); |
| 243 } | 265 } |
| 244 | 266 |
| 245 scoped_refptr<NativePixmap> SurfaceFactoryCast::CreateNativePixmap( | 267 scoped_refptr<NativePixmap> SurfaceFactoryCast::CreateNativePixmap( |
| 246 gfx::AcceleratedWidget widget, | 268 gfx::AcceleratedWidget widget, |
| 247 gfx::Size size, | 269 gfx::Size size, |
| 248 gfx::BufferFormat format, | 270 gfx::BufferFormat format, |
| 249 gfx::BufferUsage usage) { | 271 gfx::BufferUsage usage) { |
| 250 class CastPixmap : public NativePixmap { | 272 class CastPixmap : public NativePixmap { |
| 251 public: | 273 public: |
| 252 CastPixmap(SurfaceFactoryCast* parent) : parent_(parent) {} | 274 explicit CastPixmap(SurfaceFactoryCast* parent) : parent_(parent) {} |
| 253 | 275 |
| 254 void* GetEGLClientBuffer() const override { | 276 void* GetEGLClientBuffer() const override { |
| 255 // TODO(halliwell): try to implement this through CastEglPlatform. | 277 // TODO(halliwell): try to implement this through CastEglPlatform. |
| 256 return nullptr; | 278 return nullptr; |
| 257 } | 279 } |
| 258 bool AreDmaBufFdsValid() const override { return false; } | 280 bool AreDmaBufFdsValid() const override { return false; } |
| 259 size_t GetDmaBufFdCount() const override { return 0; } | 281 size_t GetDmaBufFdCount() const override { return 0; } |
| 260 int GetDmaBufFd(size_t plane) const override { return -1; } | 282 int GetDmaBufFd(size_t plane) const override { return -1; } |
| 261 int GetDmaBufPitch(size_t plane) const override { return 0; } | 283 int GetDmaBufPitch(size_t plane) const override { return 0; } |
| 262 int GetDmaBufOffset(size_t plane) const override { return 0; } | 284 int GetDmaBufOffset(size_t plane) const override { return 0; } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 307 return false; | 329 return false; |
| 308 } | 330 } |
| 309 | 331 |
| 310 set_gl_get_proc_address.Run(gl_proc); | 332 set_gl_get_proc_address.Run(gl_proc); |
| 311 add_gl_library.Run(lib_egl); | 333 add_gl_library.Run(lib_egl); |
| 312 add_gl_library.Run(lib_gles2); | 334 add_gl_library.Run(lib_gles2); |
| 313 return true; | 335 return true; |
| 314 } | 336 } |
| 315 | 337 |
| 316 } // namespace ui | 338 } // namespace ui |
| OLD | NEW |