| 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 #ifndef UI_APP_LIST_VIEWS_CACHED_LABEL_H_ | |
| 6 #define UI_APP_LIST_VIEWS_CACHED_LABEL_H_ | |
| 7 | |
| 8 #include "build/build_config.h" | |
| 9 #include "ui/gfx/image/image_skia.h" | |
| 10 #include "ui/views/controls/label.h" | |
| 11 #include "ui/views/view.h" | |
| 12 | |
| 13 namespace gfx { | |
| 14 class Canvas; | |
| 15 } | |
| 16 | |
| 17 namespace app_list { | |
| 18 | |
| 19 // Subclass of views::Label that caches the rendered text in an ImageSkia. | |
| 20 class CachedLabel : public views::Label { | |
| 21 public: | |
| 22 CachedLabel(); | |
| 23 | |
| 24 // Have the next call to OnPaint() update the backing image. | |
| 25 void Invalidate() { needs_repaint_ = true; } | |
| 26 | |
| 27 // Calls the base label's OnPaint() to paint into a backing image. | |
| 28 void PaintToBackingImage(); | |
| 29 | |
| 30 #if defined(OS_WIN) | |
| 31 // Overridden from views::View: | |
| 32 void OnPaint(gfx::Canvas* canvas) override; | |
| 33 #endif | |
| 34 | |
| 35 // Overridden from ui::LayerDelegate: | |
| 36 void OnDeviceScaleFactorChanged(float device_scale_factor) override; | |
| 37 | |
| 38 private: | |
| 39 bool needs_repaint_; | |
| 40 gfx::ImageSkia image_; | |
| 41 }; | |
| 42 | |
| 43 } // namespace app_list | |
| 44 | |
| 45 #endif // UI_APP_LIST_VIEWS_CACHED_LABEL_H_ | |
| OLD | NEW |