diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-18 21:26:41 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-18 21:26:41 +0000 |
commit | 767f38d72c2e7da043b597eba26a718af08f9035 (patch) | |
tree | 442727383f1b535488df605bcf1113afee9682b7 /cc | |
parent | 9d11b52c42b6dc9ed9dd937b06a024f88bbee19c (diff) | |
download | chromium_src-767f38d72c2e7da043b597eba26a718af08f9035.zip chromium_src-767f38d72c2e7da043b597eba26a718af08f9035.tar.gz chromium_src-767f38d72c2e7da043b597eba26a718af08f9035.tar.bz2 |
cc: Change #if !defined(NDEBUG) to #if DCHECK_IS_ON.
Some places in cc enabled DCHECK code only when in a debug build since
they added member variables to classes in order to perform their
checks, and we could not check for DCHECK at compile time.
Since we can now, we can guard these DCHECKS with DCHECK_IS_ON. Yay!
DCHECK_IS_ON is always defined by base/logging.h. It is set to 1 when
DCHECKS are enabled, and 0 otherwise.
R=enne
BUG=350462
Review URL: https://codereview.chromium.org/201843005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257761 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r-- | cc/base/completion_event.h | 10 | ||||
-rw-r--r-- | cc/layers/picture_layer_unittest.cc | 9 | ||||
-rw-r--r-- | cc/resources/prioritized_resource.cc | 9 | ||||
-rw-r--r-- | cc/resources/prioritized_resource.h | 2 | ||||
-rw-r--r-- | cc/resources/prioritized_resource_manager.cc | 4 | ||||
-rw-r--r-- | cc/resources/prioritized_resource_unittest.cc | 2 | ||||
-rw-r--r-- | cc/resources/scoped_resource.cc | 6 | ||||
-rw-r--r-- | cc/resources/scoped_resource.h | 4 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.cc | 8 | ||||
-rw-r--r-- | cc/trees/layer_tree_host_impl.h | 2 | ||||
-rw-r--r-- | cc/trees/proxy.cc | 20 | ||||
-rw-r--r-- | cc/trees/proxy.h | 6 | ||||
-rw-r--r-- | cc/trees/single_thread_proxy.cc | 2 | ||||
-rw-r--r-- | cc/trees/single_thread_proxy.h | 8 |
14 files changed, 44 insertions, 48 deletions
diff --git a/cc/base/completion_event.h b/cc/base/completion_event.h index 759ce9c..96ccf54 100644 --- a/cc/base/completion_event.h +++ b/cc/base/completion_event.h @@ -19,21 +19,21 @@ class CompletionEvent { public: CompletionEvent() : event_(false /* manual_reset */, false /* initially_signaled */) { -#ifndef NDEBUG +#if DCHECK_IS_ON waited_ = false; signaled_ = false; #endif } ~CompletionEvent() { -#ifndef NDEBUG +#if DCHECK_IS_ON DCHECK(waited_); DCHECK(signaled_); #endif } void Wait() { -#ifndef NDEBUG +#if DCHECK_IS_ON DCHECK(!waited_); waited_ = true; #endif @@ -42,7 +42,7 @@ class CompletionEvent { } void Signal() { -#ifndef NDEBUG +#if DCHECK_IS_ON DCHECK(!signaled_); signaled_ = true; #endif @@ -51,7 +51,7 @@ class CompletionEvent { private: base::WaitableEvent event_; -#ifndef NDEBUG +#if DCHECK_IS_ON // Used to assert that Wait() and Signal() are each called exactly once. bool waited_; bool signaled_; diff --git a/cc/layers/picture_layer_unittest.cc b/cc/layers/picture_layer_unittest.cc index 6f2f940..1353016 100644 --- a/cc/layers/picture_layer_unittest.cc +++ b/cc/layers/picture_layer_unittest.cc @@ -12,6 +12,7 @@ #include "cc/test/fake_proxy.h" #include "cc/test/impl_side_painting_settings.h" #include "cc/trees/occlusion_tracker.h" +#include "cc/trees/single_thread_proxy.h" #include "testing/gtest/include/gtest/gtest.h" namespace cc { @@ -45,10 +46,9 @@ TEST(PictureLayerTest, NoTilesIfEmptyBounds) { // a layer with empty bounds. FakeProxy proxy; -#ifndef NDEBUG - proxy.SetCurrentThreadIsImplThread(true); -#endif { + DebugScopedSetImplThread impl_thread(&proxy); + FakeLayerTreeHostImpl host_impl(ImplSidePaintingSettings(), &proxy); host_impl.CreatePendingTree(); scoped_ptr<FakePictureLayerImpl> layer_impl = @@ -60,9 +60,6 @@ TEST(PictureLayerTest, NoTilesIfEmptyBounds) { EXPECT_TRUE(layer_impl->pile()->size() == gfx::Size(0, 0)); EXPECT_TRUE(layer_impl->pile()->recorded_region().IsEmpty()); } -#ifndef NDEBUG - proxy.SetCurrentThreadIsImplThread(false); -#endif } } // namespace diff --git a/cc/resources/prioritized_resource.cc b/cc/resources/prioritized_resource.cc index f1ae228..462f7f1 100644 --- a/cc/resources/prioritized_resource.cc +++ b/cc/resources/prioritized_resource.cc @@ -126,12 +126,13 @@ PrioritizedResource::Backing::Backing(unsigned id, was_above_priority_cutoff_at_last_priority_update_(false), in_drawing_impl_tree_(false), in_parent_compositor_(false), -#ifdef NDEBUG - resource_has_been_deleted_(false) {} +#if !DCHECK_IS_ON + resource_has_been_deleted_(false) { #else resource_has_been_deleted_(false), - resource_provider_(resource_provider) {} + resource_provider_(resource_provider) { #endif +} PrioritizedResource::Backing::~Backing() { DCHECK(!owner_); @@ -142,7 +143,7 @@ void PrioritizedResource::Backing::DeleteResource( ResourceProvider* resource_provider) { DCHECK(!proxy() || proxy()->IsImplThread()); DCHECK(!resource_has_been_deleted_); -#ifndef NDEBUG +#if DCHECK_IS_ON DCHECK(resource_provider == resource_provider_); #endif diff --git a/cc/resources/prioritized_resource.h b/cc/resources/prioritized_resource.h index 1d56524..7920f81 100644 --- a/cc/resources/prioritized_resource.h +++ b/cc/resources/prioritized_resource.h @@ -143,7 +143,7 @@ class CC_EXPORT PrioritizedResource { bool resource_has_been_deleted_; -#ifndef NDEBUG +#if DCHECK_IS_ON ResourceProvider* resource_provider_; #endif DISALLOW_COPY_AND_ASSIGN(Backing); diff --git a/cc/resources/prioritized_resource_manager.cc b/cc/resources/prioritized_resource_manager.cc index 707ad77..81af9fb 100644 --- a/cc/resources/prioritized_resource_manager.cc +++ b/cc/resources/prioritized_resource_manager.cc @@ -482,7 +482,7 @@ void PrioritizedResourceManager::EvictFirstBackingResource( } void PrioritizedResourceManager::AssertInvariants() { -#ifndef NDEBUG +#if DCHECK_IS_ON DCHECK(proxy_->IsImplThread() && proxy_->IsMainThreadBlocked()); // If we hit any of these asserts, there is a bug in this class. To see @@ -541,7 +541,7 @@ void PrioritizedResourceManager::AssertInvariants() { DCHECK(backing->CanBeRecycledIfNotInExternalUse()); previous_backing = backing; } -#endif +#endif // DCHECK_IS_ON } const Proxy* PrioritizedResourceManager::ProxyForDebug() const { diff --git a/cc/resources/prioritized_resource_unittest.cc b/cc/resources/prioritized_resource_unittest.cc index 7619dcc..5b0722b 100644 --- a/cc/resources/prioritized_resource_unittest.cc +++ b/cc/resources/prioritized_resource_unittest.cc @@ -78,11 +78,9 @@ class PrioritizedResourceTest : public testing::Test { void ResourceManagerAssertInvariants( PrioritizedResourceManager* resource_manager) { -#ifndef NDEBUG DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); resource_manager->AssertInvariants(); -#endif } bool TextureBackingIsAbovePriorityCutoff(PrioritizedResource* texture) { diff --git a/cc/resources/scoped_resource.cc b/cc/resources/scoped_resource.cc index a320bab..68ae59f 100644 --- a/cc/resources/scoped_resource.cc +++ b/cc/resources/scoped_resource.cc @@ -25,7 +25,7 @@ void ScopedResource::Allocate(const gfx::Size& size, set_id(resource_provider_->CreateResource( size, GL_CLAMP_TO_EDGE, hint, format)); -#ifndef NDEBUG +#if DCHECK_IS_ON allocate_thread_id_ = base::PlatformThread::CurrentId(); #endif } @@ -44,14 +44,14 @@ void ScopedResource::AllocateManaged(const gfx::Size& size, ResourceProvider::TextureUsageAny, format)); -#ifndef NDEBUG +#if DCHECK_IS_ON allocate_thread_id_ = base::PlatformThread::CurrentId(); #endif } void ScopedResource::Free() { if (id()) { -#ifndef NDEBUG +#if DCHECK_IS_ON DCHECK(allocate_thread_id_ == base::PlatformThread::CurrentId()); #endif resource_provider_->DeleteResource(id()); diff --git a/cc/resources/scoped_resource.h b/cc/resources/scoped_resource.h index eebddc1..9f58395 100644 --- a/cc/resources/scoped_resource.h +++ b/cc/resources/scoped_resource.h @@ -11,7 +11,7 @@ #include "cc/base/cc_export.h" #include "cc/resources/resource.h" -#ifndef NDEBUG +#if DCHECK_IS_ON #include "base/threading/platform_thread.h" #endif @@ -40,7 +40,7 @@ class CC_EXPORT ScopedResource : public Resource { private: ResourceProvider* resource_provider_; -#ifndef NDEBUG +#if DCHECK_IS_ON base::PlatformThreadId allocate_thread_id_; #endif diff --git a/cc/trees/layer_tree_host_impl.cc b/cc/trees/layer_tree_host_impl.cc index 26ba2ee..958419e 100644 --- a/cc/trees/layer_tree_host_impl.cc +++ b/cc/trees/layer_tree_host_impl.cc @@ -257,7 +257,7 @@ LayerTreeHostImpl::LayerTreeHostImpl( rendering_stats_instrumentation_(rendering_stats_instrumentation), micro_benchmark_controller_(this), need_to_update_visible_tiles_before_draw_(false), -#ifndef NDEBUG +#if DCHECK_IS_ON did_lose_called_(false), #endif shared_bitmap_manager_(manager), @@ -886,7 +886,7 @@ DrawSwapReadbackResult::DrawResult LayerTreeHostImpl::CalculateRenderPasses( output_surface_->capabilities().draw_and_swap_full_viewport_every_frame) draw_result = DrawSwapReadbackResult::DRAW_SUCCESS; -#ifndef NDEBUG +#if DCHECK_IS_ON for (size_t i = 0; i < frame->render_passes.size(); ++i) { for (size_t j = 0; j < frame->render_passes[i]->quad_list.size(); ++j) DCHECK(frame->render_passes[i]->quad_list[j]->shared_quad_state); @@ -1529,7 +1529,7 @@ void LayerTreeHostImpl::DidLoseOutputSurface() { // important) in production. We should adjust the test to not need this. if (renderer_) client_->DidLoseOutputSurfaceOnImplThread(); -#ifndef NDEBUG +#if DCHECK_IS_ON did_lose_called_ = true; #endif } @@ -1792,7 +1792,7 @@ void LayerTreeHostImpl::EnforceZeroBudget(bool zero_budget) { bool LayerTreeHostImpl::InitializeRenderer( scoped_ptr<OutputSurface> output_surface) { -#ifndef NDEBUG +#if DCHECK_IS_ON DCHECK(!renderer_ || did_lose_called_); #endif diff --git a/cc/trees/layer_tree_host_impl.h b/cc/trees/layer_tree_host_impl.h index 255128b..52c2c98 100644 --- a/cc/trees/layer_tree_host_impl.h +++ b/cc/trees/layer_tree_host_impl.h @@ -645,7 +645,7 @@ class CC_EXPORT LayerTreeHostImpl MicroBenchmarkControllerImpl micro_benchmark_controller_; bool need_to_update_visible_tiles_before_draw_; -#ifndef NDEBUG +#if DCHECK_IS_ON bool did_lose_called_; #endif diff --git a/cc/trees/proxy.cc b/cc/trees/proxy.cc index 9315f31..d9477cb 100644 --- a/cc/trees/proxy.cc +++ b/cc/trees/proxy.cc @@ -20,7 +20,7 @@ base::SingleThreadTaskRunner* Proxy::ImplThreadTaskRunner() const { } bool Proxy::IsMainThread() const { -#ifndef NDEBUG +#if DCHECK_IS_ON DCHECK(main_task_runner_.get()); if (impl_thread_is_overridden_) return false; @@ -31,7 +31,7 @@ bool Proxy::IsMainThread() const { } bool Proxy::IsImplThread() const { -#ifndef NDEBUG +#if DCHECK_IS_ON if (impl_thread_is_overridden_) return true; if (!impl_task_runner_.get()) @@ -42,36 +42,36 @@ bool Proxy::IsImplThread() const { #endif } -#ifndef NDEBUG +#if DCHECK_IS_ON void Proxy::SetCurrentThreadIsImplThread(bool is_impl_thread) { impl_thread_is_overridden_ = is_impl_thread; } #endif bool Proxy::IsMainThreadBlocked() const { -#ifndef NDEBUG +#if DCHECK_IS_ON return is_main_thread_blocked_; #else return true; #endif } -#ifndef NDEBUG +#if DCHECK_IS_ON void Proxy::SetMainThreadBlocked(bool is_main_thread_blocked) { is_main_thread_blocked_ = is_main_thread_blocked; } #endif -Proxy::Proxy( - scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) +Proxy::Proxy(scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) : main_task_runner_(base::MessageLoopProxy::current()), -#ifdef NDEBUG - impl_task_runner_(impl_task_runner) {} +#if !DCHECK_IS_ON + impl_task_runner_(impl_task_runner) { #else impl_task_runner_(impl_task_runner), impl_thread_is_overridden_(false), - is_main_thread_blocked_(false) {} + is_main_thread_blocked_(false) { #endif +} Proxy::~Proxy() { DCHECK(IsMainThread()); diff --git a/cc/trees/proxy.h b/cc/trees/proxy.h index e987690..4ec4f6e 100644 --- a/cc/trees/proxy.h +++ b/cc/trees/proxy.h @@ -39,7 +39,7 @@ class CC_EXPORT Proxy { bool IsMainThread() const; bool IsImplThread() const; bool IsMainThreadBlocked() const; -#ifndef NDEBUG +#if DCHECK_IS_ON void SetMainThreadBlocked(bool is_main_thread_blocked); void SetCurrentThreadIsImplThread(bool is_impl_thread); #endif @@ -112,7 +112,7 @@ class CC_EXPORT Proxy { private: scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner_; -#ifndef NDEBUG +#if DCHECK_IS_ON bool impl_thread_is_overridden_; bool is_main_thread_blocked_; #endif @@ -120,7 +120,7 @@ class CC_EXPORT Proxy { DISALLOW_COPY_AND_ASSIGN(Proxy); }; -#ifndef NDEBUG +#if DCHECK_IS_ON class DebugScopedSetMainThreadBlocked { public: explicit DebugScopedSetMainThreadBlocked(Proxy* proxy) : proxy_(proxy) { diff --git a/cc/trees/single_thread_proxy.cc b/cc/trees/single_thread_proxy.cc index ece908b..5ccef20 100644 --- a/cc/trees/single_thread_proxy.cc +++ b/cc/trees/single_thread_proxy.cc @@ -222,7 +222,7 @@ void SingleThreadProxy::DoCommit(scoped_ptr<ResourceUpdateQueue> queue) { layer_tree_host_impl_->CommitComplete(); -#ifndef NDEBUG +#if DCHECK_IS_ON // In the single-threaded case, the scale and scroll deltas should never be // touched on the impl layer tree. scoped_ptr<ScrollAndScaleSet> scroll_info = diff --git a/cc/trees/single_thread_proxy.h b/cc/trees/single_thread_proxy.h index 415dfbd..462bdd2 100644 --- a/cc/trees/single_thread_proxy.h +++ b/cc/trees/single_thread_proxy.h @@ -126,13 +126,13 @@ class SingleThreadProxy : public Proxy, LayerTreeHostImplClient { class DebugScopedSetImplThread { public: explicit DebugScopedSetImplThread(Proxy* proxy) : proxy_(proxy) { -#ifndef NDEBUG +#if DCHECK_IS_ON previous_value_ = proxy_->impl_thread_is_overridden_; proxy_->SetCurrentThreadIsImplThread(true); #endif } ~DebugScopedSetImplThread() { -#ifndef NDEBUG +#if DCHECK_IS_ON proxy_->SetCurrentThreadIsImplThread(previous_value_); #endif } @@ -149,13 +149,13 @@ class DebugScopedSetImplThread { class DebugScopedSetMainThread { public: explicit DebugScopedSetMainThread(Proxy* proxy) : proxy_(proxy) { -#ifndef NDEBUG +#if DCHECK_IS_ON previous_value_ = proxy_->impl_thread_is_overridden_; proxy_->SetCurrentThreadIsImplThread(false); #endif } ~DebugScopedSetMainThread() { -#ifndef NDEBUG +#if DCHECK_IS_ON proxy_->SetCurrentThreadIsImplThread(previous_value_); #endif } |