OLD | NEW |
1 #include "DMWriteTask.h" | 1 #include "DMWriteTask.h" |
2 | 2 |
3 #include "DMUtil.h" | 3 #include "DMUtil.h" |
4 #include "SkColorPriv.h" | 4 #include "SkColorPriv.h" |
5 #include "SkCommandLineFlags.h" | 5 #include "SkCommandLineFlags.h" |
6 #include "SkImageDecoder.h" | 6 #include "SkImageDecoder.h" |
7 #include "SkImageEncoder.h" | 7 #include "SkImageEncoder.h" |
8 #include "SkString.h" | 8 #include "SkString.h" |
9 #include "SkUnPreMultiply.h" | 9 #include "SkUnPreMultiply.h" |
10 | 10 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 // Remove the suffix and tack on a .png. | 84 // Remove the suffix and tack on a .png. |
85 filename.remove(filename.size() - suffixLength, suffixLength); | 85 filename.remove(filename.size() - suffixLength, suffixLength); |
86 filename.append(".png"); | 86 filename.append(".png"); |
87 | 87 |
88 //SkDebugf("dir %s, filename %s\n", dir.c_str(), filename.c_str()); | 88 //SkDebugf("dir %s, filename %s\n", dir.c_str(), filename.c_str()); |
89 | 89 |
90 return SkOSPath::SkPathJoin(dir.c_str(), filename.c_str()); | 90 return SkOSPath::SkPathJoin(dir.c_str(), filename.c_str()); |
91 } | 91 } |
92 | 92 |
93 bool WriteTask::Expectations::check(const Task& task, SkBitmap bitmap) const { | 93 bool WriteTask::Expectations::check(const Task& task, SkBitmap bitmap) const { |
| 94 if (!FLAGS_writePath.isEmpty() && 0 == strcmp(FLAGS_writePath[0], fRoot)) { |
| 95 SkDebugf("We seem to be reading and writing %s concurrently. This won't
work.\n", fRoot); |
| 96 return false; |
| 97 } |
| 98 |
94 // PNG is stored unpremultiplied, and going from premul to unpremul to premu
l is lossy. To | 99 // PNG is stored unpremultiplied, and going from premul to unpremul to premu
l is lossy. To |
95 // skirt this problem, we decode the PNG into an unpremul bitmap, convert ou
r bitmap to unpremul | 100 // skirt this problem, we decode the PNG into an unpremul bitmap, convert ou
r bitmap to unpremul |
96 // if needed, and compare those. Each image goes once from premul to unprem
ul, never back. | 101 // if needed, and compare those. Each image goes once from premul to unprem
ul, never back. |
97 const SkString path = path_to_expected_image(fRoot, task); | 102 const SkString path = path_to_expected_image(fRoot, task); |
98 | 103 |
99 SkAutoTUnref<SkStreamRewindable> stream(SkStream::NewFromFile(path.c_str()))
; | 104 SkAutoTUnref<SkStreamRewindable> stream(SkStream::NewFromFile(path.c_str()))
; |
100 if (NULL == stream.get()) { | 105 if (NULL == stream.get()) { |
101 SkDebugf("Could not read %s.\n", path.c_str()); | 106 SkDebugf("Could not read %s.\n", path.c_str()); |
102 return false; | 107 return false; |
103 } | 108 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 for (size_t i = 0; i < bitmap.getSize()/4; i++) { | 148 for (size_t i = 0; i < bitmap.getSize()/4; i++) { |
144 dst[i] = SkUnPreMultiply::UnPreMultiplyPreservingByteOrder(src[i]); | 149 dst[i] = SkUnPreMultiply::UnPreMultiplyPreservingByteOrder(src[i]); |
145 } | 150 } |
146 bitmap.swap(unpremul); | 151 bitmap.swap(unpremul); |
147 } | 152 } |
148 | 153 |
149 return BitmapsEqual(expected, bitmap); | 154 return BitmapsEqual(expected, bitmap); |
150 } | 155 } |
151 | 156 |
152 } // namespace DM | 157 } // namespace DM |
OLD | NEW |