summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authorzmo@google.com <zmo@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-11 21:07:18 +0000
committerzmo@google.com <zmo@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-11 21:07:18 +0000
commit2efc3118e5132ed7d3497f98d82cfb693490d552 (patch)
tree4e173c50c899c858155cc783c766db4d43a29ddf /chrome/common
parenta71a22ff3045cc1523321fd81b82c97e4e53e097 (diff)
downloadchromium_src-2efc3118e5132ed7d3497f98d82cfb693490d552.zip
chromium_src-2efc3118e5132ed7d3497f98d82cfb693490d552.tar.gz
chromium_src-2efc3118e5132ed7d3497f98d82cfb693490d552.tar.bz2
Blacklist bad GPU drivers: currenly we disable all gpu related features if a (os, device, driver) configuration is on the blacklist.
BUG=58182 TEST=unittest Review URL: http://codereview.chromium.org/5612002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68948 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/chrome_switches.cc3
-rw-r--r--chrome/common/chrome_switches.h1
-rw-r--r--chrome/common/gpu_feature_flags.cc45
-rw-r--r--chrome/common/gpu_feature_flags.h58
-rw-r--r--chrome/common/gpu_feature_flags_unittest.cc51
-rw-r--r--chrome/common/gpu_messages_internal.h5
6 files changed, 163 insertions, 0 deletions
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc
index bddc032..745ce0c 100644
--- a/chrome/common/chrome_switches.cc
+++ b/chrome/common/chrome_switches.cc
@@ -725,6 +725,9 @@ const char kHostResolverParallelism[] = "host-resolver-parallelism";
// These mappings only apply to the host resolver.
const char kHostResolverRules[] = "host-resolver-rules";
+// Ignores GPU blacklist.
+const char kIgnoreGpuBlacklist[] = "ignore-gpu-blacklist";
+
// Perform importing from another browser. The value associated with this
// setting encodes the target browser and what items to import.
const char kImport[] = "import";
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h
index 8c3ecaf..139c084 100644
--- a/chrome/common/chrome_switches.h
+++ b/chrome/common/chrome_switches.h
@@ -207,6 +207,7 @@ extern const char kHomePage[];
extern const char kHostRules[];
extern const char kHostResolverParallelism[];
extern const char kHostResolverRules[];
+extern const char kIgnoreGpuBlacklist[];
extern const char kImport[];
extern const char kImportFromFile[];
extern const char kInProcessPlugins[];
diff --git a/chrome/common/gpu_feature_flags.cc b/chrome/common/gpu_feature_flags.cc
new file mode 100644
index 0000000..12b857b
--- /dev/null
+++ b/chrome/common/gpu_feature_flags.cc
@@ -0,0 +1,45 @@
+// Copyright (c) 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 "chrome/common/gpu_feature_flags.h"
+
+#include "base/logging.h"
+
+const char GpuFeatureFlags::kGpuFeatureNameAccelerated2dCanvas[] =
+ "accelerated_2d_canvas";
+const char GpuFeatureFlags::kGpuFeatureNameAcceleratedCompositing[] =
+ "accelerated_compositing";
+const char GpuFeatureFlags::kGpuFeatureNameWebgl[] = "webgl";
+const char GpuFeatureFlags::kGpuFeatureNameAll[] = "all";
+
+GpuFeatureFlags::GpuFeatureFlags()
+ : flags_(0) {
+}
+
+void GpuFeatureFlags::set_flags(uint32 flags) {
+ DCHECK_EQ(flags & (~kGpuFeatureAll), 0u);
+ flags_ = flags;
+}
+
+uint32 GpuFeatureFlags::flags() const {
+ return flags_;
+}
+
+void GpuFeatureFlags::Combine(const GpuFeatureFlags& other) {
+ flags_ |= other.flags_;
+}
+
+GpuFeatureFlags::GpuFeatureType GpuFeatureFlags::StringToGpuFeatureType(
+ const std::string& feature_string) {
+ if (feature_string == kGpuFeatureNameAccelerated2dCanvas)
+ return kGpuFeatureAccelerated2dCanvas;
+ else if (feature_string == kGpuFeatureNameAcceleratedCompositing)
+ return kGpuFeatureAcceleratedCompositing;
+ else if (feature_string == kGpuFeatureNameWebgl)
+ return kGpuFeatureWebgl;
+ else if (feature_string == kGpuFeatureNameAll)
+ return kGpuFeatureAll;
+ return kGpuFeatureUnknown;
+}
+
diff --git a/chrome/common/gpu_feature_flags.h b/chrome/common/gpu_feature_flags.h
new file mode 100644
index 0000000..5b9d3ed
--- /dev/null
+++ b/chrome/common/gpu_feature_flags.h
@@ -0,0 +1,58 @@
+// Copyright (c) 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.
+
+#ifndef CHROME_COMMON_GPU_FEATURE_FLAGS_H__
+#define CHROME_COMMON_GPU_FEATURE_FLAGS_H__
+#pragma once
+
+// Provides flags indicating which gpu features are blacklisted for the system
+// on which chrome is currently running.
+
+#include <string>
+
+#include "base/basictypes.h"
+
+class GpuFeatureFlags {
+ public:
+ enum GpuFeatureType {
+ kGpuFeatureAccelerated2dCanvas = 1 << 0,
+ kGpuFeatureAcceleratedCompositing = 1 << 1,
+ kGpuFeatureWebgl = 1 << 2,
+ kGpuFeatureAll = kGpuFeatureAccelerated2dCanvas |
+ kGpuFeatureAcceleratedCompositing |
+ kGpuFeatureWebgl,
+ kGpuFeatureUnknown = 0
+ };
+
+ // All flags initialized to false, i.e., no feature is blacklisted.
+ GpuFeatureFlags();
+
+ // flags are OR combination of GpuFeatureType.
+ void set_flags(uint32 flags);
+
+ uint32 flags() const;
+
+ // Resets each flag by OR with the corresponding flag in "other".
+ void Combine(const GpuFeatureFlags& other);
+
+ // Maps string to GpuFeatureType; returns kGpuFeatureUnknown if none of the
+ // following is input (case-sensitive):
+ // "accelerated_2d_canvas"
+ // "accelerated_compositing"
+ // "webgl"
+ static GpuFeatureType StringToGpuFeatureType(
+ const std::string& feature_string);
+
+ private:
+ static const char kGpuFeatureNameAccelerated2dCanvas[];
+ static const char kGpuFeatureNameAcceleratedCompositing[];
+ static const char kGpuFeatureNameWebgl[];
+ static const char kGpuFeatureNameAll[];
+
+ // If a bit is set to 1, corresponding feature is blacklisted.
+ uint32 flags_;
+};
+
+#endif // CHROME_COMMON_GPU_FEATURE_FLAGS_H__
+
diff --git a/chrome/common/gpu_feature_flags_unittest.cc b/chrome/common/gpu_feature_flags_unittest.cc
new file mode 100644
index 0000000..1bd8f40
--- /dev/null
+++ b/chrome/common/gpu_feature_flags_unittest.cc
@@ -0,0 +1,51 @@
+// Copyright (c) 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 "chrome/common/gpu_feature_flags.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+TEST(GpuFeatureFlagsTest, GpuFeatureFlagsBasic) {
+ // Test that by default all flags are set to false.
+ GpuFeatureFlags flags;
+ EXPECT_EQ(flags.flags(), 0u);
+
+ // Test SetFlags().
+ GpuFeatureFlags flags2;
+ flags2.set_flags(GpuFeatureFlags::kGpuFeatureAcceleratedCompositing |
+ GpuFeatureFlags::kGpuFeatureWebgl);
+ EXPECT_EQ(flags2.flags(),
+ static_cast<uint32>(
+ GpuFeatureFlags::kGpuFeatureAcceleratedCompositing |
+ GpuFeatureFlags::kGpuFeatureWebgl));
+
+ // Test Combine() is basically OR operation per flag.
+ flags.set_flags(GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas);
+ flags.Combine(flags2);
+ EXPECT_EQ(flags.flags(),
+ static_cast<uint32>(
+ GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas |
+ GpuFeatureFlags::kGpuFeatureAcceleratedCompositing |
+ GpuFeatureFlags::kGpuFeatureWebgl));
+
+ // Test the currently supported feature set.
+ flags.set_flags(GpuFeatureFlags::kGpuFeatureAll);
+ EXPECT_EQ(flags.flags(),
+ static_cast<uint32>(
+ GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas |
+ GpuFeatureFlags::kGpuFeatureAcceleratedCompositing |
+ GpuFeatureFlags::kGpuFeatureWebgl));
+
+ // Test StringToGpuFeatureType.
+ EXPECT_EQ(GpuFeatureFlags::StringToGpuFeatureType("accelerated_2d_canvas"),
+ GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas);
+ EXPECT_EQ(GpuFeatureFlags::StringToGpuFeatureType("accelerated_compositing"),
+ GpuFeatureFlags::kGpuFeatureAcceleratedCompositing);
+ EXPECT_EQ(GpuFeatureFlags::StringToGpuFeatureType("webgl"),
+ GpuFeatureFlags::kGpuFeatureWebgl);
+ EXPECT_EQ(GpuFeatureFlags::StringToGpuFeatureType("all"),
+ GpuFeatureFlags::kGpuFeatureAll);
+ EXPECT_EQ(GpuFeatureFlags::StringToGpuFeatureType("xxx"),
+ GpuFeatureFlags::kGpuFeatureUnknown);
+}
+
diff --git a/chrome/common/gpu_messages_internal.h b/chrome/common/gpu_messages_internal.h
index 57a8917..3814702 100644
--- a/chrome/common/gpu_messages_internal.h
+++ b/chrome/common/gpu_messages_internal.h
@@ -33,6 +33,11 @@ class GPUInfo;
IPC_MESSAGE_CONTROL1(GpuMsg_EstablishChannel,
int /* renderer_id */)
+// Tells the GPU process to close the channel identified by IPC channel
+// handle. If no channel can be identified, do nothing.
+IPC_MESSAGE_CONTROL1(GpuMsg_CloseChannel,
+ IPC::ChannelHandle /* channel_handle */)
+
// Provides a synchronization point to guarantee that the processing of
// previous asynchronous messages (i.e., GpuMsg_EstablishChannel) has
// completed. (This message can't be synchronous because the