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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/app_list/views/cached_label.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/app_list/views/cached_label.h"
6
7 #include "base/utf_string_conversions.h"
8 #include "ui/base/resource/resource_bundle.h"
9 #include "ui/gfx/canvas.h"
10
11 namespace app_list {
12
13 CachedLabel::CachedLabel()
14 : needs_repaint_(true) {
15 }
16
17 void CachedLabel::PaintToBackingImage() {
18 gfx::Canvas canvas(size(), ui::SCALE_FACTOR_100P, false /* is_opaque */);
19 canvas.FillRect(GetLocalBounds(), SkColorSetARGB(0, 0, 0, 0),
20 SkXfermode::kSrc_Mode);
21 Label::OnPaint(&canvas);
22 image_ = gfx::ImageSkia(canvas.ExtractImageRep());
23 }
24
25 #if defined(OS_WIN)
26 void CachedLabel::OnPaint(gfx::Canvas* canvas) {
27 if (needs_repaint_)
28 PaintToBackingImage();
29 needs_repaint_ = false;
30 canvas->DrawImageInt(image_, 0, 0);
31 }
32 #endif
33
34 } // namespace app_list
OLDNEW
« 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