Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 if (bitmap_.width() != width() || bitmap_.height() != height()) { | |
| 19 bitmap_.setConfig(SkBitmap::kARGB_8888_Config, width(), height()); | |
| 20 bitmap_.allocPixels(); | |
| 21 image_ = gfx::ImageSkia::CreateFrom1xBitmap(bitmap_); | |
| 22 } | |
| 23 | |
| 24 SkCanvas sk_canvas(bitmap_); | |
| 25 scoped_ptr<gfx::Canvas> canvas(gfx::Canvas::CreateCanvasWithoutScaling( | |
| 26 &sk_canvas, ui::SCALE_FACTOR_100P)); | |
| 27 | |
| 28 canvas->FillRect(gfx::Rect(0, 0, width(), height()), | |
| 29 SkColorSetARGB(0x0, 0, 0, 0), SkXfermode::kSrc_Mode); | |
|
xiyuan
2013/03/13 04:14:50
Transparency might break ClearType painting and ha
koz (OOO until 15th September)
2013/03/13 04:43:28
The difficulty I found with opaque backgrounds is
| |
| 30 Label::OnPaint(canvas.get()); | |
|
xiyuan
2013/03/13 04:14:50
Are you using a SkBitmap to save some allocation?
koz (OOO until 15th September)
2013/03/13 04:43:28
Everything I do here is out of ignorance of a bett
| |
| 31 } | |
| 32 | |
| 33 #if defined(OS_WIN) | |
| 34 void CachedLabel::OnPaint(gfx::Canvas* canvas) { | |
| 35 if (needs_repaint_) | |
| 36 PaintToBackingImage(); | |
| 37 needs_repaint_ = false; | |
| 38 canvas->DrawImageInt(image_, 0, 0); | |
| 39 } | |
| 40 #endif | |
| 41 | |
| 42 } // namespace app_list | |
| OLD | NEW |