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

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

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/cached_label.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « ui/app_list/views/cached_label.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698