Roll src/third_party/skia 57a48a7:de7665a
[chromium-blink-merge.git] / cc / surfaces / display.h
blobed96d07dd28e4a00129d31a6689a4bd7b87b51bf
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"
19 namespace gfx {
20 class Size;
23 namespace cc {
25 class BlockingTaskRunner;
26 class DirectRenderer;
27 class DisplayClient;
28 class OutputSurface;
29 class RendererSettings;
30 class ResourceProvider;
31 class SharedBitmapManager;
32 class Surface;
33 class SurfaceAggregator;
34 class SurfaceIdAllocator;
35 class SurfaceFactory;
36 class TextureMailboxDeleter;
38 // A Display produces a surface that can be used to draw to a physical display
39 // (OutputSurface). The client is responsible for creating and sizing the
40 // surface IDs used to draw into the display and deciding when to draw.
41 class CC_SURFACES_EXPORT Display : public OutputSurfaceClient,
42 public RendererClient,
43 public SurfaceDamageObserver {
44 public:
45 Display(DisplayClient* client,
46 SurfaceManager* manager,
47 SharedBitmapManager* bitmap_manager,
48 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager,
49 const RendererSettings& settings);
50 ~Display() override;
52 bool Initialize(scoped_ptr<OutputSurface> output_surface);
54 // device_scale_factor is used to communicate to the external window system
55 // what scale this was rendered at.
56 void SetSurfaceId(SurfaceId id, float device_scale_factor);
57 void Resize(const gfx::Size& new_size);
58 bool Draw();
60 SurfaceId CurrentSurfaceId();
61 int GetMaxFramesPending();
63 // OutputSurfaceClient implementation.
64 void DeferredInitialize() override {}
65 void ReleaseGL() override {}
66 void CommitVSyncParameters(base::TimeTicks timebase,
67 base::TimeDelta interval) override;
68 void SetNeedsRedrawRect(const gfx::Rect& damage_rect) override {}
69 void DidSwapBuffers() override;
70 void DidSwapBuffersComplete() override;
71 void ReclaimResources(const CompositorFrameAck* ack) override {}
72 void DidLoseOutputSurface() override;
73 void SetExternalDrawConstraints(
74 const gfx::Transform& transform,
75 const gfx::Rect& viewport,
76 const gfx::Rect& clip,
77 const gfx::Rect& viewport_rect_for_tile_priority,
78 const gfx::Transform& transform_for_tile_priority,
79 bool resourceless_software_draw) override {}
80 void SetMemoryPolicy(const ManagedMemoryPolicy& policy) override;
81 void SetTreeActivationCallback(const base::Closure& callback) override {}
83 // RendererClient implementation.
84 void SetFullRootLayerDamage() override {}
86 // SurfaceDamageObserver implementation.
87 void OnSurfaceDamaged(SurfaceId surface, bool* changed) override;
89 private:
90 void InitializeRenderer();
92 DisplayClient* client_;
93 SurfaceManager* manager_;
94 SharedBitmapManager* bitmap_manager_;
95 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager_;
96 RendererSettings settings_;
97 SurfaceId current_surface_id_;
98 gfx::Size current_surface_size_;
99 float device_scale_factor_;
100 scoped_ptr<OutputSurface> output_surface_;
101 scoped_ptr<ResourceProvider> resource_provider_;
102 scoped_ptr<SurfaceAggregator> aggregator_;
103 scoped_ptr<DirectRenderer> renderer_;
104 scoped_ptr<BlockingTaskRunner> blocking_main_thread_task_runner_;
105 scoped_ptr<TextureMailboxDeleter> texture_mailbox_deleter_;
106 std::vector<ui::LatencyInfo> stored_latency_info_;
108 DISALLOW_COPY_AND_ASSIGN(Display);
111 } // namespace cc
113 #endif // CC_SURFACES_DISPLAY_H_