| 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 "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| 11 #include "SkImageEncoder.h" | 11 #include "SkImageEncoder.h" |
| 12 #include "SkOSFile.h" | 12 #include "SkOSFile.h" |
| 13 #include "SkPicture.h" | 13 #include "SkPicture.h" |
| 14 #include "SkStream.h" | 14 #include "SkStream.h" |
| 15 #include "SkString.h" | 15 #include "SkString.h" |
| 16 | 16 |
| 17 namespace sk_tools { | 17 namespace sk_tools { |
| 18 void force_all_opaque(const SkBitmap& bitmap) { | 18 void force_all_opaque(const SkBitmap& bitmap) { |
| 19 SkASSERT(NULL == bitmap.getTexture()); | 19 SkASSERT(nullptr == bitmap.getTexture()); |
| 20 SkASSERT(kN32_SkColorType == bitmap.colorType()); | 20 SkASSERT(kN32_SkColorType == bitmap.colorType()); |
| 21 if (bitmap.getTexture() || kN32_SkColorType == bitmap.colorType()) { | 21 if (bitmap.getTexture() || kN32_SkColorType == bitmap.colorType()) { |
| 22 return; | 22 return; |
| 23 } | 23 } |
| 24 | 24 |
| 25 SkAutoLockPixels lock(bitmap); | 25 SkAutoLockPixels lock(bitmap); |
| 26 for (int y = 0; y < bitmap.height(); y++) { | 26 for (int y = 0; y < bitmap.height(); y++) { |
| 27 for (int x = 0; x < bitmap.width(); x++) { | 27 for (int x = 0; x < bitmap.width(); x++) { |
| 28 *bitmap.getAddr32(x, y) |= (SK_A32_MASK << SK_A32_SHIFT); | 28 *bitmap.getAddr32(x, y) |= (SK_A32_MASK << SK_A32_SHIFT); |
| 29 } | 29 } |
| 30 } | 30 } |
| 31 } | 31 } |
| 32 | 32 |
| 33 void replace_char(SkString* str, const char oldChar, const char newChar) { | 33 void replace_char(SkString* str, const char oldChar, const char newChar) { |
| 34 if (NULL == str) { | 34 if (nullptr == str) { |
| 35 return; | 35 return; |
| 36 } | 36 } |
| 37 for (size_t i = 0; i < str->size(); ++i) { | 37 for (size_t i = 0; i < str->size(); ++i) { |
| 38 if (oldChar == str->operator[](i)) { | 38 if (oldChar == str->operator[](i)) { |
| 39 str->operator[](i) = newChar; | 39 str->operator[](i) = newChar; |
| 40 } | 40 } |
| 41 } | 41 } |
| 42 } | 42 } |
| 43 | 43 |
| 44 bool is_percentage(const char* const string) { | 44 bool is_percentage(const char* const string) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 63 SkString fullPath = SkOSPath::Join(partialPath.c_str(), baseName.c_str()
); | 63 SkString fullPath = SkOSPath::Join(partialPath.c_str(), baseName.c_str()
); |
| 64 if (SkImageEncoder::EncodeFile(fullPath.c_str(), bm, SkImageEncoder::kPN
G_Type, 100)) { | 64 if (SkImageEncoder::EncodeFile(fullPath.c_str(), bm, SkImageEncoder::kPN
G_Type, 100)) { |
| 65 return true; | 65 return true; |
| 66 } else { | 66 } else { |
| 67 SkDebugf("Failed to write the bitmap to %s.\n", fullPath.c_str()); | 67 SkDebugf("Failed to write the bitmap to %s.\n", fullPath.c_str()); |
| 68 return false; | 68 return false; |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 | 71 |
| 72 } // namespace sk_tools | 72 } // namespace sk_tools |
| OLD | NEW |