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 "SkCodec.h" | 10 #include "SkCodec.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 } | 26 } |
27 | 27 |
28 sk_sp<SkData> read_file(const char* file_path) { | 28 sk_sp<SkData> read_file(const char* file_path) { |
29 sk_sp<SkData> data(SkData::MakeFromFileName(file_path)); | 29 sk_sp<SkData> data(SkData::MakeFromFileName(file_path)); |
30 if (!data) { | 30 if (!data) { |
31 SkDebugf("WARNING: could not open file <%s> for reading\n", file_path); | 31 SkDebugf("WARNING: could not open file <%s> for reading\n", file_path); |
32 } | 32 } |
33 return data; | 33 return data; |
34 } | 34 } |
35 | 35 |
36 bool get_bitmap(SkData* fileBits, DiffResource& resource, bool sizeOnly) { | 36 bool get_bitmap(sk_sp<SkData> fileBits, DiffResource& resource, bool sizeOnly) { |
37 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(fileBits)); | 37 SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(fileBits)); |
38 if (!codec) { | 38 if (!codec) { |
39 SkDebugf("ERROR: could not create codec for <%s>\n", resource.fFullPath.
c_str()); | 39 SkDebugf("ERROR: could not create codec for <%s>\n", resource.fFullPath.
c_str()); |
40 resource.fStatus = DiffResource::kCouldNotDecode_Status; | 40 resource.fStatus = DiffResource::kCouldNotDecode_Status; |
41 return false; | 41 return false; |
42 } | 42 } |
43 | 43 |
44 if (!resource.fBitmap.setInfo(codec->getInfo().makeColorType(kN32_SkColorTyp
e))) { | 44 if (!resource.fBitmap.setInfo(codec->getInfo().makeColorType(kN32_SkColorTyp
e))) { |
45 SkDebugf("ERROR: could not set bitmap info for <%s>\n", resource.fFullPa
th.c_str()); | 45 SkDebugf("ERROR: could not set bitmap info for <%s>\n", resource.fFullPa
th.c_str()); |
46 resource.fStatus = DiffResource::kCouldNotDecode_Status; | 46 resource.fStatus = DiffResource::kCouldNotDecode_Status; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 drp->fDifference.fStatus = DiffResource::kDoesNotExist_Status; | 170 drp->fDifference.fStatus = DiffResource::kDoesNotExist_Status; |
171 } | 171 } |
172 if (write_bitmap(drp->fWhite.fFullPath, drp->fWhite.fBitmap)) { | 172 if (write_bitmap(drp->fWhite.fFullPath, drp->fWhite.fBitmap)) { |
173 drp->fWhite.fStatus = DiffResource::kExists_Status; | 173 drp->fWhite.fStatus = DiffResource::kExists_Status; |
174 } else { | 174 } else { |
175 drp->fWhite.fStatus = DiffResource::kDoesNotExist_Status; | 175 drp->fWhite.fStatus = DiffResource::kDoesNotExist_Status; |
176 } | 176 } |
177 } | 177 } |
178 } | 178 } |
179 } | 179 } |
OLD | NEW |