Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: dm/DMWriteTask.cpp

Issue 152223003: DM: catch -r foo -w foo. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698