2 * Copyright 2012 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #include "picture_utils.h"
10 #include "SkPicture.h"
16 void make_filepath(SkString* path, const SkString& dir, const SkString& name) {
17 size_t len = dir.size();
19 if (0 < len && '/' != dir[len - 1]) {
26 bool is_path_seperator(const char chr) {
27 #if defined(SK_BUILD_FOR_WIN)
28 return chr == '\\' || chr == '/';
35 void get_basename(SkString* basename, const SkString& path) {
36 if (path.size() == 0) {
41 size_t end = path.size() - 1;
43 // Paths pointing to directories often have a trailing slash,
44 // we remove it so the name is not empty
45 if (is_path_seperator(path[end])) {
57 if (is_path_seperator(path[i])) {
58 const char* basenameStart = path.c_str() + i + 1;
59 size_t basenameLength = end - i;
60 basename->set(basenameStart, basenameLength);
65 basename->set(path.c_str(), end + 1);
68 void setup_bitmap(SkBitmap* bitmap, int width, int height) {
69 bitmap->setConfig(SkBitmap::kARGB_8888_Config, width, height);
70 bitmap->allocPixels();
71 bitmap->eraseColor(0);