Chromium Code Reviews| Index: ui/app_list/views/cached_label.h |
| diff --git a/ui/app_list/views/cached_label.h b/ui/app_list/views/cached_label.h |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..08c9eeef2efc829d1f5db1208ad82f67348b06e3 |
| --- /dev/null |
| +++ b/ui/app_list/views/cached_label.h |
| @@ -0,0 +1,41 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
|
benwells
2013/03/12 04:58:11
super important nit: no (c)
koz (OOO until 15th September)
2013/03/13 00:30:36
Done.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef UI_APP_LIST_VIEWS_CACHED_LABEL_H_ |
| +#define UI_APP_LIST_VIEWS_CACHED_LABEL_H_ |
| + |
| +#include "third_party/skia/include/core/SkBitmap.h" |
| +#include "ui/gfx/image/image_skia.h" |
| +#include "ui/views/controls/label.h" |
| +#include "ui/views/view.h" |
| + |
| +namespace gfx { |
| +class Canvas; |
| +} |
| + |
| +namespace app_list { |
| + |
| +// Subclass of views::Label that caches the rendered text in a SkBitmap. |
| +class CachedLabel : public views::Label { |
| + public: |
| + CachedLabel(); |
| + |
| + // Have the next call to OnPaint() update the backing image. |
| + void Invalidate() { needs_repaint_ = true; } |
| + |
| + // views::View overrides. |
| + virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
| + |
| + private: |
| + // Calls the base label's OnPaint() to paint into a backing image. |
| + void PaintToBackingImage(); |
| + |
| + bool needs_repaint_; |
| + SkBitmap bitmap_; |
| + gfx::ImageSkia image_; |
| +}; |
| + |
| +} // namespace app_list |
| + |
| +#endif // UI_APP_LIST_VIEWS_CACHED_LABEL_H_ |