summaryrefslogtreecommitdiffstats
path: root/ui/base/nine_image_painter_factory.cc
blob: 3b47160e31fc443408970d95537807304176944b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/base/nine_image_painter_factory.h"

#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/nine_image_painter.h"

namespace ui {

namespace {

std::vector<gfx::ImageSkia> ImageIdsToImages(const int image_ids[]) {
  ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
  std::vector<gfx::ImageSkia> images(9);
  for (size_t i = 0; i < 9; ++i) {
    if (image_ids[i] != 0)
      images[i] = *rb.GetImageSkiaNamed(image_ids[i]);
  }
  return images;
}

}  // namespace

scoped_ptr<gfx::NineImagePainter> CreateNineImagePainter(
    const int image_ids[]) {
  return make_scoped_ptr(
      new gfx::NineImagePainter(ImageIdsToImages(image_ids)));
}

}  // namespace ui