• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef CC_SURFACES_DISPLAY_H_
6 #define CC_SURFACES_DISPLAY_H_
7 
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"
16 
17 namespace gfx {
18 class Size;
19 }
20 
21 namespace cc {
22 
23 class BlockingTaskRunner;
24 class DirectRenderer;
25 class DisplayClient;
26 class OutputSurface;
27 class ResourceProvider;
28 class SharedBitmapManager;
29 class Surface;
30 class SurfaceAggregator;
31 class SurfaceIdAllocator;
32 class SurfaceFactory;
33 
34 // A Display produces a surface that can be used to draw to a physical display
35 // (OutputSurface). The client is responsible for creating and sizing the
36 // surface IDs used to draw into the display and deciding when to draw.
37 class CC_SURFACES_EXPORT Display : public OutputSurfaceClient,
38                                    public RendererClient,
39                                    public SurfaceDamageObserver {
40  public:
41   Display(DisplayClient* client,
42           SurfaceManager* manager,
43           SharedBitmapManager* bitmap_manager);
44   virtual ~Display();
45 
46   void Resize(SurfaceId id, const gfx::Size& new_size);
47   bool Draw();
48 
49   SurfaceId CurrentSurfaceId();
50   int GetMaxFramesPending();
51 
52   // OutputSurfaceClient implementation.
DeferredInitialize()53   virtual void DeferredInitialize() OVERRIDE {}
ReleaseGL()54   virtual void ReleaseGL() OVERRIDE {}
55   virtual void CommitVSyncParameters(base::TimeTicks timebase,
56                                      base::TimeDelta interval) OVERRIDE;
SetNeedsRedrawRect(const gfx::Rect & damage_rect)57   virtual void SetNeedsRedrawRect(const gfx::Rect& damage_rect) OVERRIDE {}
BeginFrame(const BeginFrameArgs & args)58   virtual void BeginFrame(const BeginFrameArgs& args) OVERRIDE {}
59   virtual void DidSwapBuffers() OVERRIDE;
60   virtual void DidSwapBuffersComplete() OVERRIDE;
ReclaimResources(const CompositorFrameAck * ack)61   virtual void ReclaimResources(const CompositorFrameAck* ack) OVERRIDE {}
DidLoseOutputSurface()62   virtual void DidLoseOutputSurface() OVERRIDE {}
SetExternalDrawConstraints(const gfx::Transform & transform,const gfx::Rect & viewport,const gfx::Rect & clip,const gfx::Rect & viewport_rect_for_tile_priority,const gfx::Transform & transform_for_tile_priority,bool resourceless_software_draw)63   virtual void SetExternalDrawConstraints(
64       const gfx::Transform& transform,
65       const gfx::Rect& viewport,
66       const gfx::Rect& clip,
67       const gfx::Rect& viewport_rect_for_tile_priority,
68       const gfx::Transform& transform_for_tile_priority,
69       bool resourceless_software_draw) OVERRIDE {}
SetMemoryPolicy(const ManagedMemoryPolicy & policy)70   virtual void SetMemoryPolicy(const ManagedMemoryPolicy& policy) OVERRIDE {}
SetTreeActivationCallback(const base::Closure & callback)71   virtual void SetTreeActivationCallback(
72       const base::Closure& callback) OVERRIDE {}
73 
74   // RendererClient implementation.
SetFullRootLayerDamage()75   virtual void SetFullRootLayerDamage() OVERRIDE {}
76 
77   // SurfaceDamageObserver implementation.
78   virtual void OnSurfaceDamaged(SurfaceId surface) OVERRIDE;
79 
80  private:
81   void InitializeOutputSurface();
82 
83   DisplayClient* client_;
84   SurfaceManager* manager_;
85   SharedBitmapManager* bitmap_manager_;
86   SurfaceId current_surface_id_;
87   gfx::Size current_surface_size_;
88   LayerTreeSettings settings_;
89   scoped_ptr<OutputSurface> output_surface_;
90   scoped_ptr<ResourceProvider> resource_provider_;
91   scoped_ptr<SurfaceAggregator> aggregator_;
92   scoped_ptr<DirectRenderer> renderer_;
93   scoped_ptr<BlockingTaskRunner> blocking_main_thread_task_runner_;
94 
95   DISALLOW_COPY_AND_ASSIGN(Display);
96 };
97 
98 }  // namespace cc
99 
100 #endif  // CC_SURFACES_DISPLAY_H_
101