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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 SkAutoLockPixels lock(bitmap); | 78 SkAutoLockPixels lock(bitmap); |
79 for (int y = 0; y < bitmap.height(); y++) { | 79 for (int y = 0; y < bitmap.height(); y++) { |
80 for (int x = 0; x < bitmap.width(); x++) { | 80 for (int x = 0; x < bitmap.width(); x++) { |
81 *bitmap.getAddr32(x, y) |= (SK_A32_MASK << SK_A32_SHIFT); | 81 *bitmap.getAddr32(x, y) |= (SK_A32_MASK << SK_A32_SHIFT); |
82 } | 82 } |
83 } | 83 } |
84 } | 84 } |
85 | 85 |
86 bool write_bitmap(const SkString& path, const SkBitmap& bitmap) { | 86 bool write_bitmap(const SkString& path, const SkBitmap& bitmap) { |
87 SkBitmap copy; | 87 SkBitmap copy; |
88 bitmap.copyTo(©, kN32_SkColorType); | 88 bitmap.copyTo(©, kPMColor_SkColorType); |
89 force_all_opaque(copy); | 89 force_all_opaque(copy); |
90 return SkImageEncoder::EncodeFile(path.c_str(), copy, | 90 return SkImageEncoder::EncodeFile(path.c_str(), copy, |
91 SkImageEncoder::kPNG_Type, 100); | 91 SkImageEncoder::kPNG_Type, 100); |
92 } | 92 } |
93 | 93 |
94 /// Return a copy of the "input" string, within which we have replaced all insta
nces | 94 /// Return a copy of the "input" string, within which we have replaced all insta
nces |
95 /// of oldSubstring with newSubstring. | 95 /// of oldSubstring with newSubstring. |
96 /// | 96 /// |
97 /// TODO: If we like this, we should move it into the core SkString implementati
on, | 97 /// TODO: If we like this, we should move it into the core SkString implementati
on, |
98 /// adding more checks and ample test cases, and paying more attention to effici
ency. | 98 /// adding more checks and ample test cases, and paying more attention to effici
ency. |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 drp->fDifference.fStatus = DiffResource::kDoesNotExist_Status; | 177 drp->fDifference.fStatus = DiffResource::kDoesNotExist_Status; |
178 } | 178 } |
179 if (write_bitmap(drp->fWhite.fFullPath, drp->fWhite.fBitmap)) { | 179 if (write_bitmap(drp->fWhite.fFullPath, drp->fWhite.fBitmap)) { |
180 drp->fWhite.fStatus = DiffResource::kExists_Status; | 180 drp->fWhite.fStatus = DiffResource::kExists_Status; |
181 } else { | 181 } else { |
182 drp->fWhite.fStatus = DiffResource::kDoesNotExist_Status; | 182 drp->fWhite.fStatus = DiffResource::kDoesNotExist_Status; |
183 } | 183 } |
184 } | 184 } |
185 } | 185 } |
186 } | 186 } |
OLD | NEW |