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 "SkImageEncoder.h" | 6 #include "SkImageEncoder.h" |
7 #include "SkMallocPixelRef.h" | 7 #include "SkMallocPixelRef.h" |
8 #include "SkStream.h" | 8 #include "SkStream.h" |
9 #include "SkString.h" | 9 #include "SkString.h" |
10 | 10 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 77 |
78 // The raw pixels are at the end of the file. We'll skip the encoded PN
G at the front. | 78 // The raw pixels are at the end of the file. We'll skip the encoded PN
G at the front. |
79 const size_t rowBytes = info.minRowBytes(); // Assume densely packed. | 79 const size_t rowBytes = info.minRowBytes(); // Assume densely packed. |
80 const size_t bitmapBytes = info.getSafeSize(rowBytes); | 80 const size_t bitmapBytes = info.getSafeSize(rowBytes); |
81 if (data->size() < bitmapBytes) { | 81 if (data->size() < bitmapBytes) { |
82 SkDebugf("%s is too small to contain the bitmap we're looking for.\n
", path); | 82 SkDebugf("%s is too small to contain the bitmap we're looking for.\n
", path); |
83 return false; | 83 return false; |
84 } | 84 } |
85 | 85 |
86 const size_t offset = data->size() - bitmapBytes; | 86 const size_t offset = data->size() - bitmapBytes; |
| 87 SkAutoTUnref<SkData> subset( |
| 88 SkData::NewSubset(data, offset, bitmapBytes)); |
87 SkAutoTUnref<SkPixelRef> pixels( | 89 SkAutoTUnref<SkPixelRef> pixels( |
88 SkMallocPixelRef::NewWithData(info, rowBytes, NULL/*ctable*/, data,
offset)); | 90 SkMallocPixelRef::NewWithData( |
| 91 info, rowBytes, NULL/*ctable*/, subset)); |
89 SkASSERT(pixels); | 92 SkASSERT(pixels); |
90 | 93 |
91 bitmap->setConfig(info, rowBytes); | 94 bitmap->setConfig(info, rowBytes); |
92 bitmap->setPixelRef(pixels); | 95 bitmap->setPixelRef(pixels); |
93 return true; | 96 return true; |
94 } | 97 } |
95 }; | 98 }; |
96 | 99 |
97 } // namespace | 100 } // namespace |
98 | 101 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 const SkString path = path_to_expected_image(fRoot, task); | 154 const SkString path = path_to_expected_image(fRoot, task); |
152 SkBitmap expected; | 155 SkBitmap expected; |
153 if (!PngAndRaw::Decode(path.c_str(), bitmap.info(), &expected)) { | 156 if (!PngAndRaw::Decode(path.c_str(), bitmap.info(), &expected)) { |
154 return false; | 157 return false; |
155 } | 158 } |
156 | 159 |
157 return BitmapsEqual(expected, bitmap); | 160 return BitmapsEqual(expected, bitmap); |
158 } | 161 } |
159 | 162 |
160 } // namespace DM | 163 } // namespace DM |
OLD | NEW |