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 #ifndef COMPONENTS_MUS_SURFACES_DISPLAY_IMPL_H_
6 #define COMPONENTS_MUS_SURFACES_DISPLAY_IMPL_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "cc/surfaces/display_client.h"
10 #include "cc/surfaces/surface_factory.h"
11 #include "cc/surfaces/surface_factory_client.h"
12 #include "components/mus/gles2/gpu_state.h"
13 #include "components/mus/surfaces/surfaces_context_provider.h"
14 #include "components/mus/surfaces/surfaces_context_provider_delegate.h"
15 #include "components/mus/surfaces/surfaces_state.h"
16 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h"
17 #include "ui/gfx/native_widget_types.h"
26 class DisplayDelegate
;
27 class SurfacesScheduler
;
30 // A TopLevelDisplayClient manages the top level surface that is rendered into a
31 // provided AcceleratedWidget. Frames are submitted here. New frames are
32 // scheduled to be generated here based on VSync.
33 class TopLevelDisplayClient
: public cc::DisplayClient
,
34 public cc::SurfaceFactoryClient
,
35 public SurfacesContextProviderDelegate
{
37 TopLevelDisplayClient(gfx::AcceleratedWidget widget
,
38 const scoped_refptr
<GpuState
>& gpu_state
,
39 const scoped_refptr
<SurfacesState
>& surfaces_state
);
40 ~TopLevelDisplayClient() override
;
42 void SubmitCompositorFrame(scoped_ptr
<cc::CompositorFrame
> frame
,
43 const base::Closure
& callback
);
45 const cc::CompositorFrame
* GetLastCompositorFrame() const;
47 const cc::SurfaceId
& surface_id() const { return cc_id_
; }
49 // DisplayClient implementation.
50 // TODO(rjkroege, fsamuel): This won't work correctly with multiple displays.
51 void CommitVSyncParameters(base::TimeTicks timebase
,
52 base::TimeDelta interval
) override
;
53 void OutputSurfaceLost() override
;
54 void SetMemoryPolicy(const cc::ManagedMemoryPolicy
& policy
) override
;
56 // SurfacesContextProviderDelegate:
57 void OnVSyncParametersUpdated(int64_t timebase
, int64_t interval
) override
;
59 // SurfaceFactoryClient implementation.
60 void ReturnResources(const cc::ReturnedResourceArray
& resources
) override
;
62 scoped_refptr
<SurfacesState
> surfaces_state_
;
63 cc::SurfaceFactory factory_
;
66 gfx::Size last_submitted_frame_size_
;
67 scoped_ptr
<cc::CompositorFrame
> pending_frame_
;
69 scoped_ptr
<cc::Display
> display_
;
71 DISALLOW_COPY_AND_ASSIGN(TopLevelDisplayClient
);
76 #endif // COMPONENTS_MUS_SURFACES_DISPLAY_IMPL_H_