• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 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/base/nine_image_painter_factory.h"
6 
7 #include "ui/base/resource/resource_bundle.h"
8 #include "ui/gfx/nine_image_painter.h"
9 
10 namespace ui {
11 
12 namespace {
13 
ImageIdsToImages(const int image_ids[])14 std::vector<gfx::ImageSkia> ImageIdsToImages(const int image_ids[]) {
15   ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
16   std::vector<gfx::ImageSkia> images(9);
17   for (size_t i = 0; i < 9; ++i) {
18     if (image_ids[i] != 0)
19       images[i] = *rb.GetImageSkiaNamed(image_ids[i]);
20   }
21   return images;
22 }
23 
24 }  // namespace
25 
CreateNineImagePainter(const int image_ids[])26 scoped_ptr<gfx::NineImagePainter> CreateNineImagePainter(
27     const int image_ids[]) {
28   return scoped_ptr<gfx::NineImagePainter>(
29       new gfx::NineImagePainter(ImageIdsToImages(image_ids)));
30 }
31 
32 }  // namespace ui
33