| Index: content/browser/compositor/mus_browser_compositor_output_surface.cc
|
| diff --git a/content/browser/compositor/gpu_browser_compositor_output_surface.cc b/content/browser/compositor/mus_browser_compositor_output_surface.cc
|
| similarity index 57%
|
| copy from content/browser/compositor/gpu_browser_compositor_output_surface.cc
|
| copy to content/browser/compositor/mus_browser_compositor_output_surface.cc
|
| index 84cee90f3eaecc64678253a3ec6bd86f2add0613..5eab602e9a2d89fa1f0ce8cfe8e207e0044ea306 100644
|
| --- a/content/browser/compositor/gpu_browser_compositor_output_surface.cc
|
| +++ b/content/browser/compositor/mus_browser_compositor_output_surface.cc
|
| @@ -1,25 +1,33 @@
|
| -// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "content/browser/compositor/gpu_browser_compositor_output_surface.h"
|
| +#include "content/browser/compositor/mus_browser_compositor_output_surface.h"
|
|
|
| #include <utility>
|
|
|
| #include "build/build_config.h"
|
| #include "cc/output/compositor_frame.h"
|
| +#include "cc/output/compositor_frame_ack.h"
|
| #include "cc/output/output_surface_client.h"
|
| #include "components/display_compositor/compositor_overlay_candidate_validator.h"
|
| +#include "components/mus/common/gpu_service.h"
|
| +#include "components/mus/public/cpp/surfaces/surfaces_type_converters.h"
|
| +#include "components/mus/public/cpp/window.h"
|
| +#include "components/mus/public/cpp/window_surface.h"
|
| #include "content/browser/compositor/reflector_impl.h"
|
| #include "content/browser/compositor/reflector_texture.h"
|
| #include "content/browser/renderer_host/render_widget_host_impl.h"
|
| #include "content/common/gpu/client/context_provider_command_buffer.h"
|
| #include "gpu/command_buffer/client/context_support.h"
|
| #include "gpu/ipc/client/command_buffer_proxy_impl.h"
|
| +#include "ui/views/mus/native_widget_mus.h"
|
| +#include "ui/views/mus/window_tree_host_mus.h"
|
|
|
| namespace content {
|
|
|
| -GpuBrowserCompositorOutputSurface::GpuBrowserCompositorOutputSurface(
|
| +MusBrowserCompositorOutputSurface::MusBrowserCompositorOutputSurface(
|
| + gpu::SurfaceHandle surface_handle,
|
| scoped_refptr<ContextProviderCommandBuffer> context,
|
| scoped_refptr<ui::CompositorVSyncManager> vsync_manager,
|
| cc::SyntheticBeginFrameSource* begin_frame_source,
|
| @@ -30,27 +38,65 @@ GpuBrowserCompositorOutputSurface::GpuBrowserCompositorOutputSurface(
|
| begin_frame_source,
|
| std::move(overlay_candidate_validator)),
|
| swap_buffers_completion_callback_(base::Bind(
|
| - &GpuBrowserCompositorOutputSurface::OnGpuSwapBuffersCompleted,
|
| + &MusBrowserCompositorOutputSurface::OnGpuSwapBuffersCompleted,
|
| base::Unretained(this))),
|
| update_vsync_parameters_callback_(base::Bind(
|
| &BrowserCompositorOutputSurface::OnUpdateVSyncParametersFromGpu,
|
| - base::Unretained(this))) {}
|
| + base::Unretained(this))) {
|
| + capabilities_.delegated_rendering = true;
|
| + views::WindowTreeHostMus* window_tree_host =
|
| + static_cast<views::WindowTreeHostMus*>(
|
| + aura::WindowTreeHost::GetForAcceleratedWidget(surface_handle));
|
| + mus::Window* window = window_tree_host->native_widget()->window();
|
| + mus_window_surface_ =
|
| + window->RequestSurface(mus::mojom::SurfaceType::DEFAULT);
|
| +}
|
|
|
| -GpuBrowserCompositorOutputSurface::~GpuBrowserCompositorOutputSurface() {}
|
| +MusBrowserCompositorOutputSurface::~MusBrowserCompositorOutputSurface() {}
|
|
|
| -gpu::CommandBufferProxyImpl*
|
| -GpuBrowserCompositorOutputSurface::GetCommandBufferProxy() {
|
| - ContextProviderCommandBuffer* provider_command_buffer =
|
| - static_cast<content::ContextProviderCommandBuffer*>(
|
| - context_provider_.get());
|
| - gpu::CommandBufferProxyImpl* command_buffer_proxy =
|
| - provider_command_buffer->GetCommandBufferProxy();
|
| - DCHECK(command_buffer_proxy);
|
| - return command_buffer_proxy;
|
| +void MusBrowserCompositorOutputSurface::OnReflectorChanged() {
|
| + if (!reflector_) {
|
| + reflector_texture_.reset();
|
| + } else {
|
| + reflector_texture_.reset(new ReflectorTexture(context_provider()));
|
| + reflector_->OnSourceTextureMailboxUpdated(reflector_texture_->mailbox());
|
| + }
|
| +}
|
| +
|
| +void MusBrowserCompositorOutputSurface::OnGpuSwapBuffersCompleted(
|
| + const std::vector<ui::LatencyInfo>& latency_info,
|
| + gfx::SwapResult result,
|
| + const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac) {
|
| + RenderWidgetHostImpl::CompositorFrameDrawn(latency_info);
|
| + OnSwapBuffersComplete();
|
| }
|
|
|
| -bool GpuBrowserCompositorOutputSurface::BindToClient(
|
| +#if defined(OS_MACOSX)
|
| +void MusBrowserCompositorOutputSurface::SetSurfaceSuspendedForRecycle(
|
| + bool suspended) {}
|
| +#endif
|
| +
|
| +void MusBrowserCompositorOutputSurface::SwapBuffers(cc::CompositorFrame frame) {
|
| + DCHECK(frame.delegated_frame_data);
|
| + GetCommandBufferProxy()->SetLatencyInfo(frame.metadata.latency_info);
|
| +
|
| + // TODO(fsamuel, rjkroege): We should probably throttle compositor frames.
|
| + client_->DidSwapBuffers();
|
| +
|
| + mus_window_surface_->SubmitCompositorFrame(
|
| + cc::mojom::CompositorFrame::From(frame),
|
| + base::Bind(&MusBrowserCompositorOutputSurface::OnGpuSwapBuffersCompleted,
|
| + base::Unretained(this), std::vector<ui::LatencyInfo>(),
|
| + gfx::SwapResult::SWAP_ACK, nullptr));
|
| + // TODO(penghuang): figure how to handle reflector.
|
| + return;
|
| +}
|
| +
|
| +bool MusBrowserCompositorOutputSurface::BindToClient(
|
| cc::OutputSurfaceClient* client) {
|
| + mus_window_surface_->BindToThread();
|
| + mus_window_surface_->set_client(this);
|
| +
|
| if (!BrowserCompositorOutputSurface::BindToClient(client))
|
| return false;
|
|
|
| @@ -65,59 +111,28 @@ bool GpuBrowserCompositorOutputSurface::BindToClient(
|
| return true;
|
| }
|
|
|
| -uint32_t GpuBrowserCompositorOutputSurface::GetFramebufferCopyTextureFormat() {
|
| +uint32_t MusBrowserCompositorOutputSurface::GetFramebufferCopyTextureFormat() {
|
| auto* gl = static_cast<ContextProviderCommandBuffer*>(context_provider());
|
| return gl->GetCopyTextureInternalFormat();
|
| }
|
|
|
| -void GpuBrowserCompositorOutputSurface::OnReflectorChanged() {
|
| - if (!reflector_) {
|
| - reflector_texture_.reset();
|
| - } else {
|
| - reflector_texture_.reset(new ReflectorTexture(context_provider()));
|
| - reflector_->OnSourceTextureMailboxUpdated(reflector_texture_->mailbox());
|
| - }
|
| +void MusBrowserCompositorOutputSurface::OnResourcesReturned(
|
| + mus::WindowSurface* surface,
|
| + mojo::Array<cc::ReturnedResource> resources) {
|
| + cc::CompositorFrameAck cfa;
|
| + cfa.resources = resources.To<cc::ReturnedResourceArray>();
|
| + ReclaimResources(&cfa);
|
| }
|
|
|
| -void GpuBrowserCompositorOutputSurface::SwapBuffers(cc::CompositorFrame frame) {
|
| - DCHECK(frame.gl_frame_data);
|
| -
|
| - GetCommandBufferProxy()->SetLatencyInfo(frame.metadata.latency_info);
|
| -
|
| - if (reflector_) {
|
| - if (frame.gl_frame_data->sub_buffer_rect ==
|
| - gfx::Rect(frame.gl_frame_data->size)) {
|
| - reflector_texture_->CopyTextureFullImage(SurfaceSize());
|
| - reflector_->OnSourceSwapBuffers();
|
| - } else {
|
| - const gfx::Rect& rect = frame.gl_frame_data->sub_buffer_rect;
|
| - reflector_texture_->CopyTextureSubImage(rect);
|
| - reflector_->OnSourcePostSubBuffer(rect);
|
| - }
|
| - }
|
| -
|
| - if (frame.gl_frame_data->sub_buffer_rect ==
|
| - gfx::Rect(frame.gl_frame_data->size)) {
|
| - context_provider_->ContextSupport()->Swap();
|
| - } else {
|
| - context_provider_->ContextSupport()->PartialSwapBuffers(
|
| - frame.gl_frame_data->sub_buffer_rect);
|
| - }
|
| -
|
| - client_->DidSwapBuffers();
|
| -}
|
| -
|
| -void GpuBrowserCompositorOutputSurface::OnGpuSwapBuffersCompleted(
|
| - const std::vector<ui::LatencyInfo>& latency_info,
|
| - gfx::SwapResult result,
|
| - const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac) {
|
| - RenderWidgetHostImpl::CompositorFrameDrawn(latency_info);
|
| - OnSwapBuffersComplete();
|
| +gpu::CommandBufferProxyImpl*
|
| +MusBrowserCompositorOutputSurface::GetCommandBufferProxy() {
|
| + ContextProviderCommandBuffer* provider_command_buffer =
|
| + static_cast<content::ContextProviderCommandBuffer*>(
|
| + context_provider_.get());
|
| + gpu::CommandBufferProxyImpl* command_buffer_proxy =
|
| + provider_command_buffer->GetCommandBufferProxy();
|
| + DCHECK(command_buffer_proxy);
|
| + return command_buffer_proxy;
|
| }
|
|
|
| -#if defined(OS_MACOSX)
|
| -void GpuBrowserCompositorOutputSurface::SetSurfaceSuspendedForRecycle(
|
| - bool suspended) {}
|
| -#endif
|
| -
|
| } // namespace content
|
|
|