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
3 // found in the LICENSE file.
5 #ifndef CC_SURFACES_DISPLAY_H_
6 #define CC_SURFACES_DISPLAY_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "cc/output/output_surface_client.h"
10 #include "cc/output/renderer.h"
11 #include "cc/resources/returned_resource.h"
12 #include "cc/surfaces/surface_aggregator.h"
13 #include "cc/surfaces/surface_id.h"
14 #include "cc/surfaces/surface_manager.h"
15 #include "cc/surfaces/surfaces_export.h"
23 class BlockingTaskRunner
;
27 class RendererSettings
;
28 class ResourceProvider
;
29 class SharedBitmapManager
;
31 class SurfaceAggregator
;
32 class SurfaceIdAllocator
;
34 class TextureMailboxDeleter
;
36 // A Display produces a surface that can be used to draw to a physical display
37 // (OutputSurface). The client is responsible for creating and sizing the
38 // surface IDs used to draw into the display and deciding when to draw.
39 class CC_SURFACES_EXPORT Display
: public OutputSurfaceClient
,
40 public RendererClient
,
41 public SurfaceDamageObserver
{
43 Display(DisplayClient
* client
,
44 SurfaceManager
* manager
,
45 SharedBitmapManager
* bitmap_manager
,
46 gpu::GpuMemoryBufferManager
* gpu_memory_buffer_manager
,
47 const RendererSettings
& settings
);
50 bool Initialize(scoped_ptr
<OutputSurface
> output_surface
);
52 // device_scale_factor is used to communicate to the external window system
53 // what scale this was rendered at.
54 void Resize(SurfaceId id
,
55 const gfx::Size
& new_size
,
56 float device_scale_factor
);
59 SurfaceId
CurrentSurfaceId();
60 int GetMaxFramesPending();
62 // OutputSurfaceClient implementation.
63 void DeferredInitialize() override
{}
64 void ReleaseGL() override
{}
65 void CommitVSyncParameters(base::TimeTicks timebase
,
66 base::TimeDelta interval
) override
;
67 void SetNeedsRedrawRect(const gfx::Rect
& damage_rect
) override
{}
68 void DidSwapBuffers() override
;
69 void DidSwapBuffersComplete() override
;
70 void ReclaimResources(const CompositorFrameAck
* ack
) override
{}
71 void DidLoseOutputSurface() override
;
72 void SetExternalDrawConstraints(
73 const gfx::Transform
& transform
,
74 const gfx::Rect
& viewport
,
75 const gfx::Rect
& clip
,
76 const gfx::Rect
& viewport_rect_for_tile_priority
,
77 const gfx::Transform
& transform_for_tile_priority
,
78 bool resourceless_software_draw
) override
{}
79 void SetMemoryPolicy(const ManagedMemoryPolicy
& policy
) override
;
80 void SetTreeActivationCallback(const base::Closure
& callback
) override
{}
82 // RendererClient implementation.
83 void SetFullRootLayerDamage() override
{}
85 // SurfaceDamageObserver implementation.
86 void OnSurfaceDamaged(SurfaceId surface
) override
;
89 void InitializeRenderer();
91 DisplayClient
* client_
;
92 SurfaceManager
* manager_
;
93 SharedBitmapManager
* bitmap_manager_
;
94 gpu::GpuMemoryBufferManager
* gpu_memory_buffer_manager_
;
95 RendererSettings settings_
;
96 SurfaceId current_surface_id_
;
97 gfx::Size current_surface_size_
;
98 float device_scale_factor_
;
99 scoped_ptr
<OutputSurface
> output_surface_
;
100 scoped_ptr
<ResourceProvider
> resource_provider_
;
101 scoped_ptr
<SurfaceAggregator
> aggregator_
;
102 scoped_ptr
<DirectRenderer
> renderer_
;
103 scoped_ptr
<BlockingTaskRunner
> blocking_main_thread_task_runner_
;
104 scoped_ptr
<TextureMailboxDeleter
> texture_mailbox_deleter_
;
106 DISALLOW_COPY_AND_ASSIGN(Display
);
111 #endif // CC_SURFACES_DISPLAY_H_