summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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);