badge_util.h revision 201ade2fbba22bfb27ae029f4d23fca6ded109a0
1// Copyright (c) 2010 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 CHROME_COMMON_BADGE_UTIL_H_ 6#define CHROME_COMMON_BADGE_UTIL_H_ 7#pragma once 8 9#include "base/string16.h" 10#include "third_party/skia/include/core/SkBitmap.h" 11 12class SkPaint; 13 14// badge_util provides a set of helper routines for rendering dynamically 15// generated text overlays ("badges") on toolbar icons. 16namespace badge_util { 17 18// Helper routine that returns a singleton SkPaint object configured for 19// rendering badge overlay text (correct font, typeface, etc). 20SkPaint* GetBadgeTextPaintSingleton(); 21 22// Given an |icon|, renders the |text| centered on the |icon|. If |text| is 23// too large to fit within the bounds of the image, the |fallback| string is 24// rendered instead (or nothing, if |fallback| is empty). 25SkBitmap DrawBadgeIconOverlay(const SkBitmap& icon, 26 float font_size_in_pixels, 27 const string16& text, 28 const string16& fallback); 29 30} // namespace badge_util; 31 32#endif // CHROME_COMMON_BADGE_UTIL_H_ 33