Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(490)

Unified Diff: ui/app_list/views/cached_label.h

Issue 12771021: Make painting app list items more efficient by caching the labels. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: respond to comments Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/app_list/views/app_list_item_view.cc ('k') | ui/app_list/views/cached_label.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 100644
index 0000000000000000000000000000000000000000..a5a497a4783546da80b3fed5fa8c0ed5092f4952
--- /dev/null
+++ b/ui/app_list/views/cached_label.h
@@ -0,0 +1,41 @@
+// 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.
+
+#ifndef UI_APP_LIST_VIEWS_CACHED_LABEL_H_
+#define UI_APP_LIST_VIEWS_CACHED_LABEL_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 an ImageSkia.
+class CachedLabel : public views::Label {
+ public:
+ CachedLabel();
+
+ // Have the next call to OnPaint() update the backing image.
+ void Invalidate() { needs_repaint_ = true; }
+
+#if defined(OS_WIN)
+ // views::View overrides.
+ virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
+#endif
+
+ private:
+ // Calls the base label's OnPaint() to paint into a backing image.
+ void PaintToBackingImage();
+
+ bool needs_repaint_;
+ gfx::ImageSkia image_;
+};
+
+} // namespace app_list
+
+#endif // UI_APP_LIST_VIEWS_CACHED_LABEL_H_
« no previous file with comments | « ui/app_list/views/app_list_item_view.cc ('k') | ui/app_list/views/cached_label.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698