summaryrefslogtreecommitdiffstats
path: root/mojo/services/surfaces/surfaces_impl.h
blob: fb6ce53a9cce06b70934f211fa9c3b7d5970f987 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef MOJO_SERVICES_SURFACES_SURFACES_IMPL_H_
#define MOJO_SERVICES_SURFACES_SURFACES_IMPL_H_

#include "base/compiler_specific.h"
#include "cc/surfaces/display_client.h"
#include "cc/surfaces/surface_factory.h"
#include "cc/surfaces/surface_factory_client.h"
#include "mojo/public/cpp/application/application_connection.h"
#include "mojo/services/gles2/command_buffer.mojom.h"
#include "mojo/services/public/interfaces/surfaces/surfaces.mojom.h"

namespace cc {
class Display;
}

namespace mojo {
class ApplicationManager;

class SurfaceNativeViewportClient;

class SurfacesImpl : public InterfaceImpl<Surface>,
                     public cc::SurfaceFactoryClient,
                     public cc::DisplayClient {
 public:
  class Client {
   public:
    virtual void FrameSubmitted() = 0;
    virtual void SetDisplay(cc::Display*) = 0;
  };

  SurfacesImpl(cc::SurfaceManager* manager,
               uint32_t id_namespace,
               Client* client);
  virtual ~SurfacesImpl();

  // Surface implementation.
  virtual void CreateSurface(SurfaceIdPtr id, mojo::SizePtr size) OVERRIDE;
  virtual void SubmitFrame(SurfaceIdPtr id, FramePtr frame) OVERRIDE;
  virtual void DestroySurface(SurfaceIdPtr id) OVERRIDE;
  virtual void CreateGLES2BoundSurface(CommandBufferPtr gles2_client,
                                       SurfaceIdPtr id,
                                       mojo::SizePtr size) OVERRIDE;

  // SurfaceFactoryClient implementation.
  virtual void ReturnResources(
      const cc::ReturnedResourceArray& resources) OVERRIDE;

  // DisplayClient implementation.
  virtual void DisplayDamaged() OVERRIDE;
  virtual void DidSwapBuffers() OVERRIDE;
  virtual void DidSwapBuffersComplete() OVERRIDE;
  virtual void CommitVSyncParameters(base::TimeTicks timebase,
                                     base::TimeDelta interval) OVERRIDE;
  virtual void OutputSurfaceLost() OVERRIDE;
  virtual void SetMemoryPolicy(const cc::ManagedMemoryPolicy& policy) OVERRIDE;

  cc::SurfaceFactory* factory() { return &factory_; }

 private:
  cc::SurfaceManager* manager_;
  cc::SurfaceFactory factory_;
  uint32_t id_namespace_;
  Client* client_;
  scoped_ptr<cc::Display> display_;
  ScopedMessagePipeHandle command_buffer_handle_;

  DISALLOW_COPY_AND_ASSIGN(SurfacesImpl);
};

}  // namespace mojo

#endif  // MOJO_SERVICES_SURFACES_SURFACES_IMPL_H_