OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "picture_utils.h" | 8 #include "picture_utils.h" |
9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 } | 29 } |
30 | 30 |
31 SkAutoLockPixels lock(bitmap); | 31 SkAutoLockPixels lock(bitmap); |
32 for (int y = 0; y < bitmap.height(); y++) { | 32 for (int y = 0; y < bitmap.height(); y++) { |
33 for (int x = 0; x < bitmap.width(); x++) { | 33 for (int x = 0; x < bitmap.width(); x++) { |
34 *bitmap.getAddr32(x, y) |= (SK_A32_MASK << SK_A32_SHIFT); | 34 *bitmap.getAddr32(x, y) |= (SK_A32_MASK << SK_A32_SHIFT); |
35 } | 35 } |
36 } | 36 } |
37 } | 37 } |
38 | 38 |
| 39 void replace_char(SkString* str, const char oldChar, const char newChar) { |
| 40 if (NULL == str) { |
| 41 return; |
| 42 } |
| 43 for (size_t i = 0; i < str->size(); ++i) { |
| 44 if (oldChar == str->operator[](i)) { |
| 45 str->operator[](i) = newChar; |
| 46 } |
| 47 } |
| 48 } |
| 49 |
39 void make_filepath(SkString* path, const SkString& dir, const SkString& name
) { | 50 void make_filepath(SkString* path, const SkString& dir, const SkString& name
) { |
40 size_t len = dir.size(); | 51 size_t len = dir.size(); |
41 path->set(dir); | 52 path->set(dir); |
42 if (0 < len && '/' != dir[len - 1]) { | 53 if (0 < len && '/' != dir[len - 1]) { |
43 path->append("/"); | 54 path->append("/"); |
44 } | 55 } |
45 path->append(name); | 56 path->append(name); |
46 } | 57 } |
47 | 58 |
48 void get_basename(SkString* basename, const SkString& path) { | 59 void get_basename(SkString* basename, const SkString& path) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 SkString skString(string); | 93 SkString skString(string); |
83 return skString.endsWith("%"); | 94 return skString.endsWith("%"); |
84 } | 95 } |
85 | 96 |
86 void setup_bitmap(SkBitmap* bitmap, int width, int height) { | 97 void setup_bitmap(SkBitmap* bitmap, int width, int height) { |
87 bitmap->setConfig(SkBitmap::kARGB_8888_Config, width, height); | 98 bitmap->setConfig(SkBitmap::kARGB_8888_Config, width, height); |
88 bitmap->allocPixels(); | 99 bitmap->allocPixels(); |
89 bitmap->eraseColor(SK_ColorTRANSPARENT); | 100 bitmap->eraseColor(SK_ColorTRANSPARENT); |
90 } | 101 } |
91 } | 102 } |
OLD | NEW |