summaryrefslogtreecommitdiffstats
path: root/ui/ozone/public/ozone_gpu_test_helper.h
blob: e3428656ad5a680a93a9af67e98890e5298cced6 (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
// 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 UI_OZONE_PUBLIC_OZONE_GPU_THREAD_HELPER_H_
#define UI_OZONE_PUBLIC_OZONE_GPU_THREAD_HELPER_H_

#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "ui/ozone/ozone_export.h"

namespace base {
class SingleThreadTaskRunner;
class Thread;
}

namespace ui {

class FakeGpuProcess;
class FakeGpuProcessHost;

// Helper class for applications that do not have a dedicated GPU channel.
//
// This sets up message forwarding between the "gpu" and "ui" threads.
class OZONE_EXPORT OzoneGpuTestHelper {
 public:
  OzoneGpuTestHelper();
  virtual ~OzoneGpuTestHelper();

  // Start processing gpu messages. The host process will be using the
  // |gpu_task_runner| to post messages intended for the GPU thread. The "gpu"
  // process will be using the |ui_task_runner| to post messages intended for
  // the "ui" thread.
  bool Initialize(
      const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner,
      const scoped_refptr<base::SingleThreadTaskRunner>& gpu_task_runner);

 private:
  scoped_ptr<FakeGpuProcess> fake_gpu_process_;
  scoped_ptr<FakeGpuProcessHost> fake_gpu_process_host_;
  scoped_ptr<base::Thread> io_helper_thread_;

  DISALLOW_COPY_AND_ASSIGN(OzoneGpuTestHelper);
};

}  // namespace ui

#endif  // UI_OZONE_PUBLIC_OZONE_GPU_THREAD_HELPER_H_