| Index: ui/app_list/views/cached_label.cc
|
| diff --git a/ui/app_list/views/cached_label.cc b/ui/app_list/views/cached_label.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..60f731e1ddc72d03e4217735ea1399f0f3fe3db2
|
| --- /dev/null
|
| +++ b/ui/app_list/views/cached_label.cc
|
| @@ -0,0 +1,34 @@
|
| +// Copyright 2013 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 "ui/app_list/views/cached_label.h"
|
| +
|
| +#include "base/utf_string_conversions.h"
|
| +#include "ui/base/resource/resource_bundle.h"
|
| +#include "ui/gfx/canvas.h"
|
| +
|
| +namespace app_list {
|
| +
|
| +CachedLabel::CachedLabel()
|
| + : needs_repaint_(true) {
|
| +}
|
| +
|
| +void CachedLabel::PaintToBackingImage() {
|
| + gfx::Canvas canvas(size(), ui::SCALE_FACTOR_100P, false /* is_opaque */);
|
| + canvas.FillRect(GetLocalBounds(), SkColorSetARGB(0, 0, 0, 0),
|
| + SkXfermode::kSrc_Mode);
|
| + Label::OnPaint(&canvas);
|
| + image_ = gfx::ImageSkia(canvas.ExtractImageRep());
|
| +}
|
| +
|
| +#if defined(OS_WIN)
|
| +void CachedLabel::OnPaint(gfx::Canvas* canvas) {
|
| + if (needs_repaint_)
|
| + PaintToBackingImage();
|
| + needs_repaint_ = false;
|
| + canvas->DrawImageInt(image_, 0, 0);
|
| +}
|
| +#endif
|
| +
|
| +} // namespace app_list
|
|
|