summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-24 18:12:54 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-24 18:12:54 +0000
commit38856c732d770f9d628413cbd8fc972ca6f28a85 (patch)
tree63b3b58f9db37e4c81246d6ca64e76b4744d1437 /views
parent2ccdef6db7f9b14a72922e7c5cd3ad82e8662214 (diff)
downloadchromium_src-38856c732d770f9d628413cbd8fc972ca6f28a85.zip
chromium_src-38856c732d770f9d628413cbd8fc972ca6f28a85.tar.gz
chromium_src-38856c732d770f9d628413cbd8fc972ca6f28a85.tar.bz2
Makes Background only create a brush when needed. This avoids
irrelevant DCHECKs if you use a color with alpha. BUG=none TEST=none R=ben@chromium.org Review URL: http://codereview.chromium.org/7065013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86454 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/background.cc12
-rw-r--r--views/background.h6
2 files changed, 13 insertions, 5 deletions
diff --git a/views/background.cc b/views/background.cc
index 1c374e4..f9eb2135 100644
--- a/views/background.cc
+++ b/views/background.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -75,10 +75,18 @@ void Background::SetNativeControlColor(SkColor color) {
color_ = color;
#if defined(OS_WIN)
DeleteObject(native_control_brush_);
- native_control_brush_ = CreateSolidBrush(skia::SkColorToCOLORREF(color));
+ native_control_brush_ = NULL;
#endif
}
+#if defined(OS_WIN)
+HBRUSH Background::GetNativeControlBrush() const {
+ if (!native_control_brush_)
+ native_control_brush_ = CreateSolidBrush(skia::SkColorToCOLORREF(color_));
+ return native_control_brush_;
+}
+#endif
+
//static
Background* Background::CreateSolidBackground(const SkColor& color) {
return new SolidBackground(color);
diff --git a/views/background.h b/views/background.h
index 56bb7f8..abed279 100644
--- a/views/background.h
+++ b/views/background.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -84,14 +84,14 @@ class Background {
// TODO(port): Make GetNativeControlBrush portable (currently uses HBRUSH).
// Get the brush that was specified by SetNativeControlColor
- HBRUSH GetNativeControlBrush() const { return native_control_brush_; };
+ HBRUSH GetNativeControlBrush() const;
#endif // defined(OS_WIN)
private:
SkColor color_;
#if defined(OS_WIN)
// TODO(port): Create portable replacement for HBRUSH.
- HBRUSH native_control_brush_;
+ mutable HBRUSH native_control_brush_;
#endif // defined(OS_WIN)
DISALLOW_COPY_AND_ASSIGN(Background);