| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2015 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 <stdint.h> | |
| 6 | |
| 7 #include "base/memory/scoped_ptr.h" | |
| 8 #include "gpu/command_buffer/service/gpu_preferences.h" | |
| 9 #include "gpu/ipc/service/gpu_channel.h" | |
| 10 #include "gpu/ipc/service/gpu_channel_manager.h" | |
| 11 #include "gpu/ipc/service/gpu_channel_manager_delegate.h" | |
| 12 #include "ipc/ipc_test_sink.h" | |
| 13 #include "testing/gtest/include/gtest/gtest.h" | |
| 14 | |
| 15 class GURL; | |
| 16 | |
| 17 namespace base { | |
| 18 class TestSimpleTaskRunner; | |
| 19 } // namespace base | |
| 20 | |
| 21 namespace IPC { | |
| 22 class TestSink; | |
| 23 } // namespace IPC | |
| 24 | |
| 25 namespace gpu { | |
| 26 | |
| 27 class SyncPointManager; | |
| 28 | |
| 29 class TestGpuChannelManagerDelegate : public GpuChannelManagerDelegate { | |
| 30 public: | |
| 31 TestGpuChannelManagerDelegate(); | |
| 32 ~TestGpuChannelManagerDelegate() override; | |
| 33 | |
| 34 private: | |
| 35 // GpuChannelManagerDelegate implementation: | |
| 36 void SetActiveURL(const GURL& url) override; | |
| 37 void AddSubscription(int32_t client_id, unsigned int target) override; | |
| 38 void DidCreateOffscreenContext(const GURL& active_url) override; | |
| 39 void DidDestroyChannel(int client_id) override; | |
| 40 void DidDestroyOffscreenContext(const GURL& active_url) override; | |
| 41 void DidLoseContext(bool offscreen, | |
| 42 error::ContextLostReason reason, | |
| 43 const GURL& active_url) override; | |
| 44 void GpuMemoryUmaStats(const GPUMemoryUmaStats& params) override; | |
| 45 void RemoveSubscription(int32_t client_id, unsigned int target) override; | |
| 46 void StoreShaderToDisk(int32_t client_id, | |
| 47 const std::string& key, | |
| 48 const std::string& shader) override; | |
| 49 #if defined(OS_MACOSX) | |
| 50 void SendAcceleratedSurfaceBuffersSwapped( | |
| 51 int32_t surface_id, | |
| 52 CAContextID ca_context_id, | |
| 53 const gfx::ScopedRefCountedIOSurfaceMachPort& io_surface, | |
| 54 const gfx::Size& size, | |
| 55 float scale_factor, | |
| 56 std::vector<ui::LatencyInfo> latency_info) override; | |
| 57 #endif | |
| 58 #if defined(OS_WIN) | |
| 59 void SendAcceleratedSurfaceCreatedChildWindow( | |
| 60 SurfaceHandle parent_window, | |
| 61 SurfaceHandle child_window) override; | |
| 62 #endif | |
| 63 | |
| 64 DISALLOW_COPY_AND_ASSIGN(TestGpuChannelManagerDelegate); | |
| 65 }; | |
| 66 | |
| 67 class TestGpuChannelManager : public GpuChannelManager { | |
| 68 public: | |
| 69 TestGpuChannelManager(const GpuPreferences& gpu_preferences, | |
| 70 GpuChannelManagerDelegate* delegate, | |
| 71 base::SingleThreadTaskRunner* task_runner, | |
| 72 base::SingleThreadTaskRunner* io_task_runner, | |
| 73 SyncPointManager* sync_point_manager, | |
| 74 GpuMemoryBufferFactory* gpu_memory_buffer_factory); | |
| 75 ~TestGpuChannelManager() override; | |
| 76 | |
| 77 protected: | |
| 78 scoped_ptr<GpuChannel> CreateGpuChannel( | |
| 79 int client_id, | |
| 80 uint64_t client_tracing_id, | |
| 81 bool preempts, | |
| 82 bool allow_view_command_buffers, | |
| 83 bool allow_real_time_streams) override; | |
| 84 }; | |
| 85 | |
| 86 class TestGpuChannel : public GpuChannel { | |
| 87 public: | |
| 88 TestGpuChannel(GpuChannelManager* gpu_channel_manager, | |
| 89 SyncPointManager* sync_point_manager, | |
| 90 gfx::GLShareGroup* share_group, | |
| 91 gles2::MailboxManager* mailbox_manager, | |
| 92 PreemptionFlag* preempting_flag, | |
| 93 PreemptionFlag* preempted_flag, | |
| 94 base::SingleThreadTaskRunner* task_runner, | |
| 95 base::SingleThreadTaskRunner* io_task_runner, | |
| 96 int client_id, | |
| 97 uint64_t client_tracing_id, | |
| 98 bool allow_view_command_buffers, | |
| 99 bool allow_real_time_streams); | |
| 100 ~TestGpuChannel() override; | |
| 101 | |
| 102 IPC::TestSink* sink() { return &sink_; } | |
| 103 base::ProcessId GetClientPID() const override; | |
| 104 | |
| 105 IPC::ChannelHandle Init(base::WaitableEvent* shutdown_event) override; | |
| 106 | |
| 107 // IPC::Sender implementation. | |
| 108 bool Send(IPC::Message* msg) override; | |
| 109 | |
| 110 private: | |
| 111 IPC::TestSink sink_; | |
| 112 }; | |
| 113 | |
| 114 class GpuChannelTestCommon : public testing::Test { | |
| 115 public: | |
| 116 GpuChannelTestCommon(); | |
| 117 ~GpuChannelTestCommon() override; | |
| 118 | |
| 119 protected: | |
| 120 GpuChannelManager* channel_manager() { return channel_manager_.get(); } | |
| 121 TestGpuChannelManagerDelegate* channel_manager_delegate() { | |
| 122 return channel_manager_delegate_.get(); | |
| 123 } | |
| 124 base::TestSimpleTaskRunner* task_runner() { return task_runner_.get(); } | |
| 125 | |
| 126 private: | |
| 127 GpuPreferences gpu_preferences_; | |
| 128 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; | |
| 129 scoped_refptr<base::TestSimpleTaskRunner> io_task_runner_; | |
| 130 scoped_ptr<SyncPointManager> sync_point_manager_; | |
| 131 scoped_ptr<TestGpuChannelManagerDelegate> channel_manager_delegate_; | |
| 132 scoped_ptr<GpuChannelManager> channel_manager_; | |
| 133 }; | |
| 134 | |
| 135 } // namespace gpu | |
| OLD | NEW |