diff options
Diffstat (limited to 'chromium/components/mus/surfaces')
15 files changed, 0 insertions, 1087 deletions
diff --git a/chromium/components/mus/surfaces/DEPS b/chromium/components/mus/surfaces/DEPS deleted file mode 100644 index e21114ea1d7..00000000000 --- a/chromium/components/mus/surfaces/DEPS +++ /dev/null @@ -1,10 +0,0 @@ -include_rules = [ - "+cc", - "+components/display_compositor", - "+components/gpu", - "+gpu", - "+services/shell", - "+mojo/common", - "+mojo/converters", - "+mojo/public", -] diff --git a/chromium/components/mus/surfaces/OWNERS b/chromium/components/mus/surfaces/OWNERS deleted file mode 100644 index 1f1af6bcc54..00000000000 --- a/chromium/components/mus/surfaces/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -fsamuel@chromium.org -rjkroege@chromium.org diff --git a/chromium/components/mus/surfaces/direct_output_surface.cc b/chromium/components/mus/surfaces/direct_output_surface.cc deleted file mode 100644 index 7c7bc55f4c9..00000000000 --- a/chromium/components/mus/surfaces/direct_output_surface.cc +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2014 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 "components/mus/surfaces/direct_output_surface.h" - -#include <stdint.h> - -#include "base/bind.h" -#include "base/memory/ptr_util.h" -#include "cc/output/compositor_frame.h" -#include "cc/output/context_provider.h" -#include "cc/output/output_surface_client.h" -#include "cc/scheduler/begin_frame_source.h" -#include "gpu/command_buffer/client/context_support.h" -#include "gpu/command_buffer/client/gles2_interface.h" - -namespace mus { - -DirectOutputSurface::DirectOutputSurface( - scoped_refptr<SurfacesContextProvider> context_provider, - cc::SyntheticBeginFrameSource* synthetic_begin_frame_source) - : cc::OutputSurface(context_provider, nullptr, nullptr), - synthetic_begin_frame_source_(synthetic_begin_frame_source), - weak_ptr_factory_(this) { - context_provider->SetDelegate(this); -} - -DirectOutputSurface::~DirectOutputSurface() = default; - -bool DirectOutputSurface::BindToClient(cc::OutputSurfaceClient* client) { - if (!cc::OutputSurface::BindToClient(client)) - return false; - - if (capabilities_.uses_default_gl_framebuffer) { - capabilities_.flipped_output_surface = - context_provider()->ContextCapabilities().flips_vertically; - } - return true; -} - -void DirectOutputSurface::OnVSyncParametersUpdated( - const base::TimeTicks& timebase, - const base::TimeDelta& interval) { - // TODO(brianderson): We should not be receiving 0 intervals. - synthetic_begin_frame_source_->OnUpdateVSyncParameters( - timebase, - interval.is_zero() ? cc::BeginFrameArgs::DefaultInterval() : interval); -} - -void DirectOutputSurface::SwapBuffers(cc::CompositorFrame frame) { - DCHECK(context_provider_); - DCHECK(frame.gl_frame_data); - 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); - } - - gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); - const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM(); - gl->ShallowFlushCHROMIUM(); - - gpu::SyncToken sync_token; - gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); - - context_provider_->ContextSupport()->SignalSyncToken( - sync_token, base::Bind(&OutputSurface::OnSwapBuffersComplete, - weak_ptr_factory_.GetWeakPtr())); - client_->DidSwapBuffers(); -} - -uint32_t DirectOutputSurface::GetFramebufferCopyTextureFormat() { - // TODO(danakj): What attributes are used for the default framebuffer here? - // Can it have alpha? SurfacesContextProvider doesn't take any attributes. - return GL_RGB; -} - -} // namespace mus diff --git a/chromium/components/mus/surfaces/direct_output_surface.h b/chromium/components/mus/surfaces/direct_output_surface.h deleted file mode 100644 index 6e08485cfbb..00000000000 --- a/chromium/components/mus/surfaces/direct_output_surface.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2014 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. - -#ifndef COMPONENTS_MUS_SURFACES_DIRECT_OUTPUT_SURFACE_H_ -#define COMPONENTS_MUS_SURFACES_DIRECT_OUTPUT_SURFACE_H_ - -#include <memory> - -#include "cc/output/output_surface.h" -#include "components/mus/surfaces/surfaces_context_provider.h" -#include "components/mus/surfaces/surfaces_context_provider_delegate.h" - -namespace cc { -class CompositorFrame; -class SyntheticBeginFrameSource; -} - -namespace mus { - -// An OutputSurface implementation that directly draws and -// swaps to an actual GL surface. -class DirectOutputSurface : public cc::OutputSurface, - public SurfacesContextProviderDelegate { - public: - explicit DirectOutputSurface( - scoped_refptr<SurfacesContextProvider> context_provider, - cc::SyntheticBeginFrameSource* synthetic_begin_frame_source); - ~DirectOutputSurface() override; - - // cc::OutputSurface implementation - bool BindToClient(cc::OutputSurfaceClient* client) override; - void SwapBuffers(cc::CompositorFrame frame) override; - uint32_t GetFramebufferCopyTextureFormat() override; - - // SurfacesContextProviderDelegate implementation - void OnVSyncParametersUpdated(const base::TimeTicks& timebase, - const base::TimeDelta& interval) override; - - private: - cc::SyntheticBeginFrameSource* const synthetic_begin_frame_source_; - base::WeakPtrFactory<DirectOutputSurface> weak_ptr_factory_; -}; - -} // namespace mus - -#endif // COMPONENTS_MUS_SURFACES_DIRECT_OUTPUT_SURFACE_H_ diff --git a/chromium/components/mus/surfaces/direct_output_surface_ozone.cc b/chromium/components/mus/surfaces/direct_output_surface_ozone.cc deleted file mode 100644 index 5148336078a..00000000000 --- a/chromium/components/mus/surfaces/direct_output_surface_ozone.cc +++ /dev/null @@ -1,166 +0,0 @@ -// 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 "components/mus/surfaces/direct_output_surface_ozone.h" - -#include <utility> - -#include "base/bind.h" -#include "base/memory/ptr_util.h" -#include "cc/output/compositor_frame.h" -#include "cc/output/context_provider.h" -#include "cc/output/output_surface_client.h" -#include "cc/scheduler/begin_frame_source.h" -#include "components/display_compositor/buffer_queue.h" -#include "components/mus/common/gpu_service.h" -#include "components/mus/common/mojo_gpu_memory_buffer_manager.h" -#include "components/mus/gpu/mus_gpu_memory_buffer_manager.h" -#include "components/mus/surfaces/surfaces_context_provider.h" -#include "gpu/command_buffer/client/context_support.h" -#include "gpu/command_buffer/client/gles2_interface.h" - -using display_compositor::BufferQueue; - -namespace mus { - -DirectOutputSurfaceOzone::DirectOutputSurfaceOzone( - scoped_refptr<SurfacesContextProvider> context_provider, - gfx::AcceleratedWidget widget, - cc::SyntheticBeginFrameSource* synthetic_begin_frame_source, - uint32_t target, - uint32_t internalformat) - : cc::OutputSurface(context_provider, nullptr, nullptr), - gl_helper_(context_provider->ContextGL(), - context_provider->ContextSupport()), - synthetic_begin_frame_source_(synthetic_begin_frame_source), - weak_ptr_factory_(this) { - if (!GpuService::UseChromeGpuCommandBuffer()) { - ozone_gpu_memory_buffer_manager_.reset(new OzoneGpuMemoryBufferManager()); - buffer_queue_.reset(new BufferQueue( - context_provider->ContextGL(), target, internalformat, &gl_helper_, - ozone_gpu_memory_buffer_manager_.get(), widget)); - } else { - buffer_queue_.reset(new BufferQueue( - context_provider->ContextGL(), target, internalformat, &gl_helper_, - MusGpuMemoryBufferManager::current(), widget)); - } - - capabilities_.uses_default_gl_framebuffer = false; - capabilities_.flipped_output_surface = true; - // Set |max_frames_pending| to 2 for surfaceless, which aligns scheduling - // more closely with the previous surfaced behavior. - // With a surface, swap buffer ack used to return early, before actually - // presenting the back buffer, enabling the browser compositor to run ahead. - // Surfaceless implementation acks at the time of actual buffer swap, which - // shifts the start of the new frame forward relative to the old - // implementation. - capabilities_.max_frames_pending = 2; - - buffer_queue_->Initialize(); - - context_provider->SetSwapBuffersCompletionCallback( - base::Bind(&DirectOutputSurfaceOzone::OnGpuSwapBuffersCompleted, - base::Unretained(this))); -} - -DirectOutputSurfaceOzone::~DirectOutputSurfaceOzone() { - // TODO(rjkroege): Support cleanup. -} - -bool DirectOutputSurfaceOzone::IsDisplayedAsOverlayPlane() const { - // TODO(rjkroege): implement remaining overlay functionality. - return true; -} - -unsigned DirectOutputSurfaceOzone::GetOverlayTextureId() const { - DCHECK(buffer_queue_); - return buffer_queue_->current_texture_id(); -} - -void DirectOutputSurfaceOzone::SwapBuffers(cc::CompositorFrame frame) { - DCHECK(buffer_queue_); - DCHECK(frame.gl_frame_data); - - buffer_queue_->SwapBuffers(frame.gl_frame_data->sub_buffer_rect); - - // Code combining GpuBrowserCompositorOutputSurface + DirectOutputSurface - 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); - } - - gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL(); - const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM(); - gl->ShallowFlushCHROMIUM(); - - gpu::SyncToken sync_token; - gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); - - client_->DidSwapBuffers(); -} - -bool DirectOutputSurfaceOzone::BindToClient(cc::OutputSurfaceClient* client) { - if (!cc::OutputSurface::BindToClient(client)) - return false; - - if (capabilities_.uses_default_gl_framebuffer) { - capabilities_.flipped_output_surface = - context_provider()->ContextCapabilities().flips_vertically; - } - return true; -} - -void DirectOutputSurfaceOzone::OnUpdateVSyncParametersFromGpu( - base::TimeTicks timebase, - base::TimeDelta interval) { - DCHECK(HasClient()); - synthetic_begin_frame_source_->OnUpdateVSyncParameters(timebase, interval); -} - -void DirectOutputSurfaceOzone::OnGpuSwapBuffersCompleted( - gfx::SwapResult result) { - DCHECK(buffer_queue_); - bool force_swap = false; - if (result == gfx::SwapResult::SWAP_NAK_RECREATE_BUFFERS) { - // Even through the swap failed, this is a fixable error so we can pretend - // it succeeded to the rest of the system. - result = gfx::SwapResult::SWAP_ACK; - buffer_queue_->RecreateBuffers(); - force_swap = true; - } - - buffer_queue_->PageFlipComplete(); - OnSwapBuffersComplete(); - - if (force_swap) - client_->SetNeedsRedrawRect(gfx::Rect(SurfaceSize())); -} - -void DirectOutputSurfaceOzone::BindFramebuffer() { - DCHECK(buffer_queue_); - buffer_queue_->BindFramebuffer(); -} - -uint32_t DirectOutputSurfaceOzone::GetFramebufferCopyTextureFormat() { - return buffer_queue_->internal_format(); -} - -// We call this on every frame but changing the size once we've allocated -// backing NativePixmapOzone instances will cause a DCHECK because -// Chrome never Reshape(s) after the first one from (0,0). NB: this implies -// that screen size changes need to be plumbed differently. In particular, we -// must create the native window in the size that the hardware reports. -void DirectOutputSurfaceOzone::Reshape(const gfx::Size& size, - float scale_factor, - const gfx::ColorSpace& color_space, - bool alpha) { - OutputSurface::Reshape(size, scale_factor, color_space, alpha); - DCHECK(buffer_queue_); - buffer_queue_->Reshape(SurfaceSize(), scale_factor); -} - -} // namespace mus diff --git a/chromium/components/mus/surfaces/direct_output_surface_ozone.h b/chromium/components/mus/surfaces/direct_output_surface_ozone.h deleted file mode 100644 index 8f6f4e4bb76..00000000000 --- a/chromium/components/mus/surfaces/direct_output_surface_ozone.h +++ /dev/null @@ -1,84 +0,0 @@ -// 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. - -#ifndef COMPONENTS_MUS_SURFACES_DIRECT_OUTPUT_SURFACE_OZONE_H_ -#define COMPONENTS_MUS_SURFACES_DIRECT_OUTPUT_SURFACE_OZONE_H_ - -#include <memory> - -#include "base/memory/weak_ptr.h" -#include "cc/output/context_provider.h" -#include "cc/output/output_surface.h" -#include "components/display_compositor/gl_helper.h" -#include "components/mus/surfaces/ozone_gpu_memory_buffer_manager.h" -#include "ui/gfx/geometry/size.h" -#include "ui/gfx/native_widget_types.h" -#include "ui/gfx/swap_result.h" -#include "ui/gl/gl_surface.h" - -namespace display_compositor { -class BufferQueue; -} - -namespace ui { -class LatencyInfo; -} // namespace ui - -namespace cc { -class CompositorFrame; -class SyntheticBeginFrameSource; -} // namespace cc - -namespace mus { - -class SurfacesContextProvider; - -// An OutputSurface implementation that directly draws and swap to a GL -// "surfaceless" surface (aka one backed by a buffer managed explicitly in -// mus/ozone. This class is adapted from -// GpuSurfacelessBrowserCompositorOutputSurface. -class DirectOutputSurfaceOzone : public cc::OutputSurface { - public: - DirectOutputSurfaceOzone( - scoped_refptr<SurfacesContextProvider> context_provider, - gfx::AcceleratedWidget widget, - cc::SyntheticBeginFrameSource* synthetic_begin_frame_source, - uint32_t target, - uint32_t internalformat); - - ~DirectOutputSurfaceOzone() override; - - // TODO(rjkroege): Implement the equivalent of Reflector. - - private: - // cc::OutputSurface implementation. - void SwapBuffers(cc::CompositorFrame frame) override; - void BindFramebuffer() override; - uint32_t GetFramebufferCopyTextureFormat() override; - void Reshape(const gfx::Size& size, - float scale_factor, - const gfx::ColorSpace& color_space, - bool alpha) override; - bool IsDisplayedAsOverlayPlane() const override; - unsigned GetOverlayTextureId() const override; - bool BindToClient(cc::OutputSurfaceClient* client) override; - - // Taken from BrowserCompositor specific API. - void OnUpdateVSyncParametersFromGpu(base::TimeTicks timebase, - base::TimeDelta interval); - - // Called when a swap completion is sent from the GPU process. - void OnGpuSwapBuffersCompleted(gfx::SwapResult result); - - display_compositor::GLHelper gl_helper_; - std::unique_ptr<OzoneGpuMemoryBufferManager> ozone_gpu_memory_buffer_manager_; - std::unique_ptr<display_compositor::BufferQueue> buffer_queue_; - cc::SyntheticBeginFrameSource* const synthetic_begin_frame_source_; - - base::WeakPtrFactory<DirectOutputSurfaceOzone> weak_ptr_factory_; -}; - -} // namespace mus - -#endif // COMPONENTS_MUS_SURFACES_DIRECT_OUTPUT_SURFACE_OZONE_H_ diff --git a/chromium/components/mus/surfaces/display_compositor.cc b/chromium/components/mus/surfaces/display_compositor.cc deleted file mode 100644 index 8ffa0b86276..00000000000 --- a/chromium/components/mus/surfaces/display_compositor.cc +++ /dev/null @@ -1,124 +0,0 @@ -// 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 "components/mus/surfaces/display_compositor.h" - -#include "cc/output/copy_output_request.h" -#include "cc/output/output_surface.h" -#include "cc/output/renderer_settings.h" -#include "cc/output/texture_mailbox_deleter.h" -#include "cc/scheduler/begin_frame_source.h" -#include "cc/scheduler/delay_based_time_source.h" -#include "cc/surfaces/display.h" -#include "cc/surfaces/display_scheduler.h" -#include "components/mus/surfaces/direct_output_surface.h" -#include "components/mus/surfaces/surfaces_context_provider.h" - -#if defined(USE_OZONE) -#include "components/mus/surfaces/direct_output_surface_ozone.h" -#include "gpu/command_buffer/client/gles2_interface.h" -#endif - -namespace mus { - -DisplayCompositor::DisplayCompositor( - scoped_refptr<base::SingleThreadTaskRunner> task_runner, - gfx::AcceleratedWidget widget, - const scoped_refptr<GpuState>& gpu_state, - const scoped_refptr<SurfacesState>& surfaces_state) - : task_runner_(task_runner), - surfaces_state_(surfaces_state), - factory_(surfaces_state->manager(), this), - allocator_(surfaces_state->next_id_namespace()) { - allocator_.RegisterSurfaceIdNamespace(surfaces_state_->manager()); - surfaces_state_->manager()->RegisterSurfaceFactoryClient( - allocator_.id_namespace(), this); - - scoped_refptr<SurfacesContextProvider> surfaces_context_provider( - new SurfacesContextProvider(widget, gpu_state)); - // TODO(rjkroege): If there is something better to do than CHECK, add it. - CHECK(surfaces_context_provider->BindToCurrentThread()); - - std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source( - new cc::DelayBasedBeginFrameSource( - base::MakeUnique<cc::DelayBasedTimeSource>(task_runner_.get()))); - - std::unique_ptr<cc::OutputSurface> display_output_surface; - if (surfaces_context_provider->ContextCapabilities().surfaceless) { -#if defined(USE_OZONE) - display_output_surface = base::WrapUnique(new DirectOutputSurfaceOzone( - surfaces_context_provider, widget, synthetic_begin_frame_source.get(), - GL_TEXTURE_2D, GL_RGB)); -#else - NOTREACHED(); -#endif - } else { - display_output_surface = base::WrapUnique(new DirectOutputSurface( - surfaces_context_provider, synthetic_begin_frame_source.get())); - } - - int max_frames_pending = - display_output_surface->capabilities().max_frames_pending; - DCHECK_GT(max_frames_pending, 0); - - std::unique_ptr<cc::DisplayScheduler> scheduler( - new cc::DisplayScheduler(synthetic_begin_frame_source.get(), - task_runner_.get(), max_frames_pending)); - - display_.reset(new cc::Display( - surfaces_state_->manager(), nullptr /* bitmap_manager */, - nullptr /* gpu_memory_buffer_manager */, cc::RendererSettings(), - allocator_.id_namespace(), std::move(synthetic_begin_frame_source), - std::move(display_output_surface), std::move(scheduler), - base::MakeUnique<cc::TextureMailboxDeleter>(task_runner_.get()))); - display_->Initialize(this); -} - -DisplayCompositor::~DisplayCompositor() { - surfaces_state_->manager()->UnregisterSurfaceFactoryClient( - allocator_.id_namespace()); -} - -void DisplayCompositor::SubmitCompositorFrame( - cc::CompositorFrame frame, - const base::Callback<void(cc::SurfaceDrawStatus)>& callback) { - gfx::Size frame_size = - frame.delegated_frame_data->render_pass_list.back()->output_rect.size(); - if (frame_size.IsEmpty() || frame_size != display_size_) { - if (!surface_id_.is_null()) - factory_.Destroy(surface_id_); - surface_id_ = allocator_.GenerateId(); - factory_.Create(surface_id_); - display_size_ = frame_size; - display_->Resize(display_size_); - } - display_->SetSurfaceId(surface_id_, frame.metadata.device_scale_factor); - factory_.SubmitCompositorFrame(surface_id_, std::move(frame), callback); -} - -void DisplayCompositor::RequestCopyOfOutput( - std::unique_ptr<cc::CopyOutputRequest> output_request) { - factory_.RequestCopyOfSurface(surface_id_, std::move(output_request)); -} - -void DisplayCompositor::ReturnResources( - const cc::ReturnedResourceArray& resources) { - // TODO(fsamuel): Implement this. -} - -void DisplayCompositor::SetBeginFrameSource( - cc::BeginFrameSource* begin_frame_source) { - // TODO(fsamuel): Implement this. -} - -void DisplayCompositor::DisplayOutputSurfaceLost() { - // TODO(fsamuel): This looks like it would crash if a frame was in flight and - // will be submitted. - display_.reset(); -} - -void DisplayCompositor::DisplaySetMemoryPolicy( - const cc::ManagedMemoryPolicy& policy) {} - -} // namespace mus diff --git a/chromium/components/mus/surfaces/display_compositor.h b/chromium/components/mus/surfaces/display_compositor.h deleted file mode 100644 index 27d1eebf3cf..00000000000 --- a/chromium/components/mus/surfaces/display_compositor.h +++ /dev/null @@ -1,80 +0,0 @@ -// 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. - -#ifndef COMPONENTS_MUS_SURFACES_DISPLAY_COMPOSITOR_H_ -#define COMPONENTS_MUS_SURFACES_DISPLAY_COMPOSITOR_H_ - -#include "cc/surfaces/display_client.h" -#include "cc/surfaces/surface.h" -#include "cc/surfaces/surface_factory.h" -#include "cc/surfaces/surface_factory_client.h" -#include "cc/surfaces/surface_id_allocator.h" -#include "components/mus/gles2/gpu_state.h" -#include "components/mus/surfaces/surfaces_state.h" -#include "ui/gfx/native_widget_types.h" - -namespace cc { -class Display; -} - -namespace mus { - -// TODO(fsamuel): This should become a mojo interface for the mus-gpu split. -// TODO(fsamuel): This should not be a SurfaceFactoryClient. -// The DisplayCompositor receives CompositorFrames from all sources, -// creates a top-level CompositorFrame once per tick, and generates graphical -// output. -class DisplayCompositor : public cc::SurfaceFactoryClient, - public cc::DisplayClient { - public: - DisplayCompositor(scoped_refptr<base::SingleThreadTaskRunner> task_runner, - gfx::AcceleratedWidget widget, - const scoped_refptr<GpuState>& gpu_state, - const scoped_refptr<SurfacesState>& surfaces_state); - ~DisplayCompositor() override; - - // DisplayCompositor embedders submit a CompositorFrame when content on the - // display should be changed. A well-behaving embedder should only submit - // a CompositorFrame once per BeginFrame tick. The callback is called the - // first time this frame is used to draw, or if the frame is discarded. - void SubmitCompositorFrame( - cc::CompositorFrame frame, - const base::Callback<void(cc::SurfaceDrawStatus)>& callback); - - // TODO(fsamuel): This is used for surface hittesting and should not be - // exposed outside of DisplayCompositor. - const cc::SurfaceId& surface_id() const { return surface_id_; } - - // This requests the display CompositorFrame be rendered and given to the - // callback within CopyOutputRequest. - void RequestCopyOfOutput( - std::unique_ptr<cc::CopyOutputRequest> output_request); - - // TODO(fsamuel): Invent an async way to create a SurfaceNamespace - // A SurfaceNamespace can create CompositorFrameSinks where the client can - // make up the ID. - - private: - // SurfaceFactoryClient implementation. - void ReturnResources(const cc::ReturnedResourceArray& resources) override; - void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; - - // DisplayClient implementation. - void DisplayOutputSurfaceLost() override; - void DisplaySetMemoryPolicy(const cc::ManagedMemoryPolicy& policy) override; - - scoped_refptr<base::SingleThreadTaskRunner> task_runner_; - scoped_refptr<SurfacesState> surfaces_state_; - cc::SurfaceFactory factory_; - cc::SurfaceIdAllocator allocator_; - cc::SurfaceId surface_id_; - - gfx::Size display_size_; - std::unique_ptr<cc::Display> display_; - DISALLOW_COPY_AND_ASSIGN(DisplayCompositor); -}; - -} // namespace mus - -#endif // COMPONENTS_MUS_SURFACES_DISPLAY_COMPOSITOR_H_ diff --git a/chromium/components/mus/surfaces/ozone_gpu_memory_buffer_manager.cc b/chromium/components/mus/surfaces/ozone_gpu_memory_buffer_manager.cc deleted file mode 100644 index b14cd1394fe..00000000000 --- a/chromium/components/mus/surfaces/ozone_gpu_memory_buffer_manager.cc +++ /dev/null @@ -1,49 +0,0 @@ -// 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 "components/mus/surfaces/ozone_gpu_memory_buffer_manager.h" - -#include "components/mus/gles2/ozone_gpu_memory_buffer.h" -#include "gpu/command_buffer/common/gpu_memory_buffer_support.h" -#include "ui/gfx/buffer_types.h" - -namespace mus { - -OzoneGpuMemoryBufferManager::OzoneGpuMemoryBufferManager() {} - -OzoneGpuMemoryBufferManager::~OzoneGpuMemoryBufferManager() {} - -std::unique_ptr<gfx::GpuMemoryBuffer> -OzoneGpuMemoryBufferManager::AllocateGpuMemoryBuffer( - const gfx::Size& size, - gfx::BufferFormat format, - gfx::BufferUsage usage, - gpu::SurfaceHandle surface_handle) { - return OzoneGpuMemoryBuffer::CreateOzoneGpuMemoryBuffer( - size, format, gfx::BufferUsage::SCANOUT, surface_handle); -} - -std::unique_ptr<gfx::GpuMemoryBuffer> -OzoneGpuMemoryBufferManager::CreateGpuMemoryBufferFromHandle( - const gfx::GpuMemoryBufferHandle& handle, - const gfx::Size& size, - gfx::BufferFormat format) { - NOTIMPLEMENTED(); - return nullptr; -} - -gfx::GpuMemoryBuffer* -OzoneGpuMemoryBufferManager::GpuMemoryBufferFromClientBuffer( - ClientBuffer buffer) { - NOTIMPLEMENTED(); - return nullptr; -} - -void OzoneGpuMemoryBufferManager::SetDestructionSyncToken( - gfx::GpuMemoryBuffer* buffer, - const gpu::SyncToken& sync_token) { - NOTIMPLEMENTED(); -} - -} // namespace mus diff --git a/chromium/components/mus/surfaces/ozone_gpu_memory_buffer_manager.h b/chromium/components/mus/surfaces/ozone_gpu_memory_buffer_manager.h deleted file mode 100644 index d6cf15f55fe..00000000000 --- a/chromium/components/mus/surfaces/ozone_gpu_memory_buffer_manager.h +++ /dev/null @@ -1,39 +0,0 @@ -// 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. - -#ifndef COMPONENTS_MUS_SURFACES_DIRECT_OUTPUT_SURFACES_OZONE_H_ -#define COMPONENTS_MUS_SURFACES_DIRECT_OUTPUT_SURFACES_OZONE_H_ - -#include "base/macros.h" -#include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" - -namespace mus { - -class OzoneGpuMemoryBufferManager : public gpu::GpuMemoryBufferManager { - public: - OzoneGpuMemoryBufferManager(); - ~OzoneGpuMemoryBufferManager() override; - - // gpu::GpuMemoryBufferManager: - std::unique_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBuffer( - const gfx::Size& size, - gfx::BufferFormat format, - gfx::BufferUsage usage, - gpu::SurfaceHandle surface_handle) override; - std::unique_ptr<gfx::GpuMemoryBuffer> CreateGpuMemoryBufferFromHandle( - const gfx::GpuMemoryBufferHandle& handle, - const gfx::Size& size, - gfx::BufferFormat format) override; - gfx::GpuMemoryBuffer* GpuMemoryBufferFromClientBuffer( - ClientBuffer buffer) override; - void SetDestructionSyncToken(gfx::GpuMemoryBuffer* buffer, - const gpu::SyncToken& sync_token) override; - - private: - DISALLOW_COPY_AND_ASSIGN(OzoneGpuMemoryBufferManager); -}; - -} // namespace mus - -#endif // COMPONENTS_MUS_SURFACES_DIRECT_OUTPUT_SURFACES_OZONE_H_ diff --git a/chromium/components/mus/surfaces/surfaces_context_provider.cc b/chromium/components/mus/surfaces/surfaces_context_provider.cc deleted file mode 100644 index 291a4402eb5..00000000000 --- a/chromium/components/mus/surfaces/surfaces_context_provider.cc +++ /dev/null @@ -1,206 +0,0 @@ -// Copyright 2014 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 "components/mus/surfaces/surfaces_context_provider.h" - -#include <stddef.h> - -#include "base/bind.h" -#include "base/bind_helpers.h" -#include "base/command_line.h" -#include "base/synchronization/waitable_event.h" -#include "base/threading/thread_task_runner_handle.h" -#include "build/build_config.h" -#include "components/mus/common/switches.h" -#include "components/mus/gles2/command_buffer_driver.h" -#include "components/mus/gles2/command_buffer_impl.h" -#include "components/mus/gles2/command_buffer_local.h" -#include "components/mus/gles2/gpu_state.h" -#include "components/mus/gpu/gpu_service_mus.h" -#include "components/mus/surfaces/surfaces_context_provider_delegate.h" -#include "gpu/command_buffer/client/gles2_cmd_helper.h" -#include "gpu/command_buffer/client/gles2_implementation.h" -#include "gpu/command_buffer/client/shared_memory_limits.h" -#include "gpu/command_buffer/client/transfer_buffer.h" -#include "gpu/ipc/client/command_buffer_proxy_impl.h" -#include "ui/gl/gpu_preference.h" - -namespace mus { - -SurfacesContextProvider::SurfacesContextProvider( - gfx::AcceleratedWidget widget, - const scoped_refptr<GpuState>& state) - : use_chrome_gpu_command_buffer_(false), - delegate_(nullptr), - widget_(widget), - command_buffer_local_(nullptr) { -// TODO(penghuang): Kludge: Use mojo command buffer when running on Windows -// since Chrome command buffer breaks unit tests -#if defined(OS_WIN) - use_chrome_gpu_command_buffer_ = false; -#else - use_chrome_gpu_command_buffer_ = - !base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kUseMojoGpuCommandBufferInMus); -#endif - if (!use_chrome_gpu_command_buffer_) { - command_buffer_local_ = new CommandBufferLocal(this, widget_, state); - } else { - GpuServiceMus* service = GpuServiceMus::GetInstance(); - gpu::CommandBufferProxyImpl* shared_command_buffer = nullptr; - gpu::GpuStreamId stream_id = gpu::GpuStreamId::GPU_STREAM_DEFAULT; - gpu::GpuStreamPriority stream_priority = gpu::GpuStreamPriority::NORMAL; - gpu::gles2::ContextCreationAttribHelper attributes; - attributes.alpha_size = -1; - attributes.depth_size = 0; - attributes.stencil_size = 0; - attributes.samples = 0; - attributes.sample_buffers = 0; - attributes.bind_generates_resource = false; - attributes.lose_context_when_out_of_memory = true; - GURL active_url; - scoped_refptr<base::SingleThreadTaskRunner> task_runner = - base::ThreadTaskRunnerHandle::Get(); - command_buffer_proxy_impl_ = gpu::CommandBufferProxyImpl::Create( - service->gpu_channel_local(), widget, shared_command_buffer, stream_id, - stream_priority, attributes, active_url, task_runner); - command_buffer_proxy_impl_->SetSwapBuffersCompletionCallback( - base::Bind(&SurfacesContextProvider::OnGpuSwapBuffersCompleted, - base::Unretained(this))); - command_buffer_proxy_impl_->SetUpdateVSyncParametersCallback( - base::Bind(&SurfacesContextProvider::OnUpdateVSyncParameters, - base::Unretained(this))); - } -} - -void SurfacesContextProvider::SetDelegate( - SurfacesContextProviderDelegate* delegate) { - DCHECK(!delegate_); - delegate_ = delegate; -} - -// This routine needs to be safe to call more than once. -// This is called when we have an accelerated widget. -bool SurfacesContextProvider::BindToCurrentThread() { - if (implementation_) - return true; - - // SurfacesContextProvider should always live on the same thread as the - // Window Manager. - DCHECK(CalledOnValidThread()); - gpu::GpuControl* gpu_control = nullptr; - gpu::CommandBuffer* command_buffer = nullptr; - if (!use_chrome_gpu_command_buffer_) { - if (!command_buffer_local_->Initialize()) - return false; - gpu_control = command_buffer_local_; - command_buffer = command_buffer_local_; - } else { - if (!command_buffer_proxy_impl_) - return false; - gpu_control = command_buffer_proxy_impl_.get(); - command_buffer = command_buffer_proxy_impl_.get(); - } - - gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(command_buffer)); - constexpr gpu::SharedMemoryLimits default_limits; - if (!gles2_helper_->Initialize(default_limits.command_buffer_size)) - return false; - gles2_helper_->SetAutomaticFlushes(false); - transfer_buffer_.reset(new gpu::TransferBuffer(gles2_helper_.get())); - capabilities_ = gpu_control->GetCapabilities(); - bool bind_generates_resource = - !!capabilities_.bind_generates_resource_chromium; - // TODO(piman): Some contexts (such as compositor) want this to be true, so - // this needs to be a public parameter. - bool lose_context_when_out_of_memory = false; - bool support_client_side_arrays = false; - implementation_.reset(new gpu::gles2::GLES2Implementation( - gles2_helper_.get(), NULL, transfer_buffer_.get(), - bind_generates_resource, lose_context_when_out_of_memory, - support_client_side_arrays, gpu_control)); - return implementation_->Initialize( - default_limits.start_transfer_buffer_size, - default_limits.min_transfer_buffer_size, - default_limits.max_transfer_buffer_size, - default_limits.mapped_memory_reclaim_limit); -} - -gpu::gles2::GLES2Interface* SurfacesContextProvider::ContextGL() { - DCHECK(implementation_); - return implementation_.get(); -} - -gpu::ContextSupport* SurfacesContextProvider::ContextSupport() { - return implementation_.get(); -} - -class GrContext* SurfacesContextProvider::GrContext() { - return NULL; -} - -void SurfacesContextProvider::InvalidateGrContext(uint32_t state) {} - -gpu::Capabilities SurfacesContextProvider::ContextCapabilities() { - return capabilities_; -} - -base::Lock* SurfacesContextProvider::GetLock() { - // This context provider is not used on multiple threads. - NOTREACHED(); - return nullptr; -} - -void SurfacesContextProvider::SetLostContextCallback( - const LostContextCallback& lost_context_callback) { - implementation_->SetLostContextCallback(lost_context_callback); -} - -SurfacesContextProvider::~SurfacesContextProvider() { - implementation_->Flush(); - implementation_.reset(); - transfer_buffer_.reset(); - gles2_helper_.reset(); - command_buffer_proxy_impl_.reset(); - if (command_buffer_local_) { - command_buffer_local_->Destroy(); - command_buffer_local_ = nullptr; - } -} - -void SurfacesContextProvider::UpdateVSyncParameters( - const base::TimeTicks& timebase, - const base::TimeDelta& interval) { - if (delegate_) - delegate_->OnVSyncParametersUpdated(timebase, interval); -} - -void SurfacesContextProvider::GpuCompletedSwapBuffers(gfx::SwapResult result) { - if (!swap_buffers_completion_callback_.is_null()) { - swap_buffers_completion_callback_.Run(result); - } -} - -void SurfacesContextProvider::OnGpuSwapBuffersCompleted( - const std::vector<ui::LatencyInfo>& latency_info, - gfx::SwapResult result, - const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac) { - if (!swap_buffers_completion_callback_.is_null()) { - swap_buffers_completion_callback_.Run(result); - } -} - -void SurfacesContextProvider::OnUpdateVSyncParameters( - base::TimeTicks timebase, - base::TimeDelta interval) { - if (delegate_) - delegate_->OnVSyncParametersUpdated(timebase, interval); -} - -void SurfacesContextProvider::SetSwapBuffersCompletionCallback( - gl::GLSurface::SwapCompletionCallback callback) { - swap_buffers_completion_callback_ = callback; -} - -} // namespace mus diff --git a/chromium/components/mus/surfaces/surfaces_context_provider.h b/chromium/components/mus/surfaces/surfaces_context_provider.h deleted file mode 100644 index 8dab0bcb9d6..00000000000 --- a/chromium/components/mus/surfaces/surfaces_context_provider.h +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright 2014 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. - -#ifndef COMPONENTS_MUS_SURFACES_SURFACES_CONTEXT_PROVIDER_H_ -#define COMPONENTS_MUS_SURFACES_SURFACES_CONTEXT_PROVIDER_H_ - -#include <stdint.h> - -#include <memory> - -#include "base/macros.h" -#include "base/threading/non_thread_safe.h" -#include "cc/output/context_provider.h" -#include "components/mus/gles2/command_buffer_local_client.h" -#include "ui/gfx/native_widget_types.h" -#include "ui/gl/gl_surface.h" - -namespace gpu { - -class CommandBufferProxyImpl; -struct GpuProcessHostedCALayerTreeParamsMac; -class TransferBuffer; - -namespace gles2 { -class GLES2CmdHelper; -class GLES2Implementation; -} - -} // namespace gpu - -namespace ui { -class LatencyInfo; -} - -namespace mus { - -class CommandBufferDriver; -class CommandBufferImpl; -class CommandBufferLocal; -class GpuState; -class SurfacesContextProviderDelegate; - -class SurfacesContextProvider : public cc::ContextProvider, - public CommandBufferLocalClient, - public base::NonThreadSafe { - public: - SurfacesContextProvider(gfx::AcceleratedWidget widget, - const scoped_refptr<GpuState>& state); - - void SetDelegate(SurfacesContextProviderDelegate* delegate); - - // cc::ContextProvider implementation. - bool BindToCurrentThread() override; - gpu::gles2::GLES2Interface* ContextGL() override; - gpu::ContextSupport* ContextSupport() override; - class GrContext* GrContext() override; - void InvalidateGrContext(uint32_t state) override; - gpu::Capabilities ContextCapabilities() override; - void DeleteCachedResources() override {} - void SetLostContextCallback( - const LostContextCallback& lost_context_callback) override; - base::Lock* GetLock() override; - - // SurfacesContextProvider API. - void SetSwapBuffersCompletionCallback( - gl::GLSurface::SwapCompletionCallback callback); - - protected: - friend class base::RefCountedThreadSafe<SurfacesContextProvider>; - ~SurfacesContextProvider() override; - - private: - // CommandBufferLocalClient: - void UpdateVSyncParameters(const base::TimeTicks& timebase, - const base::TimeDelta& interval) override; - void GpuCompletedSwapBuffers(gfx::SwapResult result) override; - - // Callbacks for CommandBufferProxyImpl: - void OnGpuSwapBuffersCompleted( - const std::vector<ui::LatencyInfo>& latency_info, - gfx::SwapResult result, - const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac); - void OnUpdateVSyncParameters(base::TimeTicks timebase, - base::TimeDelta interval); - - bool use_chrome_gpu_command_buffer_; - - // From GLES2Context: - // Initialized in BindToCurrentThread. - std::unique_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_; - std::unique_ptr<gpu::TransferBuffer> transfer_buffer_; - std::unique_ptr<gpu::gles2::GLES2Implementation> implementation_; - - gpu::Capabilities capabilities_; - LostContextCallback lost_context_callback_; - - SurfacesContextProviderDelegate* delegate_; - gfx::AcceleratedWidget widget_; - CommandBufferLocal* command_buffer_local_; - std::unique_ptr<gpu::CommandBufferProxyImpl> command_buffer_proxy_impl_; - gl::GLSurface::SwapCompletionCallback swap_buffers_completion_callback_; - - DISALLOW_COPY_AND_ASSIGN(SurfacesContextProvider); -}; - -} // namespace mus - -#endif // COMPONENTS_MUS_SURFACES_SURFACES_CONTEXT_PROVIDER_H_ diff --git a/chromium/components/mus/surfaces/surfaces_context_provider_delegate.h b/chromium/components/mus/surfaces/surfaces_context_provider_delegate.h deleted file mode 100644 index 170190a923f..00000000000 --- a/chromium/components/mus/surfaces/surfaces_context_provider_delegate.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2015 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. - -#ifndef COMPONENTS_MUS_SURFACES_SURFACES_CONTEXT_PROVIDER_DELEGATE_H_ -#define COMPONENTS_MUS_SURFACES_SURFACES_CONTEXT_PROVIDER_DELEGATE_H_ - -#include <stdint.h> - -namespace base { -class TimeDelta; -class TimeTicks; -} - -namespace mus { - -class SurfacesContextProviderDelegate { - public: - virtual void OnVSyncParametersUpdated(const base::TimeTicks& timebase, - const base::TimeDelta& interval) = 0; - - protected: - virtual ~SurfacesContextProviderDelegate() {} -}; - -} // namespace mus - -#endif // COMPONENTS_MUS_SURFACES_SURFACES_CONTEXT_PROVIDER_DELEGATE_H_ diff --git a/chromium/components/mus/surfaces/surfaces_state.cc b/chromium/components/mus/surfaces/surfaces_state.cc deleted file mode 100644 index e3dfeb8d85d..00000000000 --- a/chromium/components/mus/surfaces/surfaces_state.cc +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2015 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 "components/mus/surfaces/surfaces_state.h" - -namespace mus { - -SurfacesState::SurfacesState() : next_id_namespace_(1u) {} - -SurfacesState::~SurfacesState() {} - -} // namespace mus diff --git a/chromium/components/mus/surfaces/surfaces_state.h b/chromium/components/mus/surfaces/surfaces_state.h deleted file mode 100644 index daaf5587ab6..00000000000 --- a/chromium/components/mus/surfaces/surfaces_state.h +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2015 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. - -#ifndef COMPONENTS_MUS_SURFACES_SURFACES_STATE_H_ -#define COMPONENTS_MUS_SURFACES_SURFACES_STATE_H_ - -#include <stdint.h> - -#include "base/macros.h" -#include "base/memory/ref_counted.h" -#include "cc/surfaces/surface_manager.h" - -namespace cc { -class SurfaceHittest; -class SurfaceManager; -} // namespace cc - -namespace mus { - -// The SurfacesState object is an object global to the Window Manager app that -// holds the SurfaceManager and allocates new Surfaces namespaces. -// This object lives on the main thread of the Window Manager. -// TODO(rjkroege, fsamuel): This object will need to change to support multiple -// displays. -class SurfacesState : public base::RefCounted<SurfacesState> { - public: - SurfacesState(); - - uint32_t next_id_namespace() { return next_id_namespace_++; } - - cc::SurfaceManager* manager() { return &manager_; } - - private: - friend class base::RefCounted<SurfacesState>; - ~SurfacesState(); - - // A Surface ID is an unsigned 64-bit int where the high 32-bits are generated - // by the Surfaces service, and the low 32-bits are generated by the process - // that requested the Surface. - uint32_t next_id_namespace_; - cc::SurfaceManager manager_; - - DISALLOW_COPY_AND_ASSIGN(SurfacesState); -}; - -} // namespace mus - -#endif // COMPONENTS_MUS_SURFACES_SURFACES_STATE_H_ |