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 #include "skdiff.h" | 7 #include "skdiff.h" |
8 #include "skdiff_utils.h" | 8 #include "skdiff_utils.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkData.h" | 10 #include "SkData.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 *bitmap.getAddr32(x, y) |= (SK_A32_MASK << SK_A32_SHIFT); | 65 *bitmap.getAddr32(x, y) |= (SK_A32_MASK << SK_A32_SHIFT); |
66 } | 66 } |
67 } | 67 } |
68 } | 68 } |
69 | 69 |
70 bool write_bitmap(const SkString& path, const SkBitmap& bitmap) { | 70 bool write_bitmap(const SkString& path, const SkBitmap& bitmap) { |
71 SkBitmap copy; | 71 SkBitmap copy; |
72 bitmap.copyTo(©, kN32_SkColorType); | 72 bitmap.copyTo(©, kN32_SkColorType); |
73 force_all_opaque(copy); | 73 force_all_opaque(copy); |
74 return SkImageEncoder::EncodeFile(path.c_str(), copy, | 74 return SkImageEncoder::EncodeFile(path.c_str(), copy, |
75 SkImageEncoder::kPNG_Type, 100); | 75 kPNG_SkEncodedFormat, 100); |
76 } | 76 } |
77 | 77 |
78 /// Return a copy of the "input" string, within which we have replaced all insta
nces | 78 /// Return a copy of the "input" string, within which we have replaced all insta
nces |
79 /// of oldSubstring with newSubstring. | 79 /// of oldSubstring with newSubstring. |
80 /// | 80 /// |
81 /// TODO: If we like this, we should move it into the core SkString implementati
on, | 81 /// TODO: If we like this, we should move it into the core SkString implementati
on, |
82 /// adding more checks and ample test cases, and paying more attention to effici
ency. | 82 /// adding more checks and ample test cases, and paying more attention to effici
ency. |
83 static SkString replace_all(const SkString &input, | 83 static SkString replace_all(const SkString &input, |
84 const char oldSubstring[], const char newSubstring[]
) { | 84 const char oldSubstring[], const char newSubstring[]
) { |
85 SkString output; | 85 SkString output; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 drp->fDifference.fStatus = DiffResource::kDoesNotExist_Status; | 159 drp->fDifference.fStatus = DiffResource::kDoesNotExist_Status; |
160 } | 160 } |
161 if (write_bitmap(drp->fWhite.fFullPath, drp->fWhite.fBitmap)) { | 161 if (write_bitmap(drp->fWhite.fFullPath, drp->fWhite.fBitmap)) { |
162 drp->fWhite.fStatus = DiffResource::kExists_Status; | 162 drp->fWhite.fStatus = DiffResource::kExists_Status; |
163 } else { | 163 } else { |
164 drp->fWhite.fStatus = DiffResource::kDoesNotExist_Status; | 164 drp->fWhite.fStatus = DiffResource::kDoesNotExist_Status; |
165 } | 165 } |
166 } | 166 } |
167 } | 167 } |
168 } | 168 } |
OLD | NEW |