Automated Commit: Committing new LKGM version 6953.0.0 for chromeos.
[chromium-blink-merge.git] / cc / surfaces / display.h
blob78b3054c9e0f52f4f9b62161179420c91bb7d8e1
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 <vector>
10 #include "base/memory/scoped_ptr.h"
11 #include "cc/output/output_surface_client.h"
12 #include "cc/output/renderer.h"
13 #include "cc/resources/returned_resource.h"
14 #include "cc/surfaces/surface_aggregator.h"
15 #include "cc/surfaces/surface_id.h"
16 #include "cc/surfaces/surface_manager.h"
17 #include "cc/surfaces/surfaces_export.h"
18 #include "ui/events/latency_info.h"
20 namespace gpu {
21 class GpuMemoryBufferManager;
24 namespace gfx {
25 class Size;
28 namespace cc {
30 class BlockingTaskRunner;
31 class DirectRenderer;
32 class DisplayClient;
33 class OutputSurface;
34 class RendererSettings;
35 class ResourceProvider;
36 class SharedBitmapManager;
37 class Surface;
38 class SurfaceAggregator;
39 class SurfaceIdAllocator;
40 class SurfaceFactory;
41 class TextureMailboxDeleter;
43 // A Display produces a surface that can be used to draw to a physical display
44 // (OutputSurface). The client is responsible for creating and sizing the
45 // surface IDs used to draw into the display and deciding when to draw.
46 class CC_SURFACES_EXPORT Display : public OutputSurfaceClient,
47 public RendererClient,
48 public SurfaceDamageObserver {
49 public:
50 Display(DisplayClient* client,
51 SurfaceManager* manager,
52 SharedBitmapManager* bitmap_manager,
53 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
54 const RendererSettings& settings);
55 ~Display() override;
57 bool Initialize(scoped_ptr<OutputSurface> output_surface);
59 // device_scale_factor is used to communicate to the external window system
60 // what scale this was rendered at.
61 void SetSurfaceId(SurfaceId id, float device_scale_factor);
62 void Resize(const gfx::Size& new_size);
63 bool Draw();
65 SurfaceId CurrentSurfaceId();
66 int GetMaxFramesPending();
68 // OutputSurfaceClient implementation.
69 void DeferredInitialize() override;
70 void ReleaseGL() override;
71 void CommitVSyncParameters(base::TimeTicks timebase,
72 base::TimeDelta interval) override;
73 void SetNeedsRedrawRect(const gfx::Rect& damage_rect) override;
74 void DidSwapBuffers() override;
75 void DidSwapBuffersComplete() override;
76 void ReclaimResources(const CompositorFrameAck* ack) override;
77 void DidLoseOutputSurface() override;
78 void SetExternalDrawConstraints(
79 const gfx::Transform& transform,
80 const gfx::Rect& viewport,
81 const gfx::Rect& clip,
82 const gfx::Rect& viewport_rect_for_tile_priority,
83 const gfx::Transform& transform_for_tile_priority,
84 bool resourceless_software_draw) override;
85 void SetMemoryPolicy(const ManagedMemoryPolicy& policy) override;
86 void SetTreeActivationCallback(const base::Closure& callback) override;
87 void OnDraw() override;
89 // RendererClient implementation.
90 void SetFullRootLayerDamage() override;
92 // SurfaceDamageObserver implementation.
93 void OnSurfaceDamaged(SurfaceId surface, bool* changed) override;
95 private:
96 void InitializeRenderer();
98 DisplayClient* client_;
99 SurfaceManager* manager_;
100 SharedBitmapManager* bitmap_manager_;
101 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_;
102 RendererSettings settings_;
103 SurfaceId current_surface_id_;
104 gfx::Size current_surface_size_;
105 float device_scale_factor_;
106 scoped_ptr<OutputSurface> output_surface_;
107 scoped_ptr<ResourceProvider> resource_provider_;
108 scoped_ptr<SurfaceAggregator> aggregator_;
109 scoped_ptr<DirectRenderer> renderer_;
110 scoped_ptr<BlockingTaskRunner> blocking_main_thread_task_runner_;
111 scoped_ptr<TextureMailboxDeleter> texture_mailbox_deleter_;
112 std::vector<ui::LatencyInfo> stored_latency_info_;
114 DISALLOW_COPY_AND_ASSIGN(Display);
117 } // namespace cc
119 #endif // CC_SURFACES_DISPLAY_H_