summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrlp@chromium.org <rlp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-09 23:44:13 +0000
committerrlp@chromium.org <rlp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-09 23:44:13 +0000
commit2c1ca1a516107745daa0a892875d61944dd791f6 (patch)
tree1464f37e2a551a74dc8dd409320f9fe6382ed255
parent0dd261c0b9b03c6a8b73327a971968798d8b5109 (diff)
downloadchromium_src-2c1ca1a516107745daa0a892875d61944dd791f6.zip
chromium_src-2c1ca1a516107745daa0a892875d61944dd791f6.tar.gz
chromium_src-2c1ca1a516107745daa0a892875d61944dd791f6.tar.bz2
Adding a new param_trait type for gpu info in order to send it from the gpu process to the browser process.
BUG=38736 TEST=unittest added Review URL: http://codereview.chromium.org/2805029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52020 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/chrome_tests.gypi1
-rw-r--r--chrome/common/gpu_messages.h32
-rw-r--r--chrome/common/gpu_messages_unittest.cc35
3 files changed, 68 insertions, 0 deletions
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 6f59350..c95fecc 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1016,6 +1016,7 @@
'common/extensions/url_pattern_unittest.cc',
'common/extensions/user_script_unittest.cc',
'common/font_descriptor_mac_unittest.mm',
+ 'common/gpu_messages_unittest.cc',
'common/important_file_writer_unittest.cc',
'common/json_pref_store_unittest.cc',
'common/json_value_serializer_unittest.cc',
diff --git a/chrome/common/gpu_messages.h b/chrome/common/gpu_messages.h
index 7b37731..16f2860 100644
--- a/chrome/common/gpu_messages.h
+++ b/chrome/common/gpu_messages.h
@@ -11,6 +11,7 @@
#include "base/basictypes.h"
#include "base/process.h"
#include "chrome/common/common_param_traits.h"
+#include "chrome/common/gpu_info.h"
#include "chrome/common/gpu_native_window_handle.h"
#include "gfx/native_widget_types.h"
#include "gfx/rect.h"
@@ -19,6 +20,37 @@
namespace IPC {
template <>
+struct ParamTraits<GPUInfo> {
+ typedef GPUInfo param_type;
+ static void Write(Message* m, const param_type& p) {
+ m->WriteUInt32(p.vendor_id());
+ m->WriteUInt32(p.device_id());
+ m->WriteWString(p.driver_version());
+ m->WriteUInt32(p.pixel_shader_version());
+ m->WriteUInt32(p.vertex_shader_version());
+ }
+ static bool Read(const Message* m, void** iter, param_type* p) {
+ uint32 vendor_id;
+ uint32 device_id;
+ std::wstring driver_version;
+ uint32 pixel_shader_version;
+ uint32 vertex_shader_version;
+ bool ret = m->ReadUInt32(iter, &vendor_id);
+ ret = ret && m->ReadUInt32(iter, &device_id);
+ ret = ret && m->ReadWString(iter, &driver_version);
+ ret = ret && m->ReadUInt32(iter, &pixel_shader_version);
+ ret = ret && m->ReadUInt32(iter, &vertex_shader_version);
+ p->SetGraphicsInfo(vendor_id, device_id, driver_version,
+ pixel_shader_version, vertex_shader_version);
+ return ret;
+ }
+ static void Log(const param_type& p, std::wstring* l) {
+ l->append(StringPrintf(L"<GPUInfo> %x %x %ls",
+ p.vendor_id(), p.device_id(), p.driver_version().c_str()));
+ }
+};
+
+template <>
struct ParamTraits<gpu::CommandBuffer::State> {
typedef gpu::CommandBuffer::State param_type;
static void Write(Message* m, const param_type& p) {
diff --git a/chrome/common/gpu_messages_unittest.cc b/chrome/common/gpu_messages_unittest.cc
new file mode 100644
index 0000000..5215949
--- /dev/null
+++ b/chrome/common/gpu_messages_unittest.cc
@@ -0,0 +1,35 @@
+// Copyright (c) 2006-2010 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.
+
+#include "base/logging.h"
+#include "base/scoped_ptr.h"
+#include "chrome/common/gpu_info.h"
+#include "chrome/common/gpu_messages.h"
+#include "ipc/ipc_message.h"
+#include "ipc/ipc_message_utils.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+// Test GPUInfo serialization
+TEST(GPUIPCMessageTest, GPUInfo) {
+ GPUInfo input;
+ // Test variables taken from Lenovo T61
+ input.SetGraphicsInfo(0x10de, 0x429, L"6.14.11.7715",
+ 0xffff0300, 0xfffe0300);
+
+ IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
+ IPC::WriteParam(&msg, input);
+
+ GPUInfo output;
+ void* iter = NULL;
+ EXPECT_TRUE(IPC::ReadParam(&msg, &iter, &output));
+ EXPECT_EQ(input.vendor_id(), output.vendor_id());
+ EXPECT_EQ(input.device_id(), output.device_id());
+ EXPECT_EQ(input.driver_version(), output.driver_version());
+ EXPECT_EQ(input.pixel_shader_version(), output.pixel_shader_version());
+ EXPECT_EQ(input.vertex_shader_version(), output.vertex_shader_version());
+
+ std::wstring log_message;
+ IPC::LogParam(output, &log_message);
+ EXPECT_STREQ(L"<GPUInfo> 10de 429 6.14.11.7715", log_message.c_str());
+}