Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(392)

Side by Side Diff: ui/ozone/platform/drm/common/drm_gpu_test_helper_inprocess.cc

Issue 1285183008: Ozone integration. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: add missing license header Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/ozone/platform/drm/BUILD.gn ('k') | ui/ozone/platform/drm/common/drm_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 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.
4
5 #include "base/bind.h"
6 #include "base/thread_task_runner_handle.h"
7 #include "base/threading/thread.h"
8 #include "ui/ozone/platform/drm/gpu/drm_gpu_platform_support_inprocess.h"
9 #include "ui/ozone/platform/drm/host/drm_gpu_platform_support_host_inprocess.h"
10 #include "ui/ozone/public/gpu_platform_support.h"
11 #include "ui/ozone/public/gpu_platform_support_host.h"
12 #include "ui/ozone/public/ozone_gpu_test_helper.h"
13 #include "ui/ozone/public/ozone_platform.h"
14
15 namespace ui {
16
17 namespace {
18
19 const int kGpuProcessHostId = 1;
20
21 } // namespace
22
23 static void DispatchToGpuPlatformSupportHostTask(Message* msg) {
24 auto support = static_cast<DrmGpuPlatformSupportHost*>(
25 ui::OzonePlatform::GetInstance()->GetGpuPlatformSupportHost());
26 auto inprocess = static_cast<DrmGpuPlatformSupportHostInprocess*>(
27 support->get_delegate());
28 inprocess->OnMessageReceived(*msg);
29 delete msg;
30 }
31
32 class FakeGpuProcess {
33 public:
34 FakeGpuProcess(
35 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner)
36 : ui_task_runner_(ui_task_runner) {}
37 ~FakeGpuProcess() {}
38
39 void Init() {
40 base::Callback<void(Message*)> sender =
41 base::Bind(&DispatchToGpuPlatformSupportHostTask);
42
43 auto delegate = new DrmGpuPlatformSupportInprocess();
44 delegate->OnChannelEstablished(ui_task_runner_, sender);
45 }
46
47 private:
48 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
49 };
50
51 static void DispatchToGpuPlatformSupportTask(Message* msg) {
52 auto support = static_cast<DrmGpuPlatformSupport*>(
53 ui::OzonePlatform::GetInstance()->GetGpuPlatformSupport());
54 auto inprocess = static_cast<DrmGpuPlatformSupportInprocess*>(
55 support->get_delegate());
56 inprocess->OnMessageReceived(*msg);
57 delete msg;
58 }
59
60 class FakeGpuProcessHost {
61 public:
62 FakeGpuProcessHost(
63 const scoped_refptr<base::SingleThreadTaskRunner>& gpu_task_runner)
64 : gpu_task_runner_(gpu_task_runner) {}
65 ~FakeGpuProcessHost() {}
66
67 void Init() {
68 base::Callback<void(Message*)> sender =
69 base::Bind(&DispatchToGpuPlatformSupportTask);
70
71 auto host_support_inprocess = new DrmGpuPlatformSupportHostInprocess();
72 host_support_inprocess->OnChannelEstablished(
73 kGpuProcessHostId, gpu_task_runner_, sender);
74 }
75
76 private:
77 scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner_;
78 };
79
80 OzoneGpuTestHelper::OzoneGpuTestHelper() {
81 }
82
83 OzoneGpuTestHelper::~OzoneGpuTestHelper() {
84 }
85
86 bool OzoneGpuTestHelper::Initialize(
87 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner,
88 const scoped_refptr<base::SingleThreadTaskRunner>& gpu_task_runner) {
89
90 fake_gpu_process_.reset(new FakeGpuProcess(ui_task_runner));
91 fake_gpu_process_->Init();
92
93 fake_gpu_process_host_.reset(new FakeGpuProcessHost(gpu_task_runner));
94 fake_gpu_process_host_->Init();
95
96 return true;
97 }
98
99 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/BUILD.gn ('k') | ui/ozone/platform/drm/common/drm_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698