1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "mandoline/ui/aura/surface_context_factory.h"
7 #include "cc/output/output_surface.h"
8 #include "cc/resources/shared_bitmap_manager.h"
9 #include "cc/surfaces/surface_id_allocator.h"
10 #include "components/view_manager/public/cpp/view.h"
11 #include "mojo/application/public/interfaces/shell.mojom.h"
12 #include "ui/compositor/reflector.h"
13 #include "ui/gl/gl_bindings.h"
18 class FakeReflector
: public ui::Reflector
{
21 ~FakeReflector() override
{}
22 void OnMirroringCompositorResized() override
{}
23 void AddMirroringLayer(ui::Layer
* layer
) override
{}
24 void RemoveMirroringLayer(ui::Layer
* layer
) override
{}
29 SurfaceContextFactory::SurfaceContextFactory(mojo::Shell
* shell
,
31 : surface_binding_(shell
, view
),
32 next_surface_id_namespace_(1u) {
35 SurfaceContextFactory::~SurfaceContextFactory() {
38 void SurfaceContextFactory::CreateOutputSurface(
39 base::WeakPtr
<ui::Compositor
> compositor
) {
41 compositor
->SetOutputSurface(surface_binding_
.CreateOutputSurface());
44 scoped_ptr
<ui::Reflector
> SurfaceContextFactory::CreateReflector(
45 ui::Compositor
* mirroed_compositor
,
46 ui::Layer
* mirroring_layer
) {
48 return make_scoped_ptr(new FakeReflector
);
51 void SurfaceContextFactory::RemoveReflector(ui::Reflector
* reflector
) {
55 scoped_refptr
<cc::ContextProvider
>
56 SurfaceContextFactory::SharedMainThreadContextProvider() {
61 void SurfaceContextFactory::RemoveCompositor(ui::Compositor
* compositor
) {
65 bool SurfaceContextFactory::DoesCreateTestContexts() {
69 uint32
SurfaceContextFactory::GetImageTextureTarget(gfx::BufferFormat format
,
70 gfx::BufferUsage usage
) {
71 // No GpuMemoryBuffer support, so just return GL_TEXTURE_2D.
75 cc::SharedBitmapManager
* SurfaceContextFactory::GetSharedBitmapManager() {
80 gpu::GpuMemoryBufferManager
*
81 SurfaceContextFactory::GetGpuMemoryBufferManager() {
82 return &gpu_memory_buffer_manager_
;
85 cc::TaskGraphRunner
* SurfaceContextFactory::GetTaskGraphRunner() {
86 return raster_thread_helper_
.task_graph_runner();
89 scoped_ptr
<cc::SurfaceIdAllocator
>
90 SurfaceContextFactory::CreateSurfaceIdAllocator() {
91 return make_scoped_ptr(
92 new cc::SurfaceIdAllocator(next_surface_id_namespace_
++));
95 void SurfaceContextFactory::ResizeDisplay(ui::Compositor
* compositor
,
96 const gfx::Size
& size
) {
100 } // namespace mandoline