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" |
11 #include "SkData.h" | 11 #include "SkData.h" |
12 #include "SkImageEncoder.h" | 12 #include "SkImageEncoder.h" |
13 #include "SkStream.h" | 13 #include "SkStream.h" |
14 #include "SkTypes.h" | 14 #include "SkTypes.h" |
15 | 15 |
16 #include <memory> | 16 #include <memory> |
17 | 17 |
18 bool are_buffers_equal(SkData* skdata1, SkData* skdata2) { | 18 bool are_buffers_equal(SkData* skdata1, SkData* skdata2) { |
19 if ((nullptr == skdata1) || (nullptr == skdata2)) { | 19 if ((nullptr == skdata1) || (nullptr == skdata2)) { |
20 return false; | 20 return false; |
21 } | 21 } |
22 if (skdata1->size() != skdata2->size()) { | 22 if (skdata1->size() != skdata2->size()) { |
23 return false; | 23 return false; |
24 } | 24 } |
25 return (0 == memcmp(skdata1->data(), skdata2->data(), skdata1->size())); | 25 return (0 == memcmp(skdata1->data(), skdata2->data(), skdata1->size())); |
26 } | 26 } |
27 | 27 |
28 SkData* read_file(const char* file_path) { | 28 sk_sp<SkData> read_file(const char* file_path) { |
29 SkData* data = SkData::NewFromFileName(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(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()); |
(...skipping 130 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 |