| 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 100755
|
| index 0000000000000000000000000000000000000000..e661c23e57de69f6ed0b26e7a135ad80903d9cf2
|
| --- /dev/null
|
| +++ b/ui/app_list/views/cached_label.cc
|
| @@ -0,0 +1,40 @@
|
| +// Copyright (c) 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() {
|
| + if (bitmap_.width() != width() || bitmap_.height() != height()) {
|
| + bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width(), height());
|
| + bitmap_.allocPixels();
|
| + image_ = gfx::ImageSkia::CreateFrom1xBitmap(bitmap_);
|
| + }
|
| +
|
| + SkCanvas sk_canvas(bitmap_);
|
| + scoped_ptr<gfx::Canvas> canvas(gfx::Canvas::CreateCanvasWithoutScaling(
|
| + &sk_canvas, ui::SCALE_FACTOR_100P));
|
| +
|
| + canvas->FillRect(gfx::Rect(0, 0, width(), height()),
|
| + SkColorSetARGB(0x0, 0, 0, 0), SkXfermode::kSrc_Mode);
|
| + Label::OnPaint(canvas.get());
|
| +}
|
| +
|
| +void CachedLabel::OnPaint(gfx::Canvas* canvas) {
|
| + if (needs_repaint_)
|
| + PaintToBackingImage();
|
| + needs_repaint_ = false;
|
| + canvas->DrawImageInt(image_, 0, 0);
|
| +}
|
| +
|
| +} // namespace app_list
|
|
|