| 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 "services/ui/surfaces/display_output_surface_ozone.h" | 5 #include "services/ui/surfaces/display_output_surface_ozone.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 context_provider->ContextSupport()), | 33 context_provider->ContextSupport()), |
| 34 synthetic_begin_frame_source_(synthetic_begin_frame_source), | 34 synthetic_begin_frame_source_(synthetic_begin_frame_source), |
| 35 weak_ptr_factory_(this) { | 35 weak_ptr_factory_(this) { |
| 36 buffer_queue_.reset( | 36 buffer_queue_.reset( |
| 37 new BufferQueue(context_provider->ContextGL(), target, internalformat, | 37 new BufferQueue(context_provider->ContextGL(), target, internalformat, |
| 38 display::DisplaySnapshot::PrimaryFormat(), &gl_helper_, | 38 display::DisplaySnapshot::PrimaryFormat(), &gl_helper_, |
| 39 gpu_memory_buffer_manager, widget)); | 39 gpu_memory_buffer_manager, widget)); |
| 40 | 40 |
| 41 capabilities_.uses_default_gl_framebuffer = false; | 41 capabilities_.uses_default_gl_framebuffer = false; |
| 42 capabilities_.flipped_output_surface = true; | 42 capabilities_.flipped_output_surface = true; |
| 43 capabilities_.supports_stencil = true; |
| 43 // Set |max_frames_pending| to 2 for surfaceless, which aligns scheduling | 44 // Set |max_frames_pending| to 2 for surfaceless, which aligns scheduling |
| 44 // more closely with the previous surfaced behavior. | 45 // more closely with the previous surfaced behavior. |
| 45 // With a surface, swap buffer ack used to return early, before actually | 46 // With a surface, swap buffer ack used to return early, before actually |
| 46 // presenting the back buffer, enabling the browser compositor to run ahead. | 47 // presenting the back buffer, enabling the browser compositor to run ahead. |
| 47 // Surfaceless implementation acks at the time of actual buffer swap, which | 48 // Surfaceless implementation acks at the time of actual buffer swap, which |
| 48 // shifts the start of the new frame forward relative to the old | 49 // shifts the start of the new frame forward relative to the old |
| 49 // implementation. | 50 // implementation. |
| 50 capabilities_.max_frames_pending = 2; | 51 capabilities_.max_frames_pending = 2; |
| 51 | 52 |
| 52 buffer_queue_->Initialize(); | 53 buffer_queue_->Initialize(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 82 | 83 |
| 83 // We call this on every frame that a value changes, but changing the size once | 84 // We call this on every frame that a value changes, but changing the size once |
| 84 // we've allocated backing NativePixmapOzone instances will cause a DCHECK | 85 // we've allocated backing NativePixmapOzone instances will cause a DCHECK |
| 85 // because Chrome never Reshape(s) after the first one from (0,0). NB: this | 86 // because Chrome never Reshape(s) after the first one from (0,0). NB: this |
| 86 // implies that screen size changes need to be plumbed differently. In | 87 // implies that screen size changes need to be plumbed differently. In |
| 87 // particular, we must create the native window in the size that the hardware | 88 // particular, we must create the native window in the size that the hardware |
| 88 // reports. | 89 // reports. |
| 89 void DisplayOutputSurfaceOzone::Reshape(const gfx::Size& size, | 90 void DisplayOutputSurfaceOzone::Reshape(const gfx::Size& size, |
| 90 float device_scale_factor, | 91 float device_scale_factor, |
| 91 const gfx::ColorSpace& color_space, | 92 const gfx::ColorSpace& color_space, |
| 92 bool has_alpha) { | 93 bool has_alpha, |
| 94 bool use_stencil) { |
| 93 reshape_size_ = size; | 95 reshape_size_ = size; |
| 94 context_provider()->ContextGL()->ResizeCHROMIUM( | 96 context_provider()->ContextGL()->ResizeCHROMIUM( |
| 95 size.width(), size.height(), device_scale_factor, has_alpha); | 97 size.width(), size.height(), device_scale_factor, has_alpha); |
| 96 buffer_queue_->Reshape(size, device_scale_factor, color_space); | 98 buffer_queue_->Reshape(size, device_scale_factor, color_space, use_stencil); |
| 97 } | 99 } |
| 98 | 100 |
| 99 void DisplayOutputSurfaceOzone::SwapBuffers(cc::OutputSurfaceFrame frame) { | 101 void DisplayOutputSurfaceOzone::SwapBuffers(cc::OutputSurfaceFrame frame) { |
| 100 DCHECK(buffer_queue_); | 102 DCHECK(buffer_queue_); |
| 101 | 103 |
| 102 // TODO(rjkroege): What if swap happens again before OnGpuSwapBuffersCompleted | 104 // TODO(rjkroege): What if swap happens again before OnGpuSwapBuffersCompleted |
| 103 // then it would see the wrong size? | 105 // then it would see the wrong size? |
| 104 DCHECK(reshape_size_ == frame.size); | 106 DCHECK(reshape_size_ == frame.size); |
| 105 swap_size_ = reshape_size_; | 107 swap_size_ = reshape_size_; |
| 106 | 108 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 void DisplayOutputSurfaceOzone::OnVSyncParametersUpdated( | 168 void DisplayOutputSurfaceOzone::OnVSyncParametersUpdated( |
| 167 base::TimeTicks timebase, | 169 base::TimeTicks timebase, |
| 168 base::TimeDelta interval) { | 170 base::TimeDelta interval) { |
| 169 // TODO(brianderson): We should not be receiving 0 intervals. | 171 // TODO(brianderson): We should not be receiving 0 intervals. |
| 170 synthetic_begin_frame_source_->OnUpdateVSyncParameters( | 172 synthetic_begin_frame_source_->OnUpdateVSyncParameters( |
| 171 timebase, | 173 timebase, |
| 172 interval.is_zero() ? cc::BeginFrameArgs::DefaultInterval() : interval); | 174 interval.is_zero() ? cc::BeginFrameArgs::DefaultInterval() : interval); |
| 173 } | 175 } |
| 174 | 176 |
| 175 } // namespace ui | 177 } // namespace ui |
| OLD | NEW |