summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-07 23:34:39 +0000
committerreveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-07 23:34:39 +0000
commit189c11e3719c7d8886c15dc7db0a03ae132524eb (patch)
tree94e8978d2dc02a6abaa03c69af59d7436d3545ae
parenta4b944c145364d3a9da2a0a81f25db41306475eb (diff)
downloadchromium_src-189c11e3719c7d8886c15dc7db0a03ae132524eb.zip
chromium_src-189c11e3719c7d8886c15dc7db0a03ae132524eb.tar.gz
chromium_src-189c11e3719c7d8886c15dc7db0a03ae132524eb.tar.bz2
cc: Remove racy initialization code in cc/base/switches.cc.
This moves all lazy initialization code out of cc/base/switches.cc. Code that needs the value of these switches in a critical path should not rely on lazy initialization in cc/switches.cc but instead handle this on its own. Thread-safe lazy initialization code of impl-side painting status has been added to WebLayerImpl. This also removes the cc::switches::IsGPURasterizationEnabled() function, which for consistency should not exist unless the logic to determine the value is more complicated than HasSwitch(kEnableGPURasterization). This function was never used in performance sensitive code so lazy initialization was never necessary. BUG=330937 TBR=jamesr Review URL: https://codereview.chromium.org/122063002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243432 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--cc/base/switches.cc20
-rw-r--r--cc/base/switches.h1
-rw-r--r--content/renderer/gpu/render_widget_compositor.cc3
-rw-r--r--webkit/renderer/compositor_bindings/compositor_bindings.gyp1
-rw-r--r--webkit/renderer/compositor_bindings/web_content_layer_impl.cc12
-rw-r--r--webkit/renderer/compositor_bindings/web_image_layer_impl.cc10
-rw-r--r--webkit/renderer/compositor_bindings/web_layer_impl.cc19
-rw-r--r--webkit/renderer/compositor_bindings/web_layer_impl.h2
8 files changed, 30 insertions, 38 deletions
diff --git a/cc/base/switches.cc b/cc/base/switches.cc
index ddba9cb..dd0fa52 100644
--- a/cc/base/switches.cc
+++ b/cc/base/switches.cc
@@ -165,8 +165,7 @@ bool IsLCDTextEnabled() {
#endif
}
-namespace {
-bool CheckImplSidePaintingStatus() {
+bool IsImplSidePaintingEnabled() {
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
if (command_line.HasSwitch(switches::kDisableImplSidePainting))
@@ -181,23 +180,6 @@ bool CheckImplSidePaintingStatus() {
#endif
}
-bool CheckGPURasterizationStatus() {
- const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- return command_line.HasSwitch(switches::kEnableGPURasterization);
-}
-
-} // namespace
-
-bool IsImplSidePaintingEnabled() {
- static bool enabled = CheckImplSidePaintingStatus();
- return enabled;
-}
-
-bool IsGPURasterizationEnabled() {
- static bool enabled = CheckGPURasterizationStatus();
- return enabled;
-}
-
bool IsMapImageEnabled() {
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
diff --git a/cc/base/switches.h b/cc/base/switches.h
index 19cba57..476457f 100644
--- a/cc/base/switches.h
+++ b/cc/base/switches.h
@@ -74,7 +74,6 @@ CC_EXPORT extern const char kCCRebaselinePixeltests[];
CC_EXPORT bool IsLCDTextEnabled();
CC_EXPORT bool IsImplSidePaintingEnabled();
-CC_EXPORT bool IsGPURasterizationEnabled();
CC_EXPORT bool IsMapImageEnabled();
} // namespace switches
diff --git a/content/renderer/gpu/render_widget_compositor.cc b/content/renderer/gpu/render_widget_compositor.cc
index 2588050..89c7712 100644
--- a/content/renderer/gpu/render_widget_compositor.cc
+++ b/content/renderer/gpu/render_widget_compositor.cc
@@ -130,7 +130,8 @@ scoped_ptr<RenderWidgetCompositor> RenderWidgetCompositor::Create(
max_untiled_layer_height);
settings.impl_side_painting = cc::switches::IsImplSidePaintingEnabled();
- settings.gpu_rasterization = cc::switches::IsGPURasterizationEnabled();
+ settings.gpu_rasterization =
+ cmd->HasSwitch(cc::switches::kEnableGPURasterization);
settings.calculate_top_controls_position =
cmd->HasSwitch(cc::switches::kEnableTopControlsPositionCalculation);
diff --git a/webkit/renderer/compositor_bindings/compositor_bindings.gyp b/webkit/renderer/compositor_bindings/compositor_bindings.gyp
index 0f57cc4..d2bf244 100644
--- a/webkit/renderer/compositor_bindings/compositor_bindings.gyp
+++ b/webkit/renderer/compositor_bindings/compositor_bindings.gyp
@@ -29,6 +29,7 @@
'type': '<(component)',
'dependencies': [
'<(DEPTH)/base/base.gyp:base',
+ '<(DEPTH)/base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
'<(DEPTH)/cc/cc.gyp:cc',
'<(DEPTH)/gpu/gpu.gyp:gpu',
'<(DEPTH)/media/media.gyp:media',
diff --git a/webkit/renderer/compositor_bindings/web_content_layer_impl.cc b/webkit/renderer/compositor_bindings/web_content_layer_impl.cc
index 381501a..a7a9713 100644
--- a/webkit/renderer/compositor_bindings/web_content_layer_impl.cc
+++ b/webkit/renderer/compositor_bindings/web_content_layer_impl.cc
@@ -4,8 +4,6 @@
#include "webkit/renderer/compositor_bindings/web_content_layer_impl.h"
-#include "base/command_line.h"
-#include "cc/base/switches.h"
#include "cc/layers/content_layer.h"
#include "cc/layers/picture_layer.h"
#include "third_party/WebKit/public/platform/WebContentLayerClient.h"
@@ -20,14 +18,10 @@ using cc::PictureLayer;
namespace webkit {
-static bool usingPictureLayer() {
- return cc::switches::IsImplSidePaintingEnabled();
-}
-
WebContentLayerImpl::WebContentLayerImpl(blink::WebContentLayerClient* client)
: client_(client),
ignore_lcd_text_change_(false) {
- if (usingPictureLayer())
+ if (WebLayerImpl::UsingPictureLayer())
layer_ = make_scoped_ptr(new WebLayerImpl(PictureLayer::Create(this)));
else
layer_ = make_scoped_ptr(new WebLayerImpl(ContentLayer::Create(this)));
@@ -36,7 +30,7 @@ WebContentLayerImpl::WebContentLayerImpl(blink::WebContentLayerClient* client)
}
WebContentLayerImpl::~WebContentLayerImpl() {
- if (usingPictureLayer())
+ if (WebLayerImpl::UsingPictureLayer())
static_cast<PictureLayer*>(layer_->layer())->ClearClient();
else
static_cast<ContentLayer*>(layer_->layer())->ClearClient();
@@ -61,7 +55,7 @@ void WebContentLayerImpl::PaintContents(SkCanvas* canvas,
blink::WebFloatRect web_opaque;
// For picture layers, always record with LCD text. PictureLayerImpl
// will turn this off later during rasterization.
- bool use_lcd_text = usingPictureLayer() || can_use_lcd_text_;
+ bool use_lcd_text = WebLayerImpl::UsingPictureLayer() || can_use_lcd_text_;
client_->paintContents(canvas, clip, use_lcd_text, web_opaque);
*opaque = web_opaque;
}
diff --git a/webkit/renderer/compositor_bindings/web_image_layer_impl.cc b/webkit/renderer/compositor_bindings/web_image_layer_impl.cc
index 2074d05..c3ae4aa 100644
--- a/webkit/renderer/compositor_bindings/web_image_layer_impl.cc
+++ b/webkit/renderer/compositor_bindings/web_image_layer_impl.cc
@@ -4,21 +4,15 @@
#include "webkit/renderer/compositor_bindings/web_image_layer_impl.h"
-#include "base/command_line.h"
-#include "cc/base/switches.h"
#include "cc/layers/image_layer.h"
#include "cc/layers/picture_image_layer.h"
#include "webkit/renderer/compositor_bindings/web_layer_impl.h"
#include "webkit/renderer/compositor_bindings/web_layer_impl_fixed_bounds.h"
-static bool usingPictureLayer() {
- return cc::switches::IsImplSidePaintingEnabled();
-}
-
namespace webkit {
WebImageLayerImpl::WebImageLayerImpl() {
- if (usingPictureLayer())
+ if (WebLayerImpl::UsingPictureLayer())
layer_.reset(new WebLayerImplFixedBounds(cc::PictureImageLayer::Create()));
else
layer_.reset(new WebLayerImpl(cc::ImageLayer::Create()));
@@ -29,7 +23,7 @@ WebImageLayerImpl::~WebImageLayerImpl() {}
blink::WebLayer* WebImageLayerImpl::layer() { return layer_.get(); }
void WebImageLayerImpl::setBitmap(SkBitmap bitmap) {
- if (usingPictureLayer()) {
+ if (WebLayerImpl::UsingPictureLayer()) {
static_cast<cc::PictureImageLayer*>(layer_->layer())->SetBitmap(bitmap);
static_cast<WebLayerImplFixedBounds*>(layer_.get())->SetFixedBounds(
gfx::Size(bitmap.width(), bitmap.height()));
diff --git a/webkit/renderer/compositor_bindings/web_layer_impl.cc b/webkit/renderer/compositor_bindings/web_layer_impl.cc
index 22a5485..17fa373 100644
--- a/webkit/renderer/compositor_bindings/web_layer_impl.cc
+++ b/webkit/renderer/compositor_bindings/web_layer_impl.cc
@@ -6,10 +6,12 @@
#include "base/bind.h"
#include "base/debug/trace_event_impl.h"
+#include "base/lazy_instance.h"
#include "base/strings/string_util.h"
#include "base/threading/thread_checker.h"
#include "cc/animation/animation.h"
#include "cc/base/region.h"
+#include "cc/base/switches.h"
#include "cc/layers/layer.h"
#include "cc/layers/layer_position_constraint.h"
#include "third_party/WebKit/public/platform/WebCompositingReasons.h"
@@ -37,6 +39,18 @@ using blink::WebColor;
using blink::WebFilterOperations;
namespace webkit {
+namespace {
+
+struct ImplSidePaintingStatus {
+ ImplSidePaintingStatus()
+ : enabled(cc::switches::IsImplSidePaintingEnabled()) {
+ }
+ bool enabled;
+};
+base::LazyInstance<ImplSidePaintingStatus> g_impl_side_painting_status =
+ LAZY_INSTANCE_INITIALIZER;
+
+} // namespace
WebLayerImpl::WebLayerImpl() : layer_(Layer::Create()) {
web_layer_client_ = NULL;
@@ -54,6 +68,11 @@ WebLayerImpl::~WebLayerImpl() {
web_layer_client_ = NULL;
}
+// static
+bool WebLayerImpl::UsingPictureLayer() {
+ return g_impl_side_painting_status.Get().enabled;
+}
+
int WebLayerImpl::id() const { return layer_->id(); }
void WebLayerImpl::invalidateRect(const blink::WebFloatRect& rect) {
diff --git a/webkit/renderer/compositor_bindings/web_layer_impl.h b/webkit/renderer/compositor_bindings/web_layer_impl.h
index 011ec49..712c5bc 100644
--- a/webkit/renderer/compositor_bindings/web_layer_impl.h
+++ b/webkit/renderer/compositor_bindings/web_layer_impl.h
@@ -52,6 +52,8 @@ class WebLayerImpl : public blink::WebLayer, public cc::LayerClient {
scoped_refptr<cc::Layer>);
virtual ~WebLayerImpl();
+ static bool UsingPictureLayer();
+
WEBKIT_COMPOSITOR_BINDINGS_EXPORT cc::Layer* layer() const;
// WebLayer implementation.