summaryrefslogtreecommitdiff
path: root/chromium/content/browser/gpu/gpu_client.h
blob: 4e45d860d243aaa513e69ec7fba84d1122d988ae (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
// Copyright 2016 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 CONTENT_BROWSER_GPU_GPU_CLIENT_H_
#define CONTENT_BROWSER_GPU_GPU_CLIENT_H_

#include "base/memory/weak_ptr.h"
#include "content/browser/gpu/gpu_process_host.h"
#include "ipc/ipc_channel_handle.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "services/ui/public/interfaces/gpu.mojom.h"

namespace content {

class GpuClient : public ui::mojom::Gpu {
 public:
  explicit GpuClient(int render_process_id);
  ~GpuClient() override;

  void Add(ui::mojom::GpuRequest request);

 private:
  void OnError();
  void OnEstablishGpuChannel(const EstablishGpuChannelCallback& callback,
                             const IPC::ChannelHandle& channel,
                             const gpu::GPUInfo& gpu_info,
                             GpuProcessHost::EstablishChannelStatus status);
  void OnCreateGpuMemoryBuffer(const CreateGpuMemoryBufferCallback& callback,
                               const gfx::GpuMemoryBufferHandle& handle);

  // ui::mojom::Gpu overrides:
  void EstablishGpuChannel(
      const EstablishGpuChannelCallback& callback) override;
  void CreateGpuMemoryBuffer(
      gfx::GpuMemoryBufferId id,
      const gfx::Size& size,
      gfx::BufferFormat format,
      gfx::BufferUsage usage,
      const ui::mojom::Gpu::CreateGpuMemoryBufferCallback& callback) override;
  void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id,
                              const gpu::SyncToken& sync_token) override;

  const int render_process_id_;
  mojo::BindingSet<ui::mojom::Gpu> bindings_;
  base::WeakPtrFactory<GpuClient> weak_factory_;

  DISALLOW_COPY_AND_ASSIGN(GpuClient);
};

}  // namespace content

#endif  // CONTENT_BROWSER_GPU_GPU_CLIENT_H_