summaryrefslogtreecommitdiff
path: root/chromium/mojo/cc/output_surface_mojo.h
blob: feef5a2ae84598e680c319189b6d51e5b055b39e (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
// 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_CC_OUTPUT_SURFACE_MOJO_H_
#define MOJO_CC_OUTPUT_SURFACE_MOJO_H_

#include "base/macros.h"
#include "cc/output/output_surface.h"
#include "cc/surfaces/surface_id.h"
#include "cc/surfaces/surface_id_allocator.h"
#include "mojo/services/public/interfaces/surfaces/surfaces.mojom.h"

namespace mojo {

class OutputSurfaceMojoClient {
 public:
  virtual ~OutputSurfaceMojoClient() {}

  virtual void DidCreateSurface(cc::SurfaceId id) = 0;
};

class OutputSurfaceMojo : public cc::OutputSurface, public SurfaceClient {
 public:
  OutputSurfaceMojo(OutputSurfaceMojoClient* client,
                    const scoped_refptr<cc::ContextProvider>& context_provider,
                    SurfacePtr surface,
                    uint32_t id_namespace);

  // SurfaceClient implementation.
  void ReturnResources(Array<ReturnedResourcePtr> resources) override;

  // cc::OutputSurface implementation.
  void SwapBuffers(cc::CompositorFrame* frame) override;
  bool BindToClient(cc::OutputSurfaceClient* client) override;

 protected:
  ~OutputSurfaceMojo() override;

 private:
  OutputSurfaceMojoClient* output_surface_mojo_client_;
  SurfacePtr surface_;
  cc::SurfaceIdAllocator id_allocator_;
  cc::SurfaceId surface_id_;
  gfx::Size surface_size_;

  DISALLOW_COPY_AND_ASSIGN(OutputSurfaceMojo);
};
}

#endif  // MOJO_CC_OUTPUT_SURFACE_MOJO_H_