| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/gl_surface_cast.h" | 5 #include "ui/ozone/platform/cast/gl_surface_cast.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" |
| 8 #include "ui/gfx/vsync_provider.h" |
| 7 #include "ui/ozone/common/egl_util.h" | 9 #include "ui/ozone/common/egl_util.h" |
| 8 #include "ui/ozone/platform/cast/gl_ozone_egl_cast.h" | 10 #include "ui/ozone/platform/cast/gl_ozone_egl_cast.h" |
| 9 | 11 |
| 12 namespace { |
| 13 // Target fixed 30fps. |
| 14 // TODO(halliwell): We might need to customize this value on various devices |
| 15 // or make it dynamic that throttles framerate if device is overheating. |
| 16 const base::TimeDelta kVSyncInterval = base::TimeDelta::FromSeconds(2) / 59.9; |
| 17 } // namespace |
| 18 |
| 10 namespace ui { | 19 namespace ui { |
| 11 | 20 |
| 12 GLSurfaceCast::GLSurfaceCast(gfx::AcceleratedWidget widget, | 21 GLSurfaceCast::GLSurfaceCast(gfx::AcceleratedWidget widget, |
| 13 GLOzoneEglCast* parent) | 22 GLOzoneEglCast* parent) |
| 14 : NativeViewGLSurfaceEGL(parent->GetNativeWindow()), | 23 : NativeViewGLSurfaceEGL( |
| 24 parent->GetNativeWindow(), |
| 25 base::MakeUnique<gfx::FixedVSyncProvider>(base::TimeTicks(), |
| 26 kVSyncInterval)), |
| 15 widget_(widget), | 27 widget_(widget), |
| 16 parent_(parent), | 28 parent_(parent), |
| 17 supports_swap_buffer_with_bounds_( | 29 supports_swap_buffer_with_bounds_( |
| 18 base::CommandLine::ForCurrentProcess()->HasSwitch( | 30 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 19 switches::kEnableSwapBuffersWithBounds)) { | 31 switches::kEnableSwapBuffersWithBounds)) { |
| 20 DCHECK(parent_); | 32 DCHECK(parent_); |
| 21 } | 33 } |
| 22 | 34 |
| 23 bool GLSurfaceCast::SupportsSwapBuffersWithBounds() { | 35 bool GLSurfaceCast::SupportsSwapBuffersWithBounds() { |
| 24 return supports_swap_buffer_with_bounds_; | 36 return supports_swap_buffer_with_bounds_; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 } | 101 } |
| 90 return config_; | 102 return config_; |
| 91 } | 103 } |
| 92 | 104 |
| 93 GLSurfaceCast::~GLSurfaceCast() { | 105 GLSurfaceCast::~GLSurfaceCast() { |
| 94 Destroy(); | 106 Destroy(); |
| 95 parent_->ChildDestroyed(); | 107 parent_->ChildDestroyed(); |
| 96 } | 108 } |
| 97 | 109 |
| 98 } // namespace ui | 110 } // namespace ui |
| OLD | NEW |