Views Omnibox: tolerate minor click-to-select-all dragging.
[chromium-blink-merge.git] / ui / app_list / views / cached_label.cc
bloba7d9e27e9e3592ee2af4ac0d4f84f25ebbee176f
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.
5 #include "ui/app_list/views/cached_label.h"
7 #include "base/strings/utf_string_conversions.h"
8 #include "ui/base/resource/resource_bundle.h"
9 #include "ui/gfx/canvas.h"
11 namespace app_list {
13 CachedLabel::CachedLabel()
14 : needs_repaint_(true) {
17 void CachedLabel::PaintToBackingImage() {
18 if (image_.size() == size() && !needs_repaint_)
19 return;
20 gfx::Canvas canvas(size(), 1.0f, false /* is_opaque */);
21 canvas.FillRect(GetLocalBounds(), SkColorSetARGB(0, 0, 0, 0),
22 SkXfermode::kSrc_Mode);
23 Label::OnPaint(&canvas);
24 image_ = gfx::ImageSkia(canvas.ExtractImageRep());
25 needs_repaint_ = false;
28 #if defined(OS_WIN)
29 void CachedLabel::OnPaint(gfx::Canvas* canvas) {
30 PaintToBackingImage();
31 canvas->DrawImageInt(image_, 0, 0);
33 #endif
35 } // namespace app_list