| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/direct_output_surface.h" | 5 #include "services/ui/surfaces/display_output_surface.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 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" |
| 11 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
| 12 #include "cc/output/context_provider.h" | 12 #include "cc/output/context_provider.h" |
| 13 #include "cc/output/output_surface_client.h" | 13 #include "cc/output/output_surface_client.h" |
| 14 #include "cc/output/output_surface_frame.h" | 14 #include "cc/output/output_surface_frame.h" |
| 15 #include "cc/scheduler/begin_frame_source.h" | 15 #include "cc/scheduler/begin_frame_source.h" |
| 16 #include "gpu/command_buffer/client/context_support.h" | 16 #include "gpu/command_buffer/client/context_support.h" |
| 17 #include "gpu/command_buffer/client/gles2_interface.h" | 17 #include "gpu/command_buffer/client/gles2_interface.h" |
| 18 | 18 |
| 19 namespace ui { | 19 namespace ui { |
| 20 | 20 |
| 21 DirectOutputSurface::DirectOutputSurface( | 21 DisplayOutputSurface::DisplayOutputSurface( |
| 22 scoped_refptr<cc::InProcessContextProvider> context_provider, | 22 scoped_refptr<cc::InProcessContextProvider> context_provider, |
| 23 cc::SyntheticBeginFrameSource* synthetic_begin_frame_source) | 23 cc::SyntheticBeginFrameSource* synthetic_begin_frame_source) |
| 24 : cc::OutputSurface(context_provider), | 24 : cc::OutputSurface(context_provider), |
| 25 synthetic_begin_frame_source_(synthetic_begin_frame_source), | 25 synthetic_begin_frame_source_(synthetic_begin_frame_source), |
| 26 weak_ptr_factory_(this) { | 26 weak_ptr_factory_(this) { |
| 27 capabilities_.flipped_output_surface = | 27 capabilities_.flipped_output_surface = |
| 28 context_provider->ContextCapabilities().flips_vertically; | 28 context_provider->ContextCapabilities().flips_vertically; |
| 29 context_provider->SetSwapBuffersCompletionCallback( | 29 context_provider->SetSwapBuffersCompletionCallback( |
| 30 base::Bind(&DirectOutputSurface::OnGpuSwapBuffersCompleted, | 30 base::Bind(&DisplayOutputSurface::OnGpuSwapBuffersCompleted, |
| 31 weak_ptr_factory_.GetWeakPtr())); | 31 weak_ptr_factory_.GetWeakPtr())); |
| 32 context_provider->SetUpdateVSyncParametersCallback( | 32 context_provider->SetUpdateVSyncParametersCallback( |
| 33 base::Bind(&DirectOutputSurface::OnVSyncParametersUpdated, | 33 base::Bind(&DisplayOutputSurface::OnVSyncParametersUpdated, |
| 34 weak_ptr_factory_.GetWeakPtr())); | 34 weak_ptr_factory_.GetWeakPtr())); |
| 35 } | 35 } |
| 36 | 36 |
| 37 DirectOutputSurface::~DirectOutputSurface() {} | 37 DisplayOutputSurface::~DisplayOutputSurface() {} |
| 38 | 38 |
| 39 void DirectOutputSurface::BindToClient(cc::OutputSurfaceClient* client) { | 39 void DisplayOutputSurface::BindToClient(cc::OutputSurfaceClient* client) { |
| 40 DCHECK(client); | 40 DCHECK(client); |
| 41 DCHECK(!client_); | 41 DCHECK(!client_); |
| 42 client_ = client; | 42 client_ = client; |
| 43 } | 43 } |
| 44 | 44 |
| 45 void DirectOutputSurface::EnsureBackbuffer() {} | 45 void DisplayOutputSurface::EnsureBackbuffer() {} |
| 46 | 46 |
| 47 void DirectOutputSurface::DiscardBackbuffer() { | 47 void DisplayOutputSurface::DiscardBackbuffer() { |
| 48 context_provider()->ContextGL()->DiscardBackbufferCHROMIUM(); | 48 context_provider()->ContextGL()->DiscardBackbufferCHROMIUM(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void DirectOutputSurface::BindFramebuffer() { | 51 void DisplayOutputSurface::BindFramebuffer() { |
| 52 context_provider()->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, 0); | 52 context_provider()->ContextGL()->BindFramebuffer(GL_FRAMEBUFFER, 0); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void DirectOutputSurface::Reshape(const gfx::Size& size, | 55 void DisplayOutputSurface::Reshape(const gfx::Size& size, |
| 56 float device_scale_factor, | 56 float device_scale_factor, |
| 57 const gfx::ColorSpace& color_space, | 57 const gfx::ColorSpace& color_space, |
| 58 bool has_alpha) { | 58 bool has_alpha) { |
| 59 context_provider()->ContextGL()->ResizeCHROMIUM( | 59 context_provider()->ContextGL()->ResizeCHROMIUM( |
| 60 size.width(), size.height(), device_scale_factor, has_alpha); | 60 size.width(), size.height(), device_scale_factor, has_alpha); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void DirectOutputSurface::SwapBuffers(cc::OutputSurfaceFrame frame) { | 63 void DisplayOutputSurface::SwapBuffers(cc::OutputSurfaceFrame frame) { |
| 64 DCHECK(context_provider_); | 64 DCHECK(context_provider_); |
| 65 if (frame.sub_buffer_rect == gfx::Rect(frame.size)) { | 65 if (frame.sub_buffer_rect == gfx::Rect(frame.size)) { |
| 66 context_provider_->ContextSupport()->Swap(); | 66 context_provider_->ContextSupport()->Swap(); |
| 67 } else { | 67 } else { |
| 68 context_provider_->ContextSupport()->PartialSwapBuffers( | 68 context_provider_->ContextSupport()->PartialSwapBuffers( |
| 69 frame.sub_buffer_rect); | 69 frame.sub_buffer_rect); |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 uint32_t DirectOutputSurface::GetFramebufferCopyTextureFormat() { | 73 uint32_t DisplayOutputSurface::GetFramebufferCopyTextureFormat() { |
| 74 // TODO(danakj): What attributes are used for the default framebuffer here? | 74 // TODO(danakj): What attributes are used for the default framebuffer here? |
| 75 // Can it have alpha? cc::InProcessContextProvider doesn't take any | 75 // Can it have alpha? cc::InProcessContextProvider doesn't take any |
| 76 // attributes. | 76 // attributes. |
| 77 return GL_RGB; | 77 return GL_RGB; |
| 78 } | 78 } |
| 79 | 79 |
| 80 cc::OverlayCandidateValidator* | 80 cc::OverlayCandidateValidator* |
| 81 DirectOutputSurface::GetOverlayCandidateValidator() const { | 81 DisplayOutputSurface::GetOverlayCandidateValidator() const { |
| 82 return nullptr; | 82 return nullptr; |
| 83 } | 83 } |
| 84 | 84 |
| 85 bool DirectOutputSurface::IsDisplayedAsOverlayPlane() const { | 85 bool DisplayOutputSurface::IsDisplayedAsOverlayPlane() const { |
| 86 return false; | 86 return false; |
| 87 } | 87 } |
| 88 | 88 |
| 89 unsigned DirectOutputSurface::GetOverlayTextureId() const { | 89 unsigned DisplayOutputSurface::GetOverlayTextureId() const { |
| 90 return 0; | 90 return 0; |
| 91 } | 91 } |
| 92 | 92 |
| 93 bool DirectOutputSurface::SurfaceIsSuspendForRecycle() const { | 93 bool DisplayOutputSurface::SurfaceIsSuspendForRecycle() const { |
| 94 return false; | 94 return false; |
| 95 } | 95 } |
| 96 | 96 |
| 97 bool DirectOutputSurface::HasExternalStencilTest() const { | 97 bool DisplayOutputSurface::HasExternalStencilTest() const { |
| 98 return false; | 98 return false; |
| 99 } | 99 } |
| 100 | 100 |
| 101 void DirectOutputSurface::ApplyExternalStencil() {} | 101 void DisplayOutputSurface::ApplyExternalStencil() {} |
| 102 | 102 |
| 103 void DirectOutputSurface::OnGpuSwapBuffersCompleted( | 103 void DisplayOutputSurface::OnGpuSwapBuffersCompleted( |
| 104 const std::vector<ui::LatencyInfo>& latency_info, | 104 const std::vector<ui::LatencyInfo>& latency_info, |
| 105 gfx::SwapResult result, | 105 gfx::SwapResult result, |
| 106 const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac) { | 106 const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac) { |
| 107 client_->DidReceiveSwapBuffersAck(); | 107 client_->DidReceiveSwapBuffersAck(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void DirectOutputSurface::OnVSyncParametersUpdated(base::TimeTicks timebase, | 110 void DisplayOutputSurface::OnVSyncParametersUpdated(base::TimeTicks timebase, |
| 111 base::TimeDelta interval) { | 111 base::TimeDelta interval) { |
| 112 // TODO(brianderson): We should not be receiving 0 intervals. | 112 // TODO(brianderson): We should not be receiving 0 intervals. |
| 113 synthetic_begin_frame_source_->OnUpdateVSyncParameters( | 113 synthetic_begin_frame_source_->OnUpdateVSyncParameters( |
| 114 timebase, | 114 timebase, |
| 115 interval.is_zero() ? cc::BeginFrameArgs::DefaultInterval() : interval); | 115 interval.is_zero() ? cc::BeginFrameArgs::DefaultInterval() : interval); |
| 116 } | 116 } |
| 117 | 117 |
| 118 | |
| 119 } // namespace ui | 118 } // namespace ui |
| OLD | NEW |